0g-compute
できること
このガイドは、AIモデルを実行し微調整するための共有GPUマシンのマーケットプレイスである0G Compute Networkの使い方をエージェントに示します。セットアップの手順、コピーして使えるコードパターン、コマンドラインツールを含みます。
使う場面
- ✓0Gネットワーク上で動くAIチャットボットや画像ツールを追加したいとき。
- ✓コードまたはコマンドラインから、0Gの推論を呼び出す必要があるとき。
- ✓メインネットを使う前に、テストネットで始めたいとき。
スキルのリンク
https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“0G Computeで動く簡単なチャットボットがほしいです。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、推測ではなくコピーして使えるコードパターンをエージェントに与えます。ネットワークへの接続、リクエストの送信、利用可能なモデルの確認、各応答の処理をカバーします。また、秘密鍵は環境変数に保存するよう定めています。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
最初はどのネットワークを使うべきですか?
最初の開発にはテストネットを、実際の利用にはメインネットを勧めています。
なぜ各応答の後にprocessResponseを呼ぶ必要があるのですか?
このスキルはこれをすべての応答に対する規則としているため、エージェントは省いてはいけません。
エージェントは利用可能なAIモデルをどう知りますか?
ネットワーク上の現在のリストを確認します。利用可能なモデルは頻繁に変わるためです。
詳細
作者による元の説明
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.
人気
- GitHubのスター
- 7.0k
- ランキング
- #13601
- ライセンス
- —
- 更新日
- 2026/10/26
コメント
- …
このリポジトリの他のスキル
internet-court
7.0kエージェントが、他のAIエージェントや有料サービスと安全に支払い、雇用、取引できるよう支援し、適切な専門ガイドを案内します。
genlayer-erc7710-connector
7.0kエージェントが、AIによるレビューの結果を権限の仕組みにつなぎ、悪いレビューがエージェントの権限を制限または取り消せるよう支援します。
genlayer-intelligent-contracts
7.0kエージェントが、別のエージェントが委任された範囲を守ったかを判定するAIの審査役について、ルール、証拠、出力を定義できるよう支援します。
x402-erc7710
7.0kエージェントが、リクエストごとにウェブサービスの支払いを行い、許可された予算の範囲内で継続的な支出を設定できるよう支援します。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。