Guide

Aider With an OpenAI-Compatible API: AtmoRouter Setup Guide

Set up Aider with an OpenAI-compatible API: point it at AtmoRouter, add model metadata so costs show correctly, and split architect, editor and weak models.

Using Aider with an OpenAI-compatible API is mostly a matter of three settings. Aider is one of the few terminal coding agents that assumes almost nothing about your provider: hand it an OpenAI-compatible base URL, a key and a model name, and it will read your repo, propose diffs and commit them. That makes it a natural fit for a gateway like AtmoRouter, where one key reaches the whole public catalogue and you can move a task between models without rewriting your shell history.

There is one rough edge worth knowing before you start. Aider ships metadata for models it recognises, and AtmoRouter's catalogue IDs are not in that list. Run against them and Aider warns that the model is unknown, treats the context window as unlimited, and reports the session as costing nothing. Setup still works, but the session cost line is fiction until you add a metadata file. Below: install, the metadata fix, the three-model split that keeps a long session cheap, prompt caching, and the errors you will actually hit. Prices quoted are the catalogue's "from" rates at writing time and the arithmetic is illustrative, not a benchmark.

Point Aider at an OpenAI-compatible endpoint

Install with Aider's own installer:

bashpython -m pip install aider-install
aider-install

Then set the base URL and key. Aider reads OPENAI_API_BASE and OPENAI_API_KEY, and the OpenAI base URL for AtmoRouter includes /v1:

bashexport OPENAI_API_BASE=https://atmorouter.dev/v1
export ATMOROUTER_API_KEY=ar-xxxxxxxxxxxx
export OPENAI_API_KEY="$ATMOROUTER_API_KEY"

On Windows, setx OPENAI_API_BASE https://atmorouter.dev/v1 and setx OPENAI_API_KEY ... work, but Aider's docs warn that setx does not affect the shell that ran it — restart the terminal before testing.

Start Aider inside the repo and prefix the catalogue ID with openai/, which is how Aider tells LiteLLM to use the OpenAI adapter rather than a vendor-specific one:

bashcd /path/to/your/project
aider --model openai/zai/glm-5.3

The doubled slash is expected. openai/ selects the adapter; zai/glm-5.3 is the catalogue ID the gateway routes on.

Teach Aider the prices, or believe $0.00

First run against an unfamiliar ID prints this:

textModel zai/glm-5.3: Unknown context window size and costs, using sane defaults.

Aider's warning docs are explicit about the consequence: it will use an unlimited context window and treat the model as costing nothing. Everything still streams, but the cost readout is zero and long conversations will not be summarised at the right point. Fix it with .aider.model.metadata.json, placed in the repo root, your home directory, or wherever --model-metadata-file points. Costs are per token, so divide the per-million rate by 1,000,000:

json{
  "openai/zai/glm-5.3": {
    "max_input_tokens": 1000000,
    "max_output_tokens": 128000,
    "input_cost_per_token": 0.0000000035,
    "output_cost_per_token": 0.000000011,
    "litellm_provider": "openai",
    "mode": "chat"
  },
  "openai/zai/glm-5.3-flash": {
    "max_input_tokens": 1000000,
    "max_output_tokens": 128000,
    "input_cost_per_token": 0.000000000375,
    "output_cost_per_token": 0.00000000125,
    "litellm_provider": "openai",
    "mode": "chat"
  }
}

The key must be the exact string you pass to --model, openai/ prefix included. The docs are blunt that it has to be fully qualified and match litellm_provider, which is why the prefix appears on both sides.

Here is the spread you are modelling, per million input/output tokens:

| Catalogue ID | From input | From output | Context | |---|---|---|---| | zai/glm-5.3 | $0.0035 | $0.011 | 1M | | zai/glm-5.3-flash | $0.000375 | $0.00125 | 1M | | alicn/deepseek-v4.1-flash | $0.000375 | $0.0015 | 1M | | kc/k3.1-pro | $0.05 | $0.25 | 1M | | cx/gpt-5.6-sol | $0.3375 | $2.025 | 272k | | mm/MiniMax-M3.1-Flash | $0.005625 | $0.0225 | 1M |

Those are 2026-11-10 rates. They refresh; the model page is authoritative.

Split the work across three models

