Skip to content

[Bug]: anthropic.messages.acreate() with OpenAI target doesn't return reasoning content (uses Chat Completions instead of Responses API) #20433

Description

@roni-frantchi

What happened?

When using litellm.anthropic.messages.acreate() with an OpenAI model and thinking parameter enabled, the response doesn't include actual reasoning/thinking content - only token counts.

Expected: Reasoning text returned in response (like Anthropic's thinking blocks)
Actual: Only reasoning_tokens count returned, no text content

Root cause: The anthropic adapter translates thinkingreasoning_effort and routes to Chat Completions API. But Chat Completions only returns token counts. To get actual reasoning text, OpenAI requires Responses API with reasoning: {effort: "...", summary: "auto"}.

Steps to Reproduce

import asyncio
import litellm

async def test():
    response = await litellm.anthropic.messages.acreate(
        model="openai/gpt-5.2-2025-12-11",
        messages=[{"role": "user", "content": "What is 157 * 83? Think step by step."}],
        max_tokens=4000,
        thinking={"type": "enabled", "budget_tokens": 10000},
    )
    
    content = response["content"]
    for block in content:
        print(f"Block type: {block.get('type')}")
        # Expected: thinking block with content
        # Actual: only text block, no thinking content

asyncio.run(test())

Workaround: Manually use openai/responses/ prefix and pass reasoning instead of thinking:

response = await litellm.anthropic.messages.acreate(
    model="openai/responses/gpt-5.2-2025-12-11",  # responses/ prefix
    messages=[{"role": "user", "content": "What is 157 * 83?"}],
    max_tokens=4000,
    reasoning={"effort": "high", "summary": "auto"},  # instead of thinking
)
# This returns thinking blocks with actual content

Relevant log output

# In adapters/transformation.py, thinking is translated to reasoning_effort:
reasoning_effort = translate_anthropic_thinking_to_reasoning_effort(thinking)
return {"reasoning_effort": reasoning_effort}

# Then handler.py always calls Chat Completions:
completion_response = await litellm.acompletion(**completion_kwargs)

Suggested fix

In the anthropic adapter, when targeting OpenAI with thinking enabled:

if is_openai_model and thinking:
    # Route to Responses API instead of Chat Completions
    model = model.replace("openai/", "openai/responses/", 1)
    # Use reasoning param with summary:auto to get content back
    return {"reasoning": {"effort": mapped_effort, "summary": "auto"}}

Happy to submit a PR if you're open to this approach.

Related issue

This may be related to #13419 (OpenAI gpt-5 not showing thinking outputs) - same root cause, different entry point.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions