Aider on one prepaid key
Point aider at RelaySwitch with two environment variables and the openai/ prefix: one key, any coding model on the Models page, billed per token from a balance you top up by card or crypto.
Aider talks to any OpenAI-compatible endpoint. Set OPENAI_API_BASE to https://api.relayswitch.io/v1, put a RelaySwitch key in OPENAI_API_KEY, and start aider with --model openai/<id>. The same two values reach Claude, GPT, DeepSeek, Gemini and Kimi, each at the per-token price on its model page. No subscription, no monthly plan, no KYC: the key draws on a prepaid balance and stops when it is empty.
Below: the shell setup, the two config files that make it stick, a weak model for commit messages, and a model metadata file built from the live catalog so aider reports context and cost correctly. Then a sample session priced on each model.
01What you need
- Aider installed (
aideron your PATH) and a git repository to work in. - A RelaySwitch key. Sign in with an email code at the console and create one. Keys start with
sk-relay-. - A balance. Top-ups start at $10, by card or crypto, pay as you go. Before the first top-up the console chat gives you 12 free turns a day to try models; aider requests bill the balance.
02Aider OpenAI-compatible setup
Aider's OpenAI-compatible API page (read 2026-10-28) asks for two environment variables and the openai/ prefix on the model name. The prefix tells aider which client to use; the id after it is the one from the Models page.
# Mac/Linuxexport OPENAI_API_BASE=https://api.relayswitch.io/v1export OPENAI_API_KEY=sk-relay-... cd /to/your/projectaider --model openai/claude-sonnet-5-5On Windows the docs use setx and a fresh shell:
setx OPENAI_API_BASE https://api.relayswitch.io/v1setx OPENAI_API_KEY sk-relay-...:: open a new terminal after setxaider --model openai/claude-sonnet-5-5Keep the /v1 on the base URL. Aider adds /chat/completions itself. To switch models, change the id after the prefix; the base URL and key stay.
03Make it stick: .aider.conf.yml or .env
Aider reads .aider.conf.yml from your home directory, then the git root, then the current directory, and the last file loaded wins (config docs, read 2026-10-28). The YAML keys are the long flag names without the dashes in front:
# .aider.conf.yml (home directory, git root or current directory)openai-api-base: https://api.relayswitch.io/v1openai-api-key: sk-relay-...model: openai/claude-sonnet-5-5weak-model: openai/claude-haiku-5-5The same settings as a .env file, searched in the same order (.env docs, read 2026-10-28). Aider's own options take an AIDER_ prefix; the key stays the plain OPENAI_API_KEY the client reads:
# .env (same search order; the file loaded last wins)AIDER_OPENAI_API_BASE=https://api.relayswitch.io/v1OPENAI_API_KEY=sk-relay-...AIDER_MODEL=openai/claude-sonnet-5-5AIDER_WEAK_MODEL=openai/claude-haiku-5-5A file in the home directory covers every project. A file at a git root pins one project to another model. Keep the key out of any file you commit: a .env at the git root belongs in .gitignore.
weak-model is the model aider uses for commit messages and chat-history summaries. Those calls are short and frequent, so a cheap one does; Claude Haiku 5.5 bills $0.0582 in and $0.1455 out per million tokens today. Without the line, aider sends those calls to the main model and bills them at its price.
04Model metadata, so aider knows limits and costs
For a model it has not heard of, aider prints "Unknown context window size and costs, using sane defaults", treats the window as unlimited and the model as free (warnings page, read 2026-10-28). The fix is a .aider.model.metadata.json in the home directory, the git root or the current directory (advanced model settings, read 2026-10-28). One entry per model, under the prefixed name, with costs in USD per token:
{ "openai/claude-sonnet-5-5": { "max_input_tokens": 1000000, "max_output_tokens": 128000, "input_cost_per_token": 0.0000012, "output_cost_per_token": 0.000003, "litellm_provider": "openai", "mode": "chat" }, "openai/claude-opus-5-5": { "max_input_tokens": 1000000, "max_output_tokens": 128000, "input_cost_per_token": 0.0000027160000000000003, "output_cost_per_token": 0.000009699999999999999, "litellm_provider": "openai", "mode": "chat" }, "openai/gpt-6.1-sol": { "max_input_tokens": 1050000, "max_output_tokens": 128000, "input_cost_per_token": 5.82e-7, "output_cost_per_token": 0.00000291, "litellm_provider": "openai", "mode": "chat" }, "openai/deepseek-v4-pro-0813": { "max_input_tokens": 1048576, "max_output_tokens": 393216, "input_cost_per_token": 7.92e-7, "output_cost_per_token": 0.0000011879999999999999, "litellm_provider": "openai", "mode": "chat" }, "openai/gemini-3.1-pro-preview": { "max_input_tokens": 1048576, "max_output_tokens": 65536, "input_cost_per_token": 0.0000012, "output_cost_per_token": 0.0000072000000000000005, "litellm_provider": "openai", "mode": "chat" }, "openai/kimi-k2.7-code": { "max_input_tokens": 262144, "max_output_tokens": 262144, "input_cost_per_token": 4.2598e-7, "output_cost_per_token": 0.0000017936, "litellm_provider": "openai", "mode": "chat" }, "openai/claude-haiku-5-5": { "max_input_tokens": 1000000, "max_output_tokens": 128000, "input_cost_per_token": 5.8200000000000005e-8, "output_cost_per_token": 1.455e-7, "litellm_provider": "openai", "mode": "chat" }}The numbers above come from the live catalog when this page was built: the context window as max_input_tokens, the output ceiling as max_output_tokens, and the per-million prices divided by a million. They feed aider's token counts and the cost line after each reply. Billing does not read them; every request bills at the catalog price on the console's Usage page.
05Check the key before aider
Two curl calls rule out the key and the base URL before you read aider's output. The first lists every model id your key can call:
curl https://api.relayswitch.io/v1/models -H "Authorization: Bearer sk-relay-..."The second sends one small request the way aider does. -i prints the headers, including the request id and, on a non-streamed answer, the charge in USD.
curl -i https://api.relayswitch.io/v1/chat/completions \ -H "Authorization: Bearer sk-relay-..." \ -H "Content-Type: application/json" \ -d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say ok."}]}'If both work, any failure left is in aider's settings. Send a message in aider and the request shows on the console's Usage page within seconds, with its tokens and its charge.
06Which model to pick
Aider resends the repo map, the files you added and the chat history with every message, so input tokens are most of the bill. A low input price matters more than a low output price. Of the models here, Kimi K2.7 Code has the lowest input rate today at $0.426 per million tokens.
| Model | Input | Cached | Output | Developer list in / out | Context |
|---|---|---|---|---|---|
| Claude Sonnet 5.5 | $1.20 (40% under) | $0.075 | $3.00 (70% under) | $2.00 / $10.00 | 1M tokens |
| Claude Opus 5.5 | $2.716 (32% under) | $0.1455 | $9.70 (51% under) | $4.00 / $20.00 | 1M tokens |
| GPT-6.1 Sol | $0.582 (70% under) | $0.0582 | $2.91 (70% under) | $2.00 / $10.00 | 1.1M tokens |
| DeepSeek V4 Pro 0813 | $0.792 (40% under) | $0.0625 | $1.188 (70% under) | $1.32 / $3.96 | 1M tokens |
| Gemini 3.1 Pro Preview | $1.20 (40% under) | $0.12 | $7.20 (40% under) | $2.00 / $12.00 | 1M tokens |
| Kimi K2.7 Code | $0.426 (55% under) | $0.0852 | $1.7936 (55% under) | $0.95 / $4.00 | 262K tokens |
USD per million tokens, read from the RelaySwitch catalog when this page was built. Developer list: the catalog's record of the developer's own price.
Claude ids answer the OpenAI format, so Claude Sonnet and Opus run under the openai/ prefix with no Anthropic variable. For the full list, with every price and context size, see the Models page. How the balance and the cached rate work is on Pricing.
07What an aider session costs
The session: one feature built over 40 aider messages, late enough that the chat carries a large repo map and several files. Each message sends 80,000 tokens of earlier context, 2,000 new input tokens, and gets 1,500 output tokens back. Those sizes are an assumption; your own Usage page shows the real ones.
| Model | Context from cache | No cache hits |
|---|---|---|
| DeepSeek V4 Pro 0813 | $0.3346 | $2.67 |
| GPT-6.1 Sol | $0.4074 | $2.08 |
| Kimi K2.7 Code | $0.4143 | $1.50 |
| Claude Sonnet 5.5 | $0.516 | $4.12 |
| Gemini 3.1 Pro Preview | $0.912 | $4.37 |
| Claude Opus 5.5 | $1.26 | $9.49 |
40 messages at the live per-token prices. A model with no cached rate bills cached tokens at its input rate.
Two columns, because whether the earlier context hits the prompt cache depends on the model and the request. When it does, the response reports cached tokens and they bill at the cached rate. The console's Usage page shows the split for every request.
With cache hits the same session runs $0.3346 on DeepSeek V4 Pro 0813 and $1.26 on Claude Opus 5.5. Aider's /model command switches the main model mid-chat, so a cheap model for routine edits and a dear one for the hard step costs nothing to set up.
08Errors and fixes
401or an authentication error from the client: the key is wrong, revoked or cut short. Paste it again from the console and run the curl check.402: the balance is too low for the request. Top up in the console; the key works again at once.404or a model-not-found error: the id afteropenai/is not in the catalog. Check for a typo or a display name in place of the id;GET /v1/modelslists every id.429: the key hit its rate limit. Wait a minute and resend, or create a key with a higher Requests / min in the console.- Connection errors:
OPENAI_API_BASEis missing/v1, has a typo, or a proxy blocks it. The curl check from the same machine tells you which. - "Unknown context window size and costs": aider has no metadata for the id. Add the metadata file above; the model works either way.
- Aider asks for a variable the model needs and names one you have not set: the model id is missing the
openai/prefix, so aider looked for another provider's key.
Questions
- What base URL does aider need for an OpenAI-compatible API?
- https://api.relayswitch.io/v1, in OPENAI_API_BASE or as openai-api-base in .aider.conf.yml, with the /v1 at the end. Aider appends /chat/completions to it.
- What does the openai/ prefix on the model name do?
- It tells aider to send the request through its OpenAI-compatible client, to the base URL you set. The id after the prefix is the one from the Models page, so openai/claude-sonnet-5-5 reaches Claude Sonnet.
- Can aider run Claude through an OpenAI-compatible endpoint?
- Yes. The Claude ids on RelaySwitch answer the OpenAI format as well as Anthropic's, so they work under the openai/ prefix with no ANTHROPIC_API_KEY, at the same price.
- Why does aider say the model has an unknown context window?
- Aider ships metadata for the models it knows and prints that line for any other id. It then assumes an unlimited window and a free model. A .aider.model.metadata.json with the entry from this page gives it the real limits and prices.
- Does aider need a subscription or a monthly plan here?
- No. The key draws on a prepaid balance, topped up from $10 by card or crypto, and bills per token at the live catalog price. The console chat runs 12 free turns a day before the first top-up.