Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions litellm/llms/anthropic/chat/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,9 +1238,13 @@ def transform_request(
output_config = optional_params.get("output_config")
if output_config and isinstance(output_config, dict):
effort = output_config.get("effort")
if effort and effort not in ["high", "medium", "low"]:
if effort and effort not in ["high", "medium", "low", "max"]:
raise ValueError(
f"Invalid effort value: {effort}. Must be one of: 'high', 'medium', 'low'"
f"Invalid effort value: {effort}. Must be one of: 'high', 'medium', 'low', 'max'"
)
if effort == "max" and not self._is_claude_opus_4_6(model):
raise ValueError(
f"effort='max' is only supported by Claude Opus 4.6. Got model: {model}"
)
data["output_config"] = output_config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,41 @@ def test_effort_with_claude_opus_45():
assert result["model"] == "claude-opus-4-5-20251101"


def test_effort_validation_with_opus_46():
"""Test that all four effort levels are accepted for Claude Opus 4.6."""
config = AnthropicConfig()

messages = [{"role": "user", "content": "Test"}]

for effort in ["high", "medium", "low", "max"]:
optional_params = {"output_config": {"effort": effort}}
result = config.transform_request(
model="claude-opus-4-6-20260205",
messages=messages,
optional_params=optional_params,
litellm_params={},
headers={}
)
assert result["output_config"]["effort"] == effort


def test_max_effort_rejected_for_opus_45():
"""Test that effort='max' is rejected when using Claude Opus 4.5."""
config = AnthropicConfig()

messages = [{"role": "user", "content": "Test"}]

with pytest.raises(ValueError, match="effort='max' is only supported by Claude Opus 4.6"):
optional_params = {"output_config": {"effort": "max"}}
config.transform_request(
model="claude-opus-4-5-20251101",
messages=messages,
optional_params=optional_params,
litellm_params={},
headers={}
)


def test_effort_with_other_features():
"""Test effort works alongside other features (thinking, tools)."""
config = AnthropicConfig()
Expand Down
Loading