0g-compute
What it does
This guide shows the agent how to use the 0G Compute Network, a marketplace of shared GPU computers for running and fine-tuning AI models. It includes setup steps, code patterns to copy, and the command-line tool.
When to use it
- ✓When you want to add an AI chatbot or image tool that runs on the 0G network.
- ✓When you need to call 0G inference from code or from the command line.
- ✓When you want to start on the testnet before using the main network.
Skill link
https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“I want a simple chatbot that runs on 0G Compute.”
5 new skills a week. 1 minute to read.
How it works
The skill gives the agent code patterns to copy rather than guessing. They cover connecting to the network, sending requests, checking which models are available, and handling each response. The skill also says to keep private keys in environment variables.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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 pro
FAQ
Which network should I start with?
The skill recommends the testnet for first development, and the mainnet for real use.
Why must the agent call processResponse after each reply?
The skill makes this a rule for every response, so the agent should never skip it.
How does the agent know which AI models are available?
It checks the current list on the network, because available models change often.
Details
Original description by the author
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.
Popularity
- GitHub stars
- 7.0k
- Ranking position
- #13601
- License
- —
- Updated
- 10/26/2026
Comments
- …
More skills from this repository
internet-court
7.0kHelps your agent pay, hire, or deal safely with another AI agent or paid service, and points it to the right specialized guide.
genlayer-erc7710-connector
7.0kHelps your agent connect an AI review result to a permission system, so a bad review can limit or cancel an agent's permissions.
genlayer-intelligent-contracts
7.0kHelps your agent define the rules, evidence and outputs of an AI judge that checks whether another agent followed its mandate.
x402-erc7710
7.0kHelps your agent pay for web services one request at a time, and set up ongoing spending that stays within a permission budget.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.