Skip to content
Docs

Goose with AI Gateway

Goose is Block's open-source, terminal-based AI 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 Goose:

terminal
npx vercel ai-gateway setup --agent goose

The command writes a declarative provider JSON into ~/.config/goose/custom_providers/ that shadows Goose's built-in vercel_ai_gateway definition, sets the default provider and model in config.yaml, and records context sizes for the top gateway models from the gateway catalog. Re-run it to refresh the context sizes.

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

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

  2. Goose resolves the provider key from an environment variable. Export it in your shell:

    Terminal
    export AI_GATEWAY_API_KEY="your-ai-gateway-api-key"

    To persist the key, add the same line to your shell's startup file.

  3. Create ~/.config/goose/custom_providers/vercel_ai_gateway.json:

    ~/.config/goose/custom_providers/vercel_ai_gateway.json
    {
      "name": "vercel_ai_gateway",
      "engine": "openai",
      "display_name": "Vercel AI Gateway",
      "api_key_env": "AI_GATEWAY_API_KEY",
      "base_url": "https://ai-gateway.vercel.sh/coding-agent/v1/chat/completions",
      "models": [
        { "name": "openai/gpt-6-astra", "context_limit": 1050000 }
      ]
    }

    This file shadows Goose's built-in vercel_ai_gateway definition and repoints it at the gateway. The models array only supplies context sizes. Goose still discovers the rest of the catalog from the API, so list a few models and let discovery fill in the rest. Never set dynamic_models: false, which would reduce Goose to exactly this array.

  4. Set the default provider and model in ~/.config/goose/config.yaml:

    ~/.config/goose/config.yaml
    GOOSE_PROVIDER: vercel_ai_gateway
    GOOSE_MODEL: openai/gpt-6-astra
  5. Open a new terminal so the key is loaded, then run:

    Terminal
    goose

    Switch models with GOOSE_MODEL in config.yaml or goose configure. The picker fills from the gateway catalog.

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, named by api_key_env. Required

Goose 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.