Tools & integrationsGuide
Aider config file for your own API key: .aider.conf.yml and Windows setx
Keep your own API key and base URL in .aider.conf.yml, get the load order right and avoid the Windows setx trap, with a session cost estimate.

On this page
Two variables, OPENAI_API_BASE and OPENAI_API_KEY, and a model argument like openai/ are enough to point Aider at CheapTokens. The step-by-step basics (install, first request, 401/404/400/402) are in How to connect Aider to CheapTokens; this page covers what that guide leaves out: Windows setx, the config file and its load order, and a session cost estimate.
Source: Aider's docs for OpenAI-compatible APIs (page checked 26 October 2026; the docs show no date or version, and the latest aider-chat on PyPI that day was 0.86.2).
Windows: setx and a new terminal#
On Mac and Linux you export the two variables. On Windows (PowerShell or cmd) use setx:
setx OPENAI_API_BASE https://api.cheaptokens.dev/v1
setx OPENAI_API_KEY <your CheapTokens key>On Windows there is a catch. setx writes the variables for future sessions, not the one you are typing in, so close the terminal and open a new one before you start Aider. If you set the variables and Aider still asks for a key, this is the usual reason.
Which model for which edits#
The model argument is openai/ plus the full id, so for CheapTokens it has two slashes:
cd your-git-repo
aider --model openai/MiniMaxAI/MiniMax-M2.7MiniMax-M2.7 has a 180K context and answers up to 8,192 tokens, a fit for small and medium edits where answers stay short. If your edits come back as long diffs, the other model worth trying is DeepSeek-V4-Flash: up to 32,768 tokens per answer, a 380K context and one price at any time of day.
aider --model openai/deepseek-ai/DeepSeek-V4-Flash-0731Copy the full id from the CheapTokens docs or the model list on pricing.
Run a first edit#
Aider works inside a git repo, so start in one. Add a file and ask for something small:
> /add app.py
> Add a --verbose flag that prints each file before it is processedWhen Aider answers with an edit to the file, the key, the base URL and the model id are all right.

Stop retyping: .aider.conf.yml#
Aider reads .aider.conf.yml from your home directory, then the git repo root, then the current directory, and later files win. So a global file can hold the key and base, and a repo file can pick the model. If you want one specific file and nothing else, aider - loads only that one.
A home-directory file (example, put your own key in):
openai-api-base: https://api.cheaptokens.dev/v1
openai-api-key: <your CheapTokens key>
model: openai/MiniMaxAI/MiniMax-M2.7Now aider alone starts with the right endpoint and model. If you commit the file to a repo, leave the key out and keep it in the environment variable or in a .env file; the key lines are for your own home directory.
For a model that Aider does not know, the docs describe a model- (.) where you can specify its settings.
What a session costs#
Aider re-sends the files you added and the chat history with every message, so input tokens grow faster than output. Say a working session of about 20 messages sends 400,000 input tokens and gets 40,000 output tokens back (an assumption for the example; plug in your own numbers). On MiniMax-M2.7 that is $0.026, and cheaper than OpenRouter in total, with input and output counted together. The table below runs the same session across our models:
| Model | Input $/1M | Output $/1M | Cost | OpenRouter |
|---|---|---|---|---|
| GLM-5.3-Flash | $0.02 | $0.04 | $0.0096 | $0.0196 |
| DeepSeek-V4-Flash | $0.015 | $0.10 | $0.01 | $0.0253 |
| MiniMax-M2.7 | $0.05 | $0.15 | $0.026 | $0.168 |
400,000 input and 40,000 output tokens in total. Prices per 1M tokens are current and change together with our tariffs; the OpenRouter column shows reference prices for the same workload.
How to keep the input side small (read-only files, /drop, repo map size) is covered in How much does Aider cost. Current prices are always on the pricing page.
If it does not work#
- Aider asks for an API key or talks to the wrong service. The variables are not visible to the process. On Windows, restart the terminal after
setx; on Mac and Linux, runecho $OPENAI_in the same shell.API_ BASE - Your config seems ignored. Remember the order: home, repo root, current directory. A file closer to you overrides the global one.
- Model not found, 404 or an authentication error. These are covered in How to connect Aider to CheapTokens.
The same OpenAI-compatible address works in other tools; if you also use an editor agent, see connecting OpenCode or the overview of where to plug in your own API key.



