Every model can only process a certain amount of text at once, its input window. If a chat history grows longer than this window over time, FlowModels rejects the request with 400 context_length_exceeded. Unlike some other APIs, we don't quietly shorten your history. Here are your options in that case.
Read the error message
The message states two numbers: max_input_tokens is the model's limit, estimated_input_tokens is our estimate for your request. param is set to messages. You can find a model's limit ahead of time in GET /v1/models under flowai_limits.input_tokens, see What a model can do: check capabilities, limits, output length and reasoning effort.
400 input_tokens_exceeded is closely related. There too, the estimated input is too large for the allowed limit.
Three ways out of the error
1. Send less
Without the Brain, the history belongs to you: you decide with each request which messages to send. Leave out older messages or summarize them yourself in your application. This is the cheapest way.
2. Allow compaction
If you set "context_compression": true, FlowModels may summarize a history that's too long by itself and then run the request:
{
"model": "groq/openai/gpt-oss-120b",
"context_compression": true,
"messages": [ … your long history … ]
}
The summary is an additional model call and costs extra. In the response, this share is listed under usage.flowai.compression with calls, input_tokens, output_tokens and cost_micro_eur. The amount is already included in usage.cost and is only listed separately so that you can understand a higher charge. Without compaction, the field is missing entirely.
If you use the OpenAI library for Python, send the field via extra_body. If compaction is temporarily switched off on our side, the API responds to context_compression with 400 unsupported_field.
3. Let the Brain manage the history
With external_identifier and conversation, we store a conversation's history for you, see Use the Brain: store and continue conversations per end user. You then send only the new message. If the stored history grows longer than the input window, we automatically summarize older sections and store the summary.
The following applies:
- Each section is summarized exactly once and paid for exactly once, not again with every request.
- The most recent messages are always kept word for word. Older ones reach the model through the summary.
- Nothing is lost: a message only drops out of its verbatim form once the summary has taken it in.
These summaries are also model calls and count toward your usage.
Which way is right?
| Situation | Recommendation |
|---|---|
| You have the history in your database anyway | shorten it yourself or use context_compression |
| You don't want to deal with histories | Brain with external_identifier |
| A single request with a very long document | choose a model with a larger input window |
Good to know
- Attachments such as PDFs also count toward the input. A large document can fill the window on its own.
- The token count on our side is an estimate made before running the request. So plan for some headroom below the limit.
- Besides the token limit, there are fixed upper limits per request: 1,000 messages, 1,000,000 characters per message and 4 MiB of JSON.