---
title: "Best LLM for Aider - choosing and connecting a model"
description: "How to pick the best LLM for Aider: edit-format discipline, context size and cost per hour, a one-hour test on your own repo, and the exact OPENAI_API_BASE setup."
url: https://broadrouter.com/blog/best-llm-for-aider/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Best LLM for Aider: how to choose a model and connect it

By the BroadNet Inference team · 6 min read · Published 2026-11-14

The best model for Aider follows its edit format reliably, holds your repository map in context and is cheap enough to run all day. Aider connects to any OpenAI-compatible API: set OPENAI\_API\_BASE to https://inference.broadnet.ai/v1, set OPENAI\_API\_KEY, and start aider --model openai/broadnet/deepseek-v4.1-flash. On a Full Moon plan that model has no token meter.

## Key takeaways

-   Aider edits files through text edit formats (whole, diff, udiff), so a model must follow the format, not just write good code.
-   Any OpenAI-compatible endpoint works: OPENAI\_API\_BASE plus OPENAI\_API\_KEY, then --model openai/<model-id>.
-   DeepSeek V4.1 Flash has a 1,048,576-token context and is the only model on the unlimited plans.
-   Aider resends the repo map and chat history every turn, so input tokens dominate a per-token bill.
-   Judge a model on your own repository for an hour before you commit to it.

**On this page**

1.  What does Aider need from a model?
2.  How do you compare models on your own code?
3.  How do you connect Aider to an OpenAI-compatible API?
4.  Which BroadNet models fit Aider?
5.  Should you use architect mode with two models?
6.  Is Aider cheaper per token or on a flat plan?
7.  Which Aider settings save turns?
8.  How do you test a model before you commit?

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 is model-agnostic, which is its strength and its first question. Which model should you plug in?

There is no single right answer, but there is a right way to decide. This post covers what Aider actually asks of a model, how to compare candidates, and how to connect any OpenAI-compatible API in two environment variables.

## What does Aider need from a model?

Aider does not use API tool calling to edit files. It tells the model to reply in an **edit format**, then parses the reply and applies it. Its documentation lists several:

| Edit format | What the model returns | Good for |
| --- | --- | --- |
| `whole` | The full new contents of each changed file | Small files, weaker models |
| `diff` | Search-and-replace blocks for the changed parts | Most models, most repos |
| `diff-fenced` | The same, with the file path inside the fence | Models that misplace paths |
| `udiff` | A simplified unified diff | Models that drift in `diff` |

So a good Aider model needs four things:

1.  **Format discipline.** If the search block does not match the file exactly, the edit fails and Aider asks again. Every retry is another full request.
2.  **Context room.** Aider sends a repository map (a compact summary of symbols across the repo), the files you added and the chat so far. On a large codebase that is tens of thousands of tokens per turn.
3.  **Reasoning that fits the budget.** Reasoning models think before answering, and that thinking counts toward `max_tokens`. Too small a limit gives an empty reply.
4.  **A price you can leave running.** Aider is chatty by design. Cost per hour of real work matters more than cost per token on a pricing page.

