Skip to content
Skillpedia
APIs & servers (backend)7.0k · #13601

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.md

Copy 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

Use this skill to help me: https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

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

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

When unsure about a pattern, reference the detailed guides:

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.

repo: internet-court/internet-court-skill

Popularity

GitHub stars
7.0k
Ranking position
#13601
License
—
Updated
10/26/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills