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

Aider error

Aider: Model gpt-3.5-turbo has hit a token limit!

Error message
Model gpt-3.5-turbo has hit a token limit!

Status: WorkaroundLast verified 3 documented fixes2 sources

What it means

The API provider reported that the request went over the model's context window (input plus output) or its output token limit. Aider reports the error and suggests actions. The token counts it prints are estimates. Aider never enforces token limits; it only reports token limit errors from the API provider. Lines such as "-- exceeded output limit!" or "-- possibly exhausted context window!" show which limit was hit.

Causes

  • Trying to send too much data to a model, overflowing its context window (official docs).
  • Asking for a large change that affects a lot of code, so the LLM hits output token limits; most models have output limits as low as 4k tokens (official docs).
  • Non-compliant API proxy servers or bugs in the API server hosting a local model (official docs).

How to fix it

  1. Fix 1.

    Reduce input tokens: use /tokens to see usage, /drop to remove unneeded files, /clear to clear chat history, and break your code into smaller source files.

    Snippet
    /tokens
    /drop
    /clear
  2. Fix 2.

    Reduce output tokens: ask for smaller changes in each request, break code into smaller files, use a strong model like gpt-4o, sonnet or DeepSeek V3 that can return diffs, or use a model that supports infinite output.

  3. Fix 3.

    Try aider without an API proxy server, or directly with one of the recommended cloud APIs. For local models the docs note that Ollama is known to work well with aider.

More Aider errors

All 17 Aider errors

FAQ

What does "Model gpt-3.5-turbo has hit a token limit!" mean in Aider?

The API provider reported that the request went over the model's context window (input plus output) or its output token limit. Aider reports the error and suggests actions. The token counts it prints are estimates. Aider never enforces token limits; it only reports token limit errors from the API provider. Lines such as "-- exceeded output limit!" or "-- possibly exhausted context window!" show which limit was hit.

How do I fix "Model gpt-3.5-turbo has hit a token limit!"?

There are 3 documented fixes. Start with the first: Reduce input tokens: use /tokens to see usage, /drop to remove unneeded files, /clear to clear chat history, and break your code into smaller source files.

Is this Aider error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: All versions.

Sources

Last verified against 2 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.