0g-compute
Skill này làm gì
Hướng dẫn này chỉ cho agent cách dùng 0G Compute Network, một thị trường các máy GPU dùng chung để chạy và tinh chỉnh mô hình AI. Nó gồm các bước thiết lập, mẫu mã để sao chép và công cụ dòng lệnh.
Khi nào nên dùng
- ✓Khi bạn muốn thêm một chatbot AI hoặc công cụ hình ảnh chạy trên mạng 0G.
- ✓Khi bạn cần gọi suy luận 0G từ mã hoặc từ dòng lệnh.
- ✓Khi bạn muốn bắt đầu trên testnet trước khi dùng mạng chính.
Liên kết skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tôi muốn một chatbot đơn giản chạy trên 0G Compute.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill cung cấp cho agent các mẫu mã để sao chép thay vì phải đoán. Chúng bao gồm kết nối với mạng, gửi yêu cầu, kiểm tra mô hình nào đang có sẵn và xử lý từng phản hồi. Skill cũng yêu cầu giữ khóa riêng trong biến môi trường.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Nên bắt đầu với mạng nào?
Skill khuyên dùng testnet để phát triển ban đầu, và mainnet để sử dụng thật.
Vì sao agent phải gọi processResponse sau mỗi phản hồi?
Skill đặt đây thành quy tắc cho mọi phản hồi, nên agent không bao giờ được bỏ qua.
Agent biết mô hình AI nào đang có sẵn bằng cách nào?
Nó kiểm tra danh sách hiện tại trên mạng, vì các mô hình có sẵn thay đổi thường xuyên.
Chi tiết
Mô tả gốc của tác giả
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.
Độ phổ biến
- Sao GitHub
- 7.0k
- Vị trí xếp hạng
- #13601
- Giấy phép
- —
- Cập nhật
- 26/10/2026
Bình luận
- …
Thêm skill từ kho mã này
internet-court
7.0kGiúp agent của bạn thanh toán, thuê hoặc giao dịch an toàn với một agent AI khác hoặc dịch vụ trả phí, và chỉ đến hướng dẫn chuyên sâu phù hợp.
genlayer-erc7710-connector
7.0kGiúp agent của bạn kết nối kết quả đánh giá AI với hệ thống quyền hạn, để một đánh giá xấu có thể hạn chế hoặc hủy quyền của agent.
genlayer-intelligent-contracts
7.0kGiúp agent của bạn xác định quy tắc, bằng chứng và đầu ra của một AI judge kiểm tra xem agent khác có làm đúng nhiệm vụ được ủy quyền hay không.
x402-erc7710
7.0kGiúp agent của bạn trả tiền cho dịch vụ web theo từng yêu cầu, và thiết lập chi tiêu định kỳ nằm trong ngân sách quyền hạn.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.