Bug: Multiple bugs in Anthropic /v1/messages experimental pass-through to OpenAI
Description
There are five related bugs in the Anthropic /v1/messages experimental pass-through implementation when routing requests to OpenAI/Azure models. These issues were discovered during integration testing with Claude Code CLI which uses input_text content block format and requires forcing routing through Chat Completions API when the downstream proxy doesn't support Responses API.
Bug 1: input_text type not supported in chat completions transformation
Claude Code CLI / Claude Agent SDK sends content blocks with {"type": "input_text"} (instead of plain {"type": "text"}) for user messages and system content. The current implementation only checks for "text", so input_text blocks are silently dropped → causes empty input → 422 validation error from downstream provider.
Location: litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py
Bug 2: input_text type not supported in Responses API transformation
Same issue exists on the Responses API conversion path. The code only checks for "text" in three locations:
- Top-level user content blocks
- Nested content inside
tool_result
- System content array
Location: litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py
Bug 3: LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES not respected in responses_api_bridge_check
When the environment variable LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES=true is set (to force routing through /v1/chat/completions instead of /v1/responses), the responses_api_bridge_check function in main.py doesn't check this setting. It still activates Responses API mode for models with the responses/ prefix → request routed to wrong endpoint.
Location: litellm/main.py function responses_api_bridge_check()
Bug 4: LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES not respected in thinking auto-routing
When thinking parameter is enabled, the code automatically adds the responses/ prefix to route through Responses API (to get reasoning text output). But it didn't check the use_chat_completions_url_for_anthropic_messages setting before adding the prefix, ignoring user opt-out preference.
Location: litellm/llms/anthropic/experimental_pass_through/adapters/handler.py function _route_openai_thinking_to_responses_api_if_needed()
Bug 5: LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES not respected in token counting
When the environment variable is enabled, should_use_token_counting_api() still returns True for OpenAI provider, causing it to call /v1/responses/input_tokens endpoint which doesn't exist when routing through Chat Completions → 405 Method Not Allowed error.
Location: litellm/llms/openai/responses/count_tokens/token_counter.py function should_use_token_counting_api()
Expected behavior
input_text content blocks should be accepted and properly converted just like text blocks
- The
LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES setting should be respected consistently at all entry points where Responses API routing decision is made
Fix
All five bugs are fixed in the accompanying PR.
Bug: Multiple bugs in Anthropic
/v1/messagesexperimental pass-through to OpenAIDescription
There are five related bugs in the Anthropic
/v1/messagesexperimental pass-through implementation when routing requests to OpenAI/Azure models. These issues were discovered during integration testing with Claude Code CLI which usesinput_textcontent block format and requires forcing routing through Chat Completions API when the downstream proxy doesn't support Responses API.Bug 1:
input_texttype not supported in chat completions transformationClaude Code CLI / Claude Agent SDK sends content blocks with
{"type": "input_text"}(instead of plain{"type": "text"}) for user messages and system content. The current implementation only checks for"text", soinput_textblocks are silently dropped → causes empty input → 422 validation error from downstream provider.Location:
litellm/llms/anthropic/experimental_pass_through/adapters/transformation.pyBug 2:
input_texttype not supported in Responses API transformationSame issue exists on the Responses API conversion path. The code only checks for
"text"in three locations:tool_resultLocation:
litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.pyBug 3:
LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGESnot respected inresponses_api_bridge_checkWhen the environment variable
LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES=trueis set (to force routing through/v1/chat/completionsinstead of/v1/responses), theresponses_api_bridge_checkfunction inmain.pydoesn't check this setting. It still activates Responses API mode for models with theresponses/prefix → request routed to wrong endpoint.Location:
litellm/main.pyfunctionresponses_api_bridge_check()Bug 4:
LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGESnot respected in thinking auto-routingWhen
thinkingparameter is enabled, the code automatically adds theresponses/prefix to route through Responses API (to get reasoning text output). But it didn't check theuse_chat_completions_url_for_anthropic_messagessetting before adding the prefix, ignoring user opt-out preference.Location:
litellm/llms/anthropic/experimental_pass_through/adapters/handler.pyfunction_route_openai_thinking_to_responses_api_if_needed()Bug 5:
LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGESnot respected in token countingWhen the environment variable is enabled,
should_use_token_counting_api()still returnsTruefor OpenAI provider, causing it to call/v1/responses/input_tokensendpoint which doesn't exist when routing through Chat Completions → 405 Method Not Allowed error.Location:
litellm/llms/openai/responses/count_tokens/token_counter.pyfunctionshould_use_token_counting_api()Expected behavior
input_textcontent blocks should be accepted and properly converted just liketextblocksLITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGESsetting should be respected consistently at all entry points where Responses API routing decision is madeFix
All five bugs are fixed in the accompanying PR.