Aider’s own [leaderboards](https://aider.chat/docs/leaderboards/) measure how often models complete coding exercises in its edit formats. They are a useful first filter, but your repository, language and habits will move the result. Treat any benchmark as a shortlist, not a verdict.

## How do you compare models on your own code?

A practical test takes about an hour:

1.  Pick five real tasks from your backlog: a bug fix, a small feature, a refactor across two files, a test to write and a doc update.
2.  Run each candidate model on the same tasks from the same git commit, with one branch per model.
3.  Record three things per task: did it finish, how many turns did it take, and how many edits failed to apply.
4.  Read the diffs. A model that “finishes” with a sprawling change is worse than one that needs one more turn but stays small.

Failed edits and extra turns are where cost hides. A model with a low per-token price that needs three attempts per edit can cost more than a pricier one that gets it right first time.

## How do you connect Aider to an OpenAI-compatible API?

Aider’s [OpenAI-compatible setup](https://aider.chat/docs/llms/openai-compat.html) needs a base URL, a key, and a model name prefixed with `openai/`:

```bash
export OPENAI_API_BASE=https://inference.broadnet.ai/v1
export OPENAI_API_KEY="$BROADNET_API_KEY"

cd /path/to/your/repo
aider --model openai/broadnet/deepseek-v4.1-flash
```

The `openai/` prefix tells Aider (through LiteLLM) to use the OpenAI wire format against your base URL. Everything after the prefix is the provider’s model ID, slash included. The step-by-step version, including Windows, is in the [Aider guide](https://broadrouter.com/guides/aider-unlimited-deepseek/).

To make it permanent, put the same settings in `.aider.conf.yml` in your home directory or repo root:

```yaml
openai-api-base: https://inference.broadnet.ai/v1
model: openai/broadnet/deepseek-v4.1-flash
```

Keep the key in the environment rather than in a file you might commit.

### Silencing the unknown-model warning

Aider knows context sizes and prices for popular models only. For others it prints a warning. Its docs say you can usually ignore it, because Aider “never enforces token limits”; it only reports the provider’s errors. To give it accurate numbers, add `.aider.model.metadata.json` in your home directory, repo root or launch directory:

```json
{
  "openai/broadnet/deepseek-v4.1-flash": {
    "max_input_tokens": 1048576,
    "max_output_tokens": 32000,
    "litellm_provider": "openai",
    "mode": "chat"
  }
}
```

The output figure there is a setting you choose, not a published limit. Leave room for reasoning.

## Which BroadNet models fit Aider?

BroadNet Inference serves three chat models that suit coding work. Prices are per 1M tokens, from the published price file:

| Model | Context | Input | Cached input | Output |
| --- | --- | --- | --- | --- |
| [DeepSeek V4.1 Flash](https://broadrouter.com/models/deepseek-v4.1-flash/) | 1,048,576 | $0.175 | $0.0055 | $0.52 |
| [GLM 5.3](https://broadrouter.com/models/glm-5.3/) | 1,048,576 | $0.78 | $0.173 | $3.46 |
| [Qwen3.8 27B](https://broadrouter.com/models/qwen3.8-27b/) | 262,144 | $0.175 | $0.0435 | $2.17 |

All three reason before they answer. BroadNet Gemma 4 VL 26B has a 32,768-token context, which is tight for Aider’s repo map plus several files, so it is better kept for lighter jobs.

**DeepSeek V4.1 Flash** is the default choice here for a plain reason: it is the only model on BroadNet’s unlimited plans. A Full Moon session costs $60 a month with no token meter, and Aider’s habit of resending context every turn stops being a cost problem. Its 1M-token window also means you can add more files than usual without trimming.

**GLM 5.3** costs more per output token. It is worth trying on pay-as-you-go as an architect model for hard design steps, where quality per turn matters more than volume.

**Qwen3.8 27B** has the same input price as Flash and a 262K context. It is a reasonable second model if you want to compare behaviour on your codebase.

## Should you use architect mode with two models?

Aider’s [architect mode](https://aider.chat/docs/usage/modes.html) splits a turn in two: an architect model plans the change, and an editor model turns the plan into file edits. That lets you pair a stronger reasoning model with a cheaper, format-reliable editor:

```bash
aider --architect \
  --model openai/broadnet/glm-5.3 \
  --editor-model openai/broadnet/deepseek-v4.1-flash
```

Aider’s docs note that each turn now uses two LLM requests. On a plan session that matters for concurrency, not cost: the two requests run one after another, so one session is enough for one Aider window.

## Is Aider cheaper per token or on a flat plan?

Aider’s input-heavy traffic is where flat pricing pays off. A coding agent typically sends far more input than it receives, and much of that input repeats. With prompt caching, repeated input is billed at the cached rate ($0.0055 per 1M on Flash), so the first lever on a per-token key is a stable prompt prefix. [How cached input is billed](https://broadrouter.com/blog/cached-input-tokens-explained/).

The second lever is the plan. BroadNet’s worked example of a full-time coding agent comes to about $65.40 a month on pay-as-you-go, against $60 for a Full Moon session, so Full Moon is cheaper for that profile. Light, occasional use is the opposite case. Plug your own numbers into the [flat-rate vs per-token calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/), or read [flat rate vs pay per token](https://broadrouter.com/blog/flat-rate-vs-pay-per-token-llm-api/). For more cost levers that apply to any coding agent, see [10 ways to cut coding agent LLM costs](https://broadrouter.com/blog/cut-coding-agent-llm-costs/).

## Which Aider settings save turns?

-   **Leave room for reasoning.** If Aider gets an empty reply, the model spent its output budget thinking. [Why answers come back empty](https://broadrouter.com/guides/reasoning-tokens-empty-response/).
-   **Add only the files that change.** Aider’s repo map already tells the model where things are. Extra files cost context and attention.
-   **Use `/clear` between unrelated tasks.** Old chat history is input on every turn.
-   **Keep auto-commits on.** Each Aider edit becomes a git commit, so `/undo` is one command away when a model goes wrong.
-   **One window per session.** Two Aider windows on one plan session take turns. Buy a second session if you work in two repos at once; see [running parallel coding agents](https://broadrouter.com/blog/run-parallel-coding-agents-flat-rate/).

## How do you test a model before you commit?

The cheapest test is a Meteor hour at $1: unlimited DeepSeek V4.1 Flash for one hour, enough to run the five-task comparison above. New accounts also get $5 of starting credit, but among the chat models it covers only BroadNet Gemma 4 VL 26B; DeepSeek V4.1 Flash, GLM 5.3 and Qwen3.8 27B need a top-up or a plan. All models are listed on the [models page](https://broadrouter.com/models/). If you are still choosing between agents rather than models, read [Cline vs Roo Code vs Aider](https://broadrouter.com/blog/cline-vs-roo-code-vs-aider/).

Free tools for this

-   [Agent run cost estimator](https://broadrouter.com/tools/agent-run-cost-estimator/) Context growth per step, total tokens and cost of one agent run, with a DeepSeek session comparison.
-   [LLM batch job planner](https://broadrouter.com/tools/llm-batch-job-planner/) Run time, binding limit, cost per model and the flat sessions needed to finish a big job by a deadline.
-   [Flat-rate vs per-token LLM cost calculator](https://broadrouter.com/tools/flat-rate-vs-per-token-calculator/) Break-even between an unlimited plan and paying per token, per agent.
-   [LLM rate limit and concurrency calculator](https://broadrouter.com/tools/llm-rate-limit-calculator/) Which limit binds first: RPM, TPM or concurrency, with Little's law.

[All free tools](https://broadrouter.com/tools/)

## Terms in this article

[Token](https://broadrouter.com/glossary/token/)

A token is the unit of text a language model reads and writes: a word, part of a word, a punctuation mark or a byte sequence produced by the model's tokenizer. LLM APIs count, limit and usually bill usage in tokens.

[AI coding agent](https://broadrouter.com/glossary/coding-agent/)

An AI coding agent is a software tool in which a language model works on a codebase in a loop: it reads files, edits them, runs commands such as tests, reads the output and decides the next step until the task is done or a limit is reached.

[Pay-as-you-go](https://broadrouter.com/glossary/pay-as-you-go/)

Pay-as-you-go is a pricing model in which you pay only for what you use, metered per unit such as tokens, requests or audio minutes, with no subscription or minimum commitment. Most LLM APIs bill this way, from a prepaid balance or a periodic invoice.

[Base URL](https://broadrouter.com/glossary/base-url/)

A base URL is the fixed root address of an API, such as https://api.example.com/v1, that a client puts in front of every endpoint path, such as /chat/completions. In OpenAI-compatible SDKs, changing the base URL, together with the API key and model ID, points the same code at a different provider.

[Context window](https://broadrouter.com/glossary/context-window/)

A context window is the maximum number of tokens a language model can work with in a single request. It covers the prompt, conversation history, tool definitions, images and the generated output, including any reasoning tokens. Anything that does not fit must be cut, summarised or split across several requests.

[OpenAI-compatible API](https://broadrouter.com/glossary/openai-compatible-api/)

An OpenAI-compatible API is an HTTP API that accepts the same request and response formats as the OpenAI API, such as POST /v1/chat/completions, so OpenAI SDKs and tools can use it by changing only the base URL, the API key and the model name.

[Tool calling](https://broadrouter.com/glossary/tool-calling/)

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

[Cached input tokens](https://broadrouter.com/glossary/cached-input-tokens/)

Cached input tokens are prompt tokens that an LLM provider has recently processed and can reuse from a cache instead of computing again, usually a repeated prefix such as a system prompt or document. Providers bill them at a lower rate than new input tokens.

## Questions

### Does Aider need a model with tool calling?

No. Aider asks the model to return edits in a text format such as a search-and-replace diff, then applies them itself. What matters is that the model follows that format consistently.

### Why does Aider warn that it does not know my model?

Aider ships metadata for popular models only. For any other model it warns about unknown context size and cost. You can ignore the warning or add a .aider.model.metadata.json entry.

### Which BroadNet model should I start with in Aider?

DeepSeek V4.1 Flash, because it has a 1M-token context, low per-token prices and is the only model you can run on an unlimited plan. Try GLM 5.3 or Qwen3.8 27B on pay-as-you-go if you want a second opinion on hard edits.

### How do I use a custom OpenAI-compatible model in Aider?

Set OPENAI\_API\_BASE to the provider's base URL and OPENAI\_API\_KEY to your key, then start aider with --model set to openai/ followed by the model ID; Aider's docs say to add that openai/ prefix. On Windows, use setx and restart the shell.

### Can I run two Aider windows on one plan session?

You can, but a session runs one request at a time, so the second window waits while the first is talking to the model. Buy a session per window that works at the same time.

## Keep reading

-   [How to run parallel coding agents on a flat-rate LLM API](https://broadrouter.com/blog/run-parallel-coding-agents-flat-rate/)
-   [Flat-rate vs pay-per-token LLM API: the break-even math](https://broadrouter.com/blog/flat-rate-vs-pay-per-token-llm-api/)
-   [Cached input tokens: how to cut an LLM API bill](https://broadrouter.com/blog/cached-input-tokens-explained/)
-   [How to run coding agents unattended overnight, safely](https://broadrouter.com/blog/overnight-coding-agent-runs/)
-   [Claude Code with open models: proxies, native endpoints and limits](https://broadrouter.com/blog/claude-code-with-openai-compatible-models/)
-   [OpenClaw and Hermes Agent on a cheap model: setup and token math](https://broadrouter.com/blog/openclaw-hermes-agent-cheap-model/)
-   [Guide: Run Aider on unlimited DeepSeek V4.1 Flash](https://broadrouter.com/guides/aider-unlimited-deepseek/)
-   [Guide: Why a reasoning model returns an empty answer](https://broadrouter.com/guides/reasoning-tokens-empty-response/)
-   [Guide: How the unlimited LLM API plans work for agents](https://broadrouter.com/guides/unlimited-llm-api-sessions/)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-best-llm-for-aider&utm_content=page-cta) ·

**Sources**

-   [Aider docs, OpenAI compatible APIs (fetched 2026-11-14)](https://aider.chat/docs/llms/openai-compat.html)
-   [Aider docs, edit formats (fetched 2026-11-14)](https://aider.chat/docs/more/edit-formats.html)
-   [Aider docs, advanced model settings and model metadata (fetched 2026-11-14)](https://aider.chat/docs/config/adv-model-settings.html)
-   [Aider docs, chat modes and architect mode (fetched 2026-11-14)](https://aider.chat/docs/usage/modes.html)
-   [Aider LLM leaderboards (fetched 2026-11-14)](https://aider.chat/docs/leaderboards/)
-   [BroadNet Inference API reference (fetched 2026-11-14)](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=blog-best-llm-for-aider&utm_content=sources)