Aider makes three kinds of calls and they have very different economics. The main chat does the reasoning and usually produces the most output tokens. The editor model, used in architect mode, converts prose into a diff. The weak model writes commit messages and summarises chat history — frequent, tiny, and cheap to get right. Put cheap models where output volume is high and judgement is low, in .aider.conf.yml (YAML keys are the flags minus their leading dashes):

yamlmodel: openai/kc/k3.1-pro
weak-model: openai/zai/glm-5.3-flash
editor-model: openai/zai/glm-5.3
edit-format: diff
auto-commits: true

A commit message is a few hundred input tokens and one line of output, and you pay for it on every edit. A flash-tier model at $0.000375 / $0.00125 per million is not measurably worse at writing "fix null check in parser" than a frontier model, so there is no reason to route that call upward.

Architect mode is where the split pays off

With --architect, the main model plans in prose and the editor model turns the plan into a diff. You can therefore spend on reasoning and save on mechanics:

bashaider --architect \
  --model openai/cx/gpt-5.6-sol \
  --editor-model openai/zai/glm-5.3 \
  --editor-edit-format editor-diff

Keep the editor model's max_output_tokens honest in the metadata file. Diffs are long, and a metadata entry that understates the ceiling is the difference between a completed edit and a truncated one.

Prompt caching, honestly described

Add --cache-prompts and Aider will try to cache the system prompt, files added read-only, the repo map and the editable files. It is provider-dependent: Aider's caching docs currently list Anthropic Sonnet/Haiku and DeepSeek Chat as caching providers, so treat it as upside that appears for some catalogue IDs rather than a guarantee across the board. Where it is supported, AtmoRouter bills cached input at 10% of the input rate. Two practical notes: cache statistics and costs are not reported while streaming, so add --no-stream if you want the numbers, and --cache-keepalive-pings N pings every five minutes up to N times to stop a warm cache from expiring mid-session.

Illustrative session math

A 50-turn session averaging 30,000 input and 600 output tokens per turn is 1.5M input and 0.03M output tokens. On kc/k3.1-pro at $0.05 / $0.25 that is $0.075 + $0.0075, roughly $0.08. On cx/gpt-5.6-sol at $0.3375 / $2.025 it is $0.506 + $0.061, roughly $0.57. Same repo, same diff, about seven times the bill.

Now assume half the input is cache hits at 10% of the input rate: 0.75M uncached at $0.05 plus 0.75M at $0.005 gives $0.0375 + $0.00375, so input drops to about $0.041 and the session lands near $0.05. These are arithmetic on catalogue rates with assumed token counts. They say nothing about response quality or latency, which you have to judge on your own tasks.

Troubleshooting the four usual failures

  • Unknown context window warning. Your metadata key does not match the --model string exactly, including the openai/ prefix.
  • 404 or model-not-found. Either the catalogue ID is misspelled or OPENAI_API_BASE is missing /v1.
  • Cost stuck at $0.00. Per-token costs are absent, or present under a key Aider never matches.
  • No cache figures. Streaming is on; add --no-stream, and check the model actually supports caching.

FAQ

Does Aider work with any OpenAI-compatible API?

Yes. Set OPENAI_API_BASE to the endpoint (for AtmoRouter, https://atmorouter.dev/v1), set OPENAI_API_KEY, and pass the model as openai/<catalogue-id>. The openai/ prefix tells Aider to use the generic OpenAI adapter.

Why does Aider say my session cost $0.00?

Aider only knows prices for models in its own metadata. For any other ID it assumes zero cost until you add an entry to .aider.model.metadata.json whose key matches your --model string exactly.

Which model should I use as the weak model?

A flash-tier model such as zai/glm-5.3-flash is usually enough for commit messages and chat summaries. Keep the stronger model for the main chat, and test the editor model on your own diffs before committing to it.

Does prompt caching work with every model?

No. --cache-prompts only helps where the model supports caching. Where it does, AtmoRouter bills cached input at 10% of the input rate; check the model page to confirm.

Next steps

If you would rather stay in an editor, the Cline guide and the Continue.dev guide cover the same gateway from VS Code, and the OpenRouter migration post covers moving keys across. AtmoRouter is prepaid with no seat fees and failed requests are never billed. Create a key on atmorouter.dev and check the live rates on each model page, which are always the number to budget against.

Newer

LLM API Retry and Fallback Patterns That Don't Double Your Bill

Older

AI Code Review Cost per Pull Request: Token Math for DIY Reviewers

Build with AtmoRouter.