Skip to content
Docs

ForgeCode with AI Gateway

ForgeCode is a terminal coding agent. It supports custom OpenAI-compatible providers, which you can point at AI Gateway for unified model access and spend monitoring.

Run the Vercel CLI setup command for ForgeCode:

terminal
npx vercel ai-gateway setup --agent forge

The command writes a gateway [[providers]] entry and [session] defaults into ~/.forge/.forge.toml. It stores the key in the sibling .credentials.json with 0600 permissions, which is the only key source Forge 2.13 and later read. Re-run it to refresh the defaults.

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

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

  2. Add a [[providers]] entry to ~/.forge/.forge.toml:

    ~/.forge/.forge.toml
    [[providers]]
    id = "vercel-ai-gateway"
    url = "https://ai-gateway.vercel.sh/coding-agent/v1/chat/completions"
    models = "https://ai-gateway.vercel.sh/coding-agent/v1/models"
    api_key_vars = "AI_GATEWAY_API_KEY"
    response_type = "OpenAI"
    auth_methods = ["api_key"]
     
    [session]
    provider_id = "vercel-ai-gateway"
    model_id = "openai/gpt-6-astra"
  3. Forge 2.13 and later resolve keys only from ~/.forge/.credentials.json, not the environment. Add the key to the JSON array with mode 0600:

    ~/.forge/.credentials.json
    [
      {
        "provider_id": "vercel-ai-gateway",
        "auth_details": {
          "api_key": "your-ai-gateway-api-key"
        }
      }
    ]
    Terminal
    chmod 0600 ~/.forge/.credentials.json

    Older Forge releases read the key from AI_GATEWAY_API_KEY in the environment instead, which is why the provider also declares api_key_vars.

  4. Terminal
    forge

    Switch models in-session with :config-model. The picker fills from the gateway's /models endpoint, so the full catalog is available.

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

VariableDescription
AI_GATEWAY_API_KEYYour AI Gateway API key. Used by Forge releases older than 2.13; newer releases read .credentials.json

ForgeCode calls AI Gateway through the OpenAI-compatible Chat Completions API, so any model that supports Chat Completions works.

Last updated September 13, 2026

Was this helpful?

supported.