跳到正文
Skillpedia
API 与服务器(后端)7.0k · #13601

0g-compute

它能做什么

本指南向智能体展示如何使用 0G Compute Network,这是一个共享 GPU 计算机的市场,用于运行和微调 AI 模型。它包括设置步骤、可直接复制的代码模式,以及命令行工具。

适用场景

  • ✓当你希望添加在 0G 网络上运行的 AI 聊天机器人或图像工具的时候。
  • ✓当你需要在代码中或命令行中调用 0G 推理时。
  • ✓当你想在使用主网之前先在测试网上开始的时候。

技能链接

https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/internet-court/internet-court-skill/blob/main/vendored/0g/0g-compute/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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

  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

常见问题

应该从哪个网络开始?

该技能建议首次开发使用测试网,实际使用则用主网。

为什么智能体每次收到回复后都必须调用 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.

repo: internet-court/internet-court-skill

热度

GitHub 星标
7.0k
排名
#13601
许可证
—
更新时间
2026/10/26

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能