- Symptom
- API error mentioning max_tokens exceeding the model's output limitRequests that worked on 2.1.326 through 2.1.328 now fail on a gateway whose model allows fewer output tokens
- Cause
- Version 2.1.326 added an automatic retry that read the limit from a max_tokens error and resent with it. Version 2.1.329 removed that retry, so the oversized max_tokens value is sent and rejected every time.
- Fix
- Set CLAUDE_CODE_MAX_OUTPUT_TOKENS to the output token limit of the model behind the gateway.
- Apply
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192 # use your gateway model's real output limit- Affected
- Claude Code 2.1.329 and later, with gateways or custom base URLs whose model accepts fewer output tokens than the default
- Sources
Last verified 2026-11-20 · Confirmed by 0 builders