How to use Aider through one API
Aider is one of the best terminal-based AI pair programmers around. It edits files directly in your repo, makes git commits for you, and works with whatever model you point it at. The catch: juggling a separate account, billing page, and API key for OpenAI, Anthropic, Google, and the rest gets old fast. This guide shows how to run Aider against every major model through a single endpoint and one key.
Why one API for Aider
Aider speaks the OpenAI Chat Completions format natively, which makes it a clean fit for an OpenAI-compatible gateway. With AnyModel you get:
- One base URL —
https://anymodel.org/v1 - One API key that reaches GPT, Claude, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok
- Model switching by id only — change the
modelstring, nothing else in your config
That last point matters a lot for Aider. Picking the right model per task — a cheap one for boilerplate, a frontier one for tricky refactors — usually means re-plumbing credentials. Here it's a one-word edit.
Step 1: Get a key
Sign up and grab an API key. You start with 1,000,000 free tokens, and linking Telegram bumps your total to 6,000,000 — no credit card required. After the free tokens, it's pay-per-token with no subscription and no minimums, so an occasional Aider session costs only what it uses.
Step 2: Point Aider at the gateway
Aider isn't one of the auto-install tools (the bash <(curl ...) one-liner only covers codex, claude, opencode, and hermes). For Aider you use the standard OpenAI-compatible setup: set the base URL and key as environment variables, then pass any model id with the openai/ prefix.
export OPENAI_API_BASE="https://anymodel.org/v1"
export OPENAI_API_KEY="<YOUR_API_KEY>"
## Use Claude for a refactor
aider --model openai/claude-sonnet-4-5
## Or GPT for the next session — only the id changes
aider --model openai/gpt-5
Aider treats the gateway like the OpenAI API, so the openai/ prefix tells it which provider format to use; the actual routing to Claude, Gemini, or DeepSeek happens on the gateway side based on the model id.
Step 3: Make it stick
Typing flags every time is tedious. Drop your defaults into .aider.conf.yml in your home directory or project root:
openai-api-base: https://anymodel.org/v1
model: openai/gpt-5
Now aider just works, and you override the model with --model openai/<id> whenever a task calls for something else.
Choosing a model per task
A practical rotation for day-to-day Aider work:
| Task | Good pick |
|---|---|
| Large refactors, architecture | Claude or GPT frontier models |
| Fast edits, scaffolding | DeepSeek, Qwen, GLM |
| Long-context reading | Gemini, Kimi |
Because billing is unified, mixing providers in one afternoon doesn't fragment your spend across four invoices — it's one token counter. If you're weighing trade-offs, the model comparison page lays out strengths and pricing side by side.
A note on privacy
By default, prompts pass through the gateway like any proxy. If your repo contains sensitive code, enable Ghost Mode — opt-in, zero-retention keys where prompts and responses aren't stored on our side, only a token counter. Be realistic about what that means: the underlying model provider still receives your prompt to generate a response. Ghost Mode removes our retention, not theirs, so it's not "100% privacy" — but it does keep your code off our servers.
Troubleshooting
- 404 or model-not-found: check the
modelid matches one on the models list and that you kept theopenai/prefix. - Auth errors: confirm
OPENAI_API_BASEends in/v1and the key is the full string. - Weird formatting in diffs: some models follow Aider's edit format better than others — try a frontier model if a smaller one struggles with whole-file edits.
Wrap-up
Aider plus a single OpenAI-compatible gateway turns model choice into a one-word decision and collapses four billing relationships into one. Set the base URL once, keep your key handy, and swap models as the work demands. For more setup guides and tips, browse the blog.
Ready to try it? Create a free account and get a million tokens to point Aider at.
AnyModel