Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Aider error

Aider: Model foobar: Unknown context window size and costs, using sane...

Error message
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

  1. 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"
        }
    }
  2. Fix 2.

    Silence model warnings with --no-show-model-warnings (added in v0.30.0).

    Terminal
    aider --no-show-model-warnings
  3. Fix 3.

    For the Ollama-specific litellm bug in issue #2318, the maintainer said litellm released a fixed version and suggested upgrading litellm.

    Terminal
    pip install -U litellm

More Aider errors

All 17 Aider errors

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.