Aider Setup Guide: Custom OpenAI-Compatible Endpoint
Aider needs two settings and one naming rule to run on FreeModel. Three ways to set them, which one to choose, and what the common warnings and errors mean.
Aider is a terminal pair programmer: you add files to the chat, describe a change, and it edits the files and commits the result to git. It works with any OpenAI-compatible API, so connecting it to FreeModel takes two values and one naming rule.
The short version
export OPENAI_API_BASE=https://freemodel.in/v1
export OPENAI_API_KEY=fm_your_key_here
aider --model openai/gpt-6-luna
That is the whole setup. The rest of this guide explains each part, the other ways to set it, and what to do when something goes wrong.
The three values
| Setting | Value | Note |
|---|---|---|
| API base | https://freemodel.in/v1 | Ends at /v1, nothing after it |
| API key | your fm_ key | From Dashboard → API Keys |
| Model | openai/ + a FreeModel id | For example openai/gpt-6-luna |
Why the openai/ prefix
Aider uses LiteLLM to talk to models, and LiteLLM picks a client from the model name. The openai/ prefix says: use the OpenAI-compatible client, with my base URL. Without it, a name such as claude-sonnet-5 could be sent to a different provider client that ignores OPENAI_API_BASE.
After the prefix, write the FreeModel id exactly as GET /v1/models returns it, dots included: openai/claude-opus-4.8, openai/glm-5.3-flash. FreeModel only serves listed ids; other names are not mapped to a different model and return 404 model_not_found.
Three ways to configure it
| Method | Good for | Watch out for |
|---|---|---|
| Environment variables | Your own machine, every repo | Must be set in each new shell, or in your profile |
| Command-line flags | One-off runs, scripts, CI | The key ends up in shell history |
.aider.conf.yml + .env | Per-project defaults | Keep the key out of committed files |
1. Environment variables
macOS and Linux: add the two export lines above to ~/.bashrc or ~/.zshrc. On Windows PowerShell, for the current session:
$env:OPENAI_API_BASE = "https://freemodel.in/v1"
$env:OPENAI_API_KEY = "fm_your_key_here"
aider --model openai/gpt-6-luna
Note that OPENAI_API_KEY is also read by other tools. If you use a real OpenAI key elsewhere on the same machine, prefer the per-project method below.
2. Command-line flags
aider --openai-api-base https://freemodel.in/v1 \
--openai-api-key "$FREEMODEL_API_KEY" \
--model openai/gpt-6-luna
Reading the key from your own variable (here FREEMODEL_API_KEY) keeps it out of shell history.
3. Config file and .env
Aider reads .aider.conf.yml from your home directory and from the root of the git repo. Put the non-secret settings there:
# .aider.conf.yml
model: openai/gpt-6-luna
openai-api-base: https://freemodel.in/v1
And the key in a .env file at the repo root, which Aider also loads:
# .env (add this file to .gitignore)
OPENAI_API_KEY=fm_your_key_here
Then just run aider.
Choosing models for Aider
Aider can use up to three models in one session. Set them explicitly so it never falls back to a name FreeModel does not list:
- Main model (
--model): writes the code. - Weak model (
--weak-model): writes commit messages and summarises chat history. A free model is a sensible choice, for example--weak-model openai/gpt-6-luna. - Editor model (
--editor-model): only used in architect mode (--architect), where one model plans and another applies the edits.
On the free plan you can use the 8 free models (GPT-6.2 Astra, GPT-6 Luna, Grok 4.6, Grok 4.7, Claude Haiku 5.5, GLM-5.3 Flash, Qwen 3.8 Omni Flash and DeepSeek V4.1 Flash 1017). Claude Haiku 5.5 and GPT-6.2 Astra are on the free plan; the other Claude models and premium models need a paid plan; every paid plan reaches every model, and each model uses plan tokens at its own rate, listed on the pricing page. Input and output tokens both count, and Aider sends the files you add on every turn, so add only the files the change needs.
The "unknown model" warning
When Aider starts with a model it has no built-in data for, it warns that the context window and costs are unknown and uses defaults. Your requests still work. You have two options:
Hide the warning with --no-show-model-warnings.
Or describe the model in .aider.model.metadata.json in your home directory or repo root:
{
"openai/gpt-6-luna": {
"max_input_tokens": 1000000,
"litellm_provider": "openai",
"mode": "chat"
}
}
Take the context size from the model's page (for example GPT-6 Luna lists 1M). Some models do not publish one; leave the field out for those.
The cost Aider prints is its own estimate and does not know FreeModel's plans. Your real usage is in the FreeModel dashboard.
Troubleshooting
- 401 / authentication error — key not set in this shell, mistyped, or revoked. Run
echo $OPENAI_API_KEYto check it is there. - 404
model_not_found— the part afteropenai/does not match a listed id. - Requests go to the wrong place — the base URL is missing or ends in
/chat/completions. It must end at/v1. - 403
upgrade_required— a free account asked for a paid model. - 402 — tokens used up (
tokens_exhausted). The rejected request is not charged. - 429 — plan rate limit for this key; Aider retries after a pause.
- Edits fail to apply — some models handle Aider's diff format less reliably. Try
--edit-format whole, which asks for whole files instead of diffs (it uses more output tokens).
Before blaming Aider, test the key directly with the curl example in the quickstart. The same values work for other terminal agents; see the opencode guide.
FAQ
Why does the model name need the openai/ prefix?
Aider uses the prefix to choose the OpenAI-compatible client, which honours your custom base URL. Without it, a name like claude-sonnet-5 may be sent to a different provider client.
Is the cost Aider prints what FreeModel charges?
No. Aider estimates cost from its own price data, which does not know FreeModel plans. Your real usage is in the FreeModel dashboard.
Can I use Claude models in Aider through FreeModel?
Yes. Use the openai/ prefix with the FreeModel id, for example openai/claude-sonnet-5 on a paid plan. Free accounts can use Claude Haiku 5.5 (openai/claude-haiku-5.5) and the other free models such as gpt-6-luna.
Where should the key live?
In an environment variable or a .env file that is listed in .gitignore. Avoid putting it in a config file that is committed to the repository.
Grab a free API key — 1M tokens on 8 free models after a one-time Telegram verification, no card. Every model from $1.20.