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:
npx vercel ai-gateway setup --agent gooseThe 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:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Goose resolves the provider key from an environment variable. Export it in your shell:
Terminalexport AI_GATEWAY_API_KEY="your-ai-gateway-api-key"To persist the key, add the same line to your shell's startup file.
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_gatewaydefinition and repoints it at the gateway. Themodelsarray 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 setdynamic_models: false, which would reduce Goose to exactly this array.Set the default provider and model in
~/.config/goose/config.yaml:~/.config/goose/config.yamlGOOSE_PROVIDER: vercel_ai_gateway GOOSE_MODEL: openai/gpt-6-astraOpen a new terminal so the key is loaded, then run:
TerminalgooseSwitch models with
GOOSE_MODELinconfig.yamlorgoose 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.
| Variable | Description |
|---|---|
AI_GATEWAY_API_KEY | Your AI Gateway API key, named by api_key_env. Required |
- Browse the models catalog for available models
- Configure spend limits on your API key
- Read the Goose documentation for extensions and recipes
Was this helpful?