页面简介
Connect Aider to AI Gateway with the Vercel CLI or an OpenAI-compatible base URL, API key, and model metadata.
正文摘录
Copy pageCopy pageAider with AI GatewayCopy pageCopy pageAider 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. Set up with the Vercel CLI Run the Vercel CLI setup command for Aider: terminalnpx vercel@latest ai-gateway setup --agent aider The 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. Configuring Aider If you can't use the Vercel CLI, configure Aider manually: Create an API keyGo to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.Export the keyAider 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.Point Aider at the gatewayAdd 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 through openai-api-base, so the model value is openai/ followed by the gateway's creator/model-name slug. openai/openai/gpt-6-astra means the gateway model openai/gpt-6-astra.Register model metadataAider 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.json next 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.Start AiderTerminalaiderSwitch models with /model in a session or on the command line:Terminalaider --model openai/anthropic/claude-sonnet-5 Monitor usage and spend View your usage, spend, and request activity in the AI Gateway section in the Vercel dashboard sidebar. See the observability documentation for more details. Environment variables VariableDescriptionAIDER_OPENAI_API_KEYYour AI Gateway API key. RequiredOPENAI_API_BASENot used. Aider takes the base URL from openai-api-base in ~/.aider.conf.yml Aider calls AI Gateway through the OpenAI-compatible Chat Completions API, so any model that supports Chat Completions works. Next steps Browse the models catalog for available models Configure spend limits on your API key Read the Aider documentation for editor and git workflow options Last updated October 16, 2026PreviousCoding AgentsNextAmpWas this helpful?