mcpbeat Sign in

0g Compute Agent Skill

0G Compute Network guide for decentralized AI inference, fine-tuning, and GPU services. Covers chatbots, image generation, speech-to-text, SDK integration (0g-serving-broker), processResponse API, broker.inference methods, CLI commands (0g-compute-cli), and account management. Use this skill for any 0G compute, 0G AI, or decentralized GPU question.

31k tokens
context cost
the whole folder, loaded on every use
11
files
instructions only
1
copies elsewhere
how many repositories repackaged it
1529
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/internet-court/internet-court-skill --skill 0g-compute

What comes with it

115 653 bytes besides the instruction
.github/workflows/claude-code-review.yml
LICENSE
README.md
references/account-management.md
references/examples/README.md
references/examples/speech-to-text.md
references/examples/streaming-chat.md
references/examples/text-to-image.md
references/fine-tuning.md
references/inference.md

The instruction itself

13 sections, as written by the author

0G Compute Network

This skill provides instructions for building with the 0G Compute Network — a decentralized GPU marketplace for AI inference and model fine-tuning. Follow these patterns exactly when generating code.

Code Generation Rules

  • Copy code patterns from this skill verbatim. Do NOT generate from training data.
  • Call processResponse() after every API response (see processResponse section below).
  • Use environment variables for private keys. Never hardcode secrets.
  • Route users to testnet for initial development.

When unsure about a pattern, reference the detailed guides:

  • Inference patterns: references/inference.md
  • Fine-tuning workflow: references/fine-tuning.md
  • Account management: references/account-management.md
  • Production examples: references/examples/

Network Information

| Network | RPC URL | Inference | Fine-tuning |

|---------|---------|-----------|-------------|

| Mainnet | https://evmrpc.0g.ai | Yes | Yes |

| Testnet | https://evmrpc-testnet.0g.ai | Yes | Yes |

Model availability changes frequently. Always use broker.inference.listService() or 0g-compute-cli inference list-providers to check current models. On-chain model names use org/model-name format.

Prerequisites

node --version  # Must be >= 22.0.0
pnpm add @0glabs/0g-serving-broker        # SDK for applications
pnpm add @0glabs/0g-serving-broker -g     # CLI for direct usage

Quick Setup

0g-compute-cli setup-network              # Choose testnet or mainnet
0g-compute-cli login                       # Login with wallet private key
0g-compute-cli deposit --amount 10         # Deposit funds
0g-compute-cli get-account                 # Check balance

Inference (SDK)

import { ethers } from "ethers";
import { createZGComputeNetworkBroker } from "@0glabs/0g-serving-broker";

const RPC_URL = process.env.NODE_ENV === 'production'
  ? "https://evmrpc.0g.ai"
  : "https://evmrpc-testnet.0g.ai";

