Skip to content

[Bug]: get_supported_openai_params still reports 'temperature' as supported for Anthropic Claude Opus 4.7 — Anthropic rejects temperature on this model #26444

Description

@jehunt1548

What happened?

Anthropic's Claude Opus 4.7 family rejects the temperature parameter at request time (invalid_request_error: temperature is deprecated for this model.). LiteLLM's AnthropicConfig.get_supported_openai_params() still lists temperature as a supported param for these models, so litellm.drop_params=True / drop_params=True is a no-op — LiteLLM has no reason to drop a param it believes is supported, and it forwards temperature to the Anthropic API, which 400s.

Users who want to keep temperature in their call sites for non-reasoning models currently have to work around this with additional_drop_params=[\"temperature\"], which is exactly what drop_params=True should be doing automatically.

Relevant log output / Anthropic response

litellm.exceptions.BadRequestError: litellm.BadRequestError:
AnthropicException - {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",
\"message\":\"`temperature` is deprecated for this model.\"},
\"request_id\":\"req_011CaNyc6Kpmz9bA66oSzTKo\"}

LiteLLM Version

1.83.13 (latest as of filing — also verified on 1.82.4).

Twitter / LinkedIn details

No response

Reproduction

import importlib.metadata as md, litellm

print(\"litellm\", md.version(\"litellm\"))  # 1.83.13
params = litellm.get_supported_openai_params(
    model=\"claude-opus-4-7\", custom_llm_provider=\"anthropic\"
)
print(\"temperature reported as supported?\", \"temperature\" in params)
# → True  (bug — Anthropic rejects it at request time)

# Consequently drop_params=True does nothing:
litellm.drop_params = True
litellm.completion(
    model=\"anthropic/claude-opus-4-7\",
    messages=[{\"role\": \"user\", \"content\": \"hi\"}],
    temperature=0.1,
)
# → BadRequestError: `temperature` is deprecated for this model.

# Workaround (forces the drop):
litellm.completion(
    model=\"anthropic/claude-opus-4-7\",
    messages=[{\"role\": \"user\", \"content\": \"hi\"}],
    temperature=0.1,
    additional_drop_params=[\"temperature\"],
)
# → OK

Root cause (one-line fix)

litellm/llms/anthropic/chat/transformation.py, AnthropicConfig.get_supported_openai_params() (currently around line 217):

def get_supported_openai_params(self, model: str):
    params = [
        \"stream\",
        \"stop\",
        \"temperature\",   # ← unconditionally added
        \"top_p\",
        ...
    ]

    if (
        \"claude-3-7-sonnet\" in model
        or AnthropicConfig._is_claude_4_6_model(model)
        or AnthropicConfig._is_claude_4_7_model(model)
        or supports_reasoning(...)
    ):
        params.append(\"thinking\")
        params.append(\"reasoning_effort\")

    return params

The same branch that already knows the model is Claude 4.6 / 4.7 / reasoning-capable should also remove temperature from params, since those are exactly the models Anthropic has deprecated temperature on.

Suggested fix:

def get_supported_openai_params(self, model: str):
    params = [
        \"stream\", \"stop\", \"top_p\", \"max_tokens\", \"max_completion_tokens\",
        \"tools\", \"tool_choice\", \"extra_headers\", \"parallel_tool_calls\",
        \"response_format\", \"user\", \"web_search_options\", \"speed\",
        \"context_management\", \"cache_control\",
    ]

    is_reasoning_family = (
        \"claude-3-7-sonnet\" in model
        or AnthropicConfig._is_claude_4_6_model(model)
        or AnthropicConfig._is_claude_4_7_model(model)
        or supports_reasoning(
            model=model, custom_llm_provider=self.custom_llm_provider,
        )
    )

    if is_reasoning_family:
        params.extend([\"thinking\", \"reasoning_effort\"])
    else:
        params.append(\"temperature\")

    return params

That restores the contract: drop_params=True correctly strips temperature for Opus 4.7 and any future reasoning-family model, and callers don't have to sprinkle additional_drop_params=[\"temperature\"] throughout their codebases.

Happy to open a PR if useful — wanted to file the bug first so the team can confirm the intended behavior.

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