Skip to content

06.3 · Guide

Integrate compute

Private Computer for an API key, or the broker CLI when the app holds a wallet.

01

Two ways in

Private Computer is the short path. Create a key at pc.0g.ai, point an OpenAI SDK at the base URL the dashboard gives you, and pay per request from compute credit. The model list, with prices and which trust modes each model supports, is pc.0g.ai/models.

The broker path is for an app that signs with a wallet. The CLI wraps that flow: setup-network, login, deposit, list providers, then a per-provider secret. Node 20 or newer is required. The first deposit that creates the ledger is documented as 3 0G.

Credit is not gas

Faucet 0G on Galileo pays transactions. Compute credit pays GPU providers. get-account reads credit. cast balance reads gas.
02

Call with an API key

router-api.0g.ai/v1 is the OpenAI-compatible base URL published for 0G hacker machines. If Private Computer shows a different base URL, use that one. The model name below is a real catalog id. Confirm it still exists before you bake it into a product.

Trust mode is a header, not a model name. standard is the default and has the widest coverage. verified restricts routing to attested providers and returns a proof that the route was the route you asked for. private is the TEE-isolated path, for prompts the provider should not see. Most models are not running inside a TEE. TeeTLS attests the route. TeeML attests execution. Do not describe every request as enclave execution.

TypeScript · OpenAI SDK
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: process.env.ZG_COMPUTE_URL ?? "https://router-api.0g.ai/v1",
  apiKey: process.env.ZG_API_KEY,
});

const completion = await client.chat.completions.create(
  {
    model: "0GM-1.0-35B-A3B",
    messages: [{ role: "user", content: "Say hello from 0G." }],
  },
  { headers: { "X-0G-Provider-Trust-Mode": "standard" } },
);

console.log(completion.choices[0]?.message?.content);
03

Broker CLI, when the wallet pays

Install is in the toolchain guide. The commands themselves are the same in zsh, bash, and PowerShell. login will ask the wallet flow the CLI documents. Keep the key out of the shell history.

Create the ledger and list providers
0g-compute-cli setup-network
0g-compute-cli login
0g-compute-cli deposit --amount 3
0g-compute-cli get-account
0g-compute-cli inference list-providers
  • Copy one provider address from list-providers. The hub’s next steps are transfer-fund, inference acknowledge-provider, and inference get-secret. get-secret prints an app-sk secret and a service URL.
  • Call that service at the service URL from get-secret, plus /v1/proxy, using the app-sk value as the API key.
  • A 401 means the key or the secret does not match the base URL. A balance error from get-account means the ledger was never deposited, or the CLI is on a different network than the tokens.