const provider = new ethers.JsonRpcProvider(RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
const broker = await createZGComputeNetworkBroker(wallet);

// Discover services
const services = await broker.inference.listService();
services.forEach(s => {
  console.log(`${s.provider} | ${s.model} | ${s.serviceType}`);
});

// Make inference request
const { endpoint, model } = await broker.inference.getServiceMetadata(providerAddress);
const headers = await broker.inference.getRequestHeaders(providerAddress);

const response = await fetch(`${endpoint}/chat/completions`, {
  method: "POST",
  headers: { "Content-Type": "application/json", ...headers },
  body: JSON.stringify({ messages, model })
});

const data = await response.json();

// Extract chatID (see chatID table below)
let chatID = response.headers.get("ZG-Res-Key") || response.headers.get("zg-res-key");
if (!chatID) chatID = data.id;

// CRITICAL: Always call processResponse
await broker.inference.processResponse(
  providerAddress,              // 1st: provider address
  chatID,                       // 2nd: response identifier for verification
  JSON.stringify(data.usage)    // 3rd: usage data for fee calculation
);

For streaming, browser SDK, cURL, and Python examples, see references/inference.md.

processResponse (CRITICAL)

Call broker.inference.processResponse() after EVERY API response for fee settlement and TEE verification.

await broker.inference.processResponse(
  providerAddress,              // 1st: provider address
  chatID,                       // 2nd: response identifier for verification
  JSON.stringify(data.usage)    // 3rd: usage data for fee calculation
);

Parameter order: provider, chatID, usageData. Do NOT reorder.

chatID Retrieval by Service Type

Always try ZG-Res-Key response header first. Use fallback only when header is absent.

| Service Type | chatID Source | Fallback |

|---|---|---|

| Chatbot | ZG-Res-Key header | data.id from response body |

| Text-to-Image | ZG-Res-Key header | none |

| Speech-to-Text | ZG-Res-Key header | none |

| Chatbot Streaming | ZG-Res-Key header | id from stream chunk |

| Audio Streaming | ZG-Res-Key header | none |

Fine-tuning

Fine-tuning is available on both mainnet and testnet. It is a 6-step CLI process: list providers, upload dataset, calculate tokens, create task, monitor, download and decrypt.

For the complete workflow, see references/fine-tuning.md.

Account Management

The 0G Compute Network uses Main Accounts (deposits/withdrawals) and Provider Sub-Accounts (service payments). Sub-account refunds have a 24-hour lock period.

0g-compute-cli get-account                                    # Check balance
0g-compute-cli deposit --amount 10                             # Deposit to main
0g-compute-cli transfer-fund --provider <ADDR> --amount 5      # Transfer to sub-account
0g-compute-cli retrieve-fund                                   # Retrieve from sub (24h lock)
0g-compute-cli refund --amount 5                               # Withdraw to wallet

For detailed account management, see references/account-management.md.

CLI Quick Reference

# Inference
0g-compute-cli inference list-providers                        # List all providers
0g-compute-cli inference verify --provider <ADDR>              # Verify TEE attestation
0g-compute-cli inference acknowledge-provider --provider <ADDR> # Required before first use
0g-compute-cli inference get-secret --provider <ADDR>          # Get API key for direct calls
0g-compute-cli inference serve --provider <ADDR> --port 3000   # Local OpenAI-compatible proxy

# Fine-tuning
0g-compute-cli fine-tuning list-providers                      # List fine-tuning providers
0g-compute-cli fine-tuning list-models                         # List available models

# Web UI
0g-compute-cli ui start-web                                    # Launch at localhost:3090

Troubleshooting

| Problem | Solution |

|---|---|

| Insufficient balance | deposit --amount 5 then transfer-fund --provider <ADDR> --amount 2 |

| Provider not acknowledged | inference acknowledge-provider --provider <ADDR> |

| Provider busy (fine-tuning) | Wait and retry, or choose a different provider |

| Web UI port conflict | ui start-web --port 3091 |

Resources

> Note: A unified skill covering all 0G services (Compute, Storage, Chain) exists at 0g-agent-skills.

Other skills for the same job

different authors, same section of the catalogue
At Dispatch V2
by pytorch
vendor ×3

Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.

2k tokens
Docstring
by pytorch
vendor ×3

Write docstrings for PyTorch functions and methods following PyTorch conventions. Use when writing or updating docstrings in PyTorch code.

3k tokens
Statsmodels
by christophacham
×3

Statistical models library for Python. Use when you need specific model classes (OLS, GLM, mixed models, ARIMA) with detailed diagnostics, residuals, and inference. Best for econometrics, time series, rigorous inference with coefficient tables. For guided statistical test selection with APA reporting use statistical-analysis.

27k tokens
AI SDK
by vercel-labs
vendor ×2

Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

6k tokens
Create Llms
by github
vendor ×1

Create an llms.txt file from scratch based on repository structure following the llms.txt specification at https://llmstxt.org/

2k tokens
Esm
by K-Dense-AI
×1

Use when working directly with the `esm` Python SDK, ESM3 or ESMC model IDs, Forge/Biohub inference clients, or ESMFold2 folding workflows.

21k tokens
Modal
by K-Dense-AI
×1

Modal is a serverless cloud platform for running Python on demand, including on-demand GPUs. Use when deploying or serving AI/ML models, running GPU-accelerated workloads (training, fine-tuning, inference), serving web endpoints, scheduling batch jobs, or scaling Python code to cloud containers with the Modal SDK.

19k tokens
Pytdc
by K-Dense-AI
×1

Use Therapeutics Data Commons through the PyTDC Python package for registry discovery, approved dataset access, task-aware splits, evaluator metrics, benchmark groups, and bounded molecular-oracle workflows.

27k tokens scripts

How to use it

Copy the folder

Take internet-court/0g-compute from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.

Install what it needs

The instructions reference pnpm. Without those the skill loads but fails at the first command.