Aider with AI Gateway
Aider is an open-source, terminal-based AI pair programming tool that edits code in your local git repository. You can configure it to use AI Gateway for unified model access and spend monitoring.
Run the Vercel CLI setup command for Aider:
npx vercel ai-gateway setup --agent aiderThe command writes the gateway base URL and a default model into ~/.aider.conf.yml, registers the gateway's models in .aider.model.metadata.json and .aider.model.settings.yml so Aider knows their context windows, and exports AIDER_OPENAI_API_KEY from a managed block in your shell startup file. Re-run it to refresh the model registrations.
If you can't use the Vercel CLI, configure Aider manually:
Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
Aider reads its OpenAI-compatible key from
AIDER_OPENAI_API_KEY. Export it in your shell:Terminalexport AIDER_OPENAI_API_KEY="your-ai-gateway-api-key"To persist the key, add the same line to your shell's startup file.
Add the gateway base URL and a default model to
~/.aider.conf.yml:~/.aider.conf.ymlopenai-api-base: https://ai-gateway.vercel.sh/coding-agent/v1 model: openai/openai/gpt-6-astraThe
openai/prefix is what routes the model ID throughopenai-api-base, so the model value isopenai/followed by the gateway'screator/model-nameslug.openai/openai/gpt-6-astrameans the gateway modelopenai/gpt-6-astra.Aider has no built-in catalog entries for prefixed IDs, so it falls back to small default context windows. Register the gateway's models in
.aider.model.metadata.jsonnext to your config file:~/.aider.model.metadata.json{ "openai/openai/gpt-6-astra": { "max_input_tokens": 1050000, "litellm_provider": "openai", "mode": "chat" } }Then set the diff edit format in
.aider.model.settings.yml:~/.aider.model.settings.yml- name: openai/openai/gpt-6-astra edit_format: diff use_repo_map: trueThe Vercel CLI generates both files from the gateway's live catalog, including context windows and per-token pricing, and drops models without size data.
- Terminal
aiderSwitch models with
/modelin a session or on the command line:Terminalaider --model openai/anthropic/claude-sonnet-5
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 |
|---|---|
AIDER_OPENAI_API_KEY | Your AI Gateway API key. Required |
OPENAI_API_BASE | Not used. Aider takes the base URL from openai-api-base in ~/.aider.conf.yml |
- Browse the models catalog for available models
- Configure spend limits on your API key
- Read the Aider documentation for editor and git workflow options
Was this helpful?