A reply stops with stop_reason model_context_window_exceeded. What happened?
Why C is the answer
Generation filled the model's context window
This stop reason means generation hit the context window. It is different from max_tokens, and from the 400 returned for oversized input.
In detail
- This stop reason means generation ran until it filled the context window.
- It differs from max_tokens, which is the limit you set on the reply.
- It also differs from the 400 returned when input is too long before generation starts.
- Treat this reply as incomplete, as you would with max_tokens.
Use case
An illustrative scenario, not a real incident.
A long request is generating when it fills the model's context window, and the response stops with model_context_window_exceeded. The fix is to reduce the input or ask for less, not to raise max_tokens.
See it in different ways
flowchart TD
A["Request"] --> B{"Input over the window?"}
B -->|Yes| C["400: prompt is too long"]
B -->|No| D["Generate"]
D --> E{"Window fills?"}
E -->|Yes| F["stop_reason: model_context_window_exceeded"]
E -->|No| G["Normal stop"]stateDiagram-v2 [*] --> CheckInput CheckInput --> Rejected400: input too long CheckInput --> Generating: input fits Generating --> MaxTokens: reply limit reached Generating --> WindowFull: model_context_window_exceeded Generating --> Finished: end_turn
flowchart TD
Q{"What did you receive?"}
Q -->|"A 400 error"| A0["Input too long"]
Q -->|"stop_reason max_tokens"| A1["Your reply limit was hit"]
Q -->|"model_context_window_exceeded"| A2["Generation filled the window"]Key point: Three limits look similar but mean different things.
Why the other options are wrong
- A. The max_tokens setting was reached before the window filled
- That case reports stop_reason max_tokens.
- B. A safety system stopped the model from replying any further
- A safety stop would report a different reason, such as refusal.
- D. The API rejected the request before generation began
- A rejected request returns an error, and it would have no stop reason.

