Compute

Decentralized AI inference, priced for builders.

Call open models over a decentralized GPU marketplace. Open provider bidding sets the price, you pay per request, and settlement happens on chain.

§ 01 · Start here: Private Computer

Primary path

Private Computer is the fastest way onto 0G Compute. One API key gets you the whole model catalog: chat, image, speech, and embeddings, through an OpenAI-compatible endpoint, so you change a base URL and keep your existing SDK. Open provider bidding sets the price, and there are no platform or top-up fees. Every request is verifiably routed, and you can dial privacy up per request when the workload needs it.

Get an API key

§ 02 · Advanced: wallet auth with the broker

Prefer wallet-based auth inside your app instead of a hosted API key? Talk to the 0G Compute broker directly. You hold the key, you pick the provider, and every request settles on chain from your own ledger.

Reference implementation

Start from the Compute TypeScript Starter Kit

End-to-end example showing account setup, provider acknowledgement, and inference calls. Clone, set a private key, and run.

Clone starter kit

Follow the 5 steps below to wire it up yourself.

The deposit in step 02 spends a real balance, and step 03 needs compute credit. If you have neither, start at Get funded.

01

Install the CLI and OpenAI SDK

bash
# Node 20+ required
pnpm add @0gfoundation/0g-compute-ts-sdk -g
npm install openai
02

Provision an account

bash
# set PRIVATE_KEY in your shell env first (testnet wallet funded via faucet.0g.ai)
0g-compute-cli setup-network
0g-compute-cli login
0g-compute-cli deposit --amount 3 # 3 OG minimum to create the ledger
0g-compute-cli inference list-providers # note a provider address to use
03

Transfer funds and generate an API key

bash
# copy a provider address from the list-providers output in step 02
export PROVIDER=<address-from-list-providers>
0g-compute-cli transfer-fund --provider $PROVIDER --amount 1
0g-compute-cli inference acknowledge-provider --provider $PROVIDER
0g-compute-cli inference get-secret --provider $PROVIDER
# prints an app-sk-... secret and the service URL, copy both
04

Call a model with the OpenAI SDK

ts
import OpenAI from 'openai'
const client = new OpenAI({
baseURL: `${process.env.ZG_SERVICE_URL}/v1/proxy`,
apiKey: process.env.ZG_API_SECRET, // the app-sk-... from step 03
})
const completion = await client.chat.completions.create({
model: '0GM-1.0-35B-A3B', // or any model listed on pc.0g.ai/models
messages: [{ role: 'user', content: 'Hello, frontier.' }],
})
console.log(completion.choices[0].message.content)
05

Check your balance

bash
0g-compute-cli get-account
# or view the dashboard at pc.0g.ai

CLI or SDK

The CLI wraps the broker SDK. To do the same from inside your app:

import { ethers } from 'ethers'
import { createZGComputeNetworkBroker } from '@0gfoundation/0g-compute-ts-sdk'
const provider = new ethers.JsonRpcProvider('https://evmrpc-testnet.0g.ai')
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider)
const broker = await createZGComputeNetworkBroker(wallet)
const { endpoint, model } = await broker.inference.getServiceMetadata(PROVIDER_ADDRESS)
const headers = await broker.inference.getRequestHeaders(PROVIDER_ADDRESS)
const res = await fetch(`${endpoint}/chat/completions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...headers },
body: JSON.stringify({ model, messages: [{ role: 'user', content: 'Hello!' }] }),
})

Settlement transactions and provider activity are visible on Chain Scan.

§ 03 · Trust modes

Not every task needs the same guarantee. Standard is the default and has the widest coverage, so step up only when the workload calls for it.

Standard

Default
What it gives you

Widest coverage: every model and provider including community channels. Routing is not attested.

Use when

Everyday tasks, best price and availability

Verified

What it gives you

Routing restricted to attested providers. You get a signed proof that the model you called is the model that ran, no silent substitution.

Use when

You need provenance

Private

What it gives you

TEE-isolated execution path. Neither 0G nor the provider sees the prompt.

Use when

Sensitive data

How to set it

Per request

Send a header with the call. It overrides the key default for that request only.

X-0G-Provider-Trust-Mode: verified|private

Per key default

Set a default for a whole key in the PC Dashboard: API Key, then Edit.

What the attestation actually proves

TeeML

What it proves

The model runs inside the enclave. Hardware baseline is an Intel TDX CPU plus an NVIDIA H100/H200 with TEE support. The prompt enters the enclave encrypted, the output is signed inside the enclave before it leaves, and the host machine only ever sees encrypted traffic.

Qualifies for

Verified and Private

TeeTLS

What it proves

The routing path, not the execution. A Broker running inside a TEE proxies the request to the provider over HTTPS, pins the provider's TLS certificate during the handshake, then signs a routing proof bundling the cert fingerprint, request hash, response hash and provider identity. Conceptually close to zkTLS with stronger privacy, since the TEE guarantees the relay itself is trustworthy.

Qualifies for

Verified only: inference still happens at the upstream provider, which can see the prompt

SPML

What it proves

For open-source models that are neither self-hosted in a 0G enclave nor served from a closed-source official channel: verifies the provider's GPU and model deployment.

Qualifies for

Verified

Fine print

  • Most models are not running inside a TEE. Only a minority of providers are TeeML; most are TeeTLS, which attests the routing path and not the execution.
  • Standard is not the absence of a guarantee. If a model is served only by TeeML providers, your requests run inside an enclave whichever mode you pick.

§ 04 · Compute SDKs

§ 05 · Deep dive

§ 06 · Tutorials

§ 07 · Built with Compute

View showcase →