Skip to content

Use 0G with coding agents

Any agent or editor that lets you configure a custom OpenAI-compatible endpoint can run against the Router. There is no 0G-specific plugin to install — the tool sends the same request bodies it already sends, to a different host.

Setting Value
Base URL https://router-api.0g.ai/v1
API key An sk- key, injected from ZG_API_KEY
Model An ID from GET /v1/models

The catalog endpoint is public and needs no authentication, so you can list valid identifiers before configuring anything:

Terminal window
curl https://router-api.0g.ai/v1/models

See the model catalog for what each field means.

Many tools read the standard OpenAI environment variables rather than exposing settings of their own. Where that is the case, exporting them in the shell that launches the agent is the whole configuration:

Terminal window
export OPENAI_BASE_URL="https://router-api.0g.ai/v1"
export OPENAI_API_KEY="$ZG_API_KEY"

Other tools use their own configuration file or settings pane, with names that differ from tool to tool — base URL may appear as an endpoint, host, or provider URL. Consult the tool’s own documentation for the exact key; the values above do not change.

Config key names differ between tools — some read OPENAI_BASE_URL, others want the URL in a settings file, a few insist on a provider dropdown. The rule that does not change: whatever field takes an OpenAI-compatible endpoint takes this one. If a tool refuses the URL, the usual cause is a trailing path difference, so try with and without /v1.

Coding agents lean on tool calling, so the first filter is whether a model supports it. Check the capability fields returned by GET /v1/models for the models you are considering rather than assuming — the catalog is the authority, and it changes.

Capability lives in supported_parameters on each catalog entry. A model usable for agent work lists both tools and tool_choice:

Terminal window
curl -s https://router-api.0g.ai/v1/models \
| jq '.data[] | select(.supported_parameters | index("tools")) | .id'

Verified 2026-07-20: 19 of the 22 models list tools, so tool calling is the norm rather than the exception here. The three that do not are the image and speech models and one chat model. Filter rather than assume, since the catalog changes.

Two further constraints are worth applying before you settle:

  • Context length. Agents send large diffs and file contents. A model that fits your repository’s typical working set matters more than raw benchmark quality.
  • Trust tier. The verifiability field states which trust technology backs a model, and that determines which trust modes it can serve. If the agent will handle code you cannot expose, this decides the shortlist.

The Console’s Models page lists the same catalog with current pricing alongside each entry.

Agent configuration lives in dotfiles and project settings, and those get committed. A key pasted into a tracked config file is a key published to everyone with repository access — and whoever holds an sk- key can spend the balance behind it.

  • Inject the key from the environment, or use the tool’s own secret storage where it has one.
  • Keep agent configuration files out of version control, or reference an environment variable from them rather than the literal secret.
  • Use a separate key per machine or per agent, so revoking one does not interrupt anything else.

Revocation takes effect immediately; subsequent requests fail with 401 invalid_api_key. See API keys for creation, scoping, and rotation.

An agent reads source before it writes any, so every prompt it sends carries code you may not want leaving your control. The private trust mode routes only to providers where the model runs inside the enclave, so prompts are never exposed in plaintext.

The reliable way to enforce this for an agent is at the key, not the request. A trust mode set on the API key applies to every request made with it and cannot be overridden by whatever the tool puts in its own requests — which matters when you do not control the code that builds them. Per-request headers work too, but only if the tool lets you set custom headers at all, and many do not.

See trust modes for what each tier guarantees, and private mode for the working setup.

The same rule covers LangChain, LlamaIndex, the Vercel AI SDK, LiteLLM, and anything else that wraps an OpenAI-compatible client: set the base URL and the key on the underlying client, and the wrapper works untouched. Two things to know before you rely on one:

  • Wrappers usually drop x_0g_trace. They parse the fields they know about, so per-request cost and the provider address disappear. If you need either, use the framework’s raw-response escape hatch or call the endpoint directly. See Track what each request costs.
  • Routing headers go in the client’s default-headers option, not in the per-call arguments, in most wrappers. That also makes them easy to forget on one code path, which is the argument for enforcing a trust mode on the key instead. See Trust modes.

Exact option names differ by library and version; treat each library’s own documentation as authoritative.

  • Private mode — enforce enclave-only execution end to end.
  • API keys — create scoped keys and rotate them.