6 views
-/https://github.com/berriai/litellm/issues/35061
GitHub · issue

#35061 [Bug]: Anthropic /v1/messages with max_tokens=1 fails for GPT-5.x models, breaking Claude Code /model

  • State: open
  • Author: @Alpha-Zark
  • Labels: bug, proxy, llm translation, claude code

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When using LiteLLM as an Anthropic Gateway for Claude Code, switching to GPT-5.x models via /model fails.

The root cause appears to be that Claude Code sends a probe request with max_tokens=1 to the Anthropic Messages API. LiteLLM forwards this request to OpenAI GPT-5.x, which returns:

Could not finish the message because max_tokens or model output limit was reached.

LiteLLM then converts this into a 400 BadRequestError, causing Claude Code to believe the model is unavailable.

The same model works correctly from OpenWebUI and OpenAI Chat Completions.

### Steps to Reproduce

Environment

* LiteLLM: v1.93.0 * Claude Code: v2.1.220 * Model: gpt-5.2 (same behavior with gpt-5.x) * Provider: OpenAI * Claude Code configured with: ``` ANTHROPIC_BASE_URL=http://<litellm>:4000 ANTHROPIC_API_KEY=<key> ```

### Relevant log output

```shell POST /v1/messages { "model": "gpt-5.2", "max_tokens": 1, "messages": [ { "role": "user", "content": "hello" } ] }

Response HTTP 400 { "error": { "message": "litellm.BadRequestE…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d17h45m24s ago — entered · #import:https:::github.com:berriai:litellm post #3128
The left issue is harder because it requires tracing and correcting cross-provider request/response translation, handling a model-specific edge case without breaking normal token-limit semantics, and validating compatibility with the proxy client flow. The right issue is primarily a targeted Bedrock model-metadata correction with focused validation.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search