Aider error
Aider: Model foobar: Unknown context window size and costs, using sane...
Model foobar: Unknown context window size and costs, using sane defaults.Status: By designLast verified 3 documented fixes4 sources
What it means
Aider does not recognize the model name, so it does not know the context window size or token costs. It falls back to an unlimited context window and assumes the model is free. The docs say this is usually not a significant problem and you can probably ignore it. When the name looks like a typo, aider adds "Did you mean one of these?" with similar model names.
Causes
- Specifying a model aider has never heard of (official docs).
- A typo in the model name (official docs: "Did you mean?").
- For Ollama models in Nov 2024, a litellm bug caused spurious warnings (issue #2318).
How to fix it
- Fix 1.
Register the context window and costs in a .aider.model.metadata.json file in your home directory, the git repo root, the launch directory, or pass it with --model-metadata-file.
JSON{ "deepseek/deepseek-chat": { "max_tokens": 4096, "max_input_tokens": 32000, "max_output_tokens": 4096, "input_cost_per_token": 0.00000014, "output_cost_per_token": 0.00000028, "litellm_provider": "deepseek", "mode": "chat" } } - Fix 2.
Silence model warnings with --no-show-model-warnings (added in v0.30.0).
Terminalaider --no-show-model-warnings - Fix 3.
For the Ollama-specific litellm bug in issue #2318, the maintainer said litellm released a fixed version and suggested upgrading litellm.
Terminalpip install -U litellm
More Aider errors
All 17 Aider errorsThe LLM did not conform to the edit format.Status: WorkaroundSearchReplaceNoExactMatch: This SEARCH block failed to exactly match lines in {path}Status: WorkaroundModel gpt-3.5-turbo has hit a token limit!Status: WorkaroundModel azure/gpt-4-turbo: Missing these environment variables:Status: By designaider: The term 'aider' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Status: Workaroundaider-chat 0.23.0 requires somepackage==X.Y.Z, but you have somepackage U.W.V which is incompatible.Status: WorkaroundThe API provider is not able to authenticate you. Check your API key.Status: By designThe API provider has rate limited you. Try again later or check your quotas.Status: By design
Related reading
- Aider vs Claude Code in 2026: Git-First Open Source vs Subagent RuntimeAider vs Claude Code: git-first, model-agnostic Aider against the Claude Code runtime of subagents and hooks. Compare architecture, cost, governance and fit.
- Aider vs Claude Code: Open Source vs Commercial AI Coding CLIAider is open source and works with any model. Claude Code is Anthropic's commercial agent. Here is how they compare for TypeScript.
FAQ
What does "Model foobar: Unknown context window size and costs, using sane..." mean in Aider?
Aider does not recognize the model name, so it does not know the context window size or token costs. It falls back to an unlimited context window and assumes the model is free. The docs say this is usually not a significant problem and you can probably ignore it. When the name looks like a typo, aider adds "Did you mean one of these?" with similar model names.
How do I fix "Model foobar: Unknown context window size and costs, using sane..."?
There are 3 documented fixes. Start with the first: Register the context window and costs in a .aider.model.metadata.json file in your home directory, the git repo root, the launch directory, or pass it with --model-metadata-file.
Is this Aider error fixed?
Status: By design. Expected behavior, not a bug. The documented fixes change the setup that triggers it. Affected versions: All versions (warning by design). Ollama false positives: around Nov 2024, fixed upstream in litellm (issue #2318).
Sources
Last verified against 4 sources: official docs, maintainer replies and release notes.
Newsletter
Fixes for the tools you use, weekly
One email per week. New coding agent releases, what broke, and how developers are working around it.