Skip to content
Docs

ZCode with AI Gateway

ZCode is Z.ai's desktop agent development environment. Its custom providers speak the OpenAI-compatible Chat Completions format, which you can point at AI Gateway for unified model access and spend monitoring.

Quit ZCode, then run the Vercel CLI setup command:

terminal
npx vercel ai-gateway setup --agent zcode

The command writes a gateway provider and a seeded model list into ~/.zcode/v2/config.json with 0600 permissions. Re-run it to refresh the model list.

If you can't use the Vercel CLI, configure ZCode manually:

  1. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  2. Quit the ZCode desktop app before editing its config. ZCode keeps its provider registry in memory and rewrites ~/.zcode/v2/config.json when it saves settings or exits, silently discarding edits made while it runs.

  3. Add the provider to ~/.zcode/v2/config.json under provider, with the API format on Chat completions:

    ~/.zcode/v2/config.json
    {
      "provider": {
        "vercel-ai-gateway": {
          "name": "Vercel AI Gateway",
          "kind": "openai-compatible",
          "options": {
            "apiKey": "your-ai-gateway-api-key",
            "baseURL": "https://ai-gateway.vercel.sh/coding-agent/v1",
            "apiKeyRequired": true
          },
          "source": "custom",
          "models": {
            "openai/gpt-6-astra": {
              "limit": { "context": 1000000, "output": 128000 }
            }
          }
        }
      }
    }

    ZCode has no environment-variable lookup for custom providers, so the key is stored in this file. Create it with mode 0600.

  4. Open ZCode and pick a model under Vercel AI Gateway in the chat's model picker. Add more gateway models with Manage models > Add model.

    On a fresh install, choose Skip for now on ZCode's welcome screen. Its API-key dropdown only takes Z.ai/BigModel accounts, and the gateway provider lives in Settings > Model settings.

View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details.

The API key is stored in ~/.zcode/v2/config.json. Keep the file mode at 0600.

Keep the API format on Chat completions. ZCode's Anthropic-messages format sends a legacy thinking parameter that current Claude models reject.

Last updated September 13, 2026

Was this helpful?

supported.