Skip to content
Docs

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:

terminal
npx vercel 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.

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

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

  2. Aider reads its OpenAI-compatible key from AIDER_OPENAI_API_KEY. Export it in your shell:

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

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

  3. Add the gateway base URL and a default model to ~/.aider.conf.yml:

    ~/.aider.conf.yml
    openai-api-base: https://ai-gateway.vercel.sh/coding-agent/v1
    model: openai/openai/gpt-6-astra

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

  4. 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.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: true

    The Vercel CLI generates both files from the gateway's live catalog, including context windows and per-token pricing, and drops models without size data.

  5. Terminal
    aider

    Switch models with /model in a session or on the command line:

    Terminal
    aider --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.

VariableDescription
AIDER_OPENAI_API_KEYYour AI Gateway API key. Required
OPENAI_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.

Last updated September 13, 2026

Was this helpful?

supported.