Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
11 changes: 9 additions & 2 deletions litellm/llms/base_llm/chat/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Tuple,
Type,
Union,
cast,
)

import httpx
Expand Down Expand Up @@ -124,7 +123,15 @@ def update_optional_params_with_thinking_tokens(self, non_default_params: dict,
if is_thinking_enabled and (
"max_tokens" not in non_default_params and "max_completion_tokens" not in non_default_params
):
thinking_token_budget = cast(dict, optional_params["thinking"]).get("budget_tokens", None)
# `is_thinking_enabled` is True when `reasoning_effort` is set OR
# when `thinking` is set. Providers that pass `reasoning_effort`
# through natively (e.g. Databricks-Gemini-3+, Databricks-GPT-5)
# never populate an Anthropic-style `thinking` block, so guard
# against that case here.
thinking = optional_params.get("thinking")
if not isinstance(thinking, dict):
return
thinking_token_budget = thinking.get("budget_tokens", None)
if thinking_token_budget is not None:
optional_params["max_tokens"] = thinking_token_budget + DEFAULT_MAX_TOKENS

Expand Down
24 changes: 22 additions & 2 deletions litellm/llms/databricks/chat/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ def get_supported_openai_params(self, model: Optional[str] = None) -> list:
"thinking",
]

@staticmethod
def _databricks_model_uses_anthropic_thinking_param(model: str) -> bool:
"""
Per Databricks docs, Claude and Gemini 2.5 endpoints accept the
Anthropic-style `thinking={"type":"enabled","budget_tokens":N}` payload
and do NOT accept OpenAI's top-level `reasoning_effort`. Gemini 3+ and
GPT-5/GPT-OSS accept `reasoning_effort` natively and need no
translation.
"""
from litellm.utils import _supports_factory

normalized = model.lower().replace(".", "-")
return _supports_factory(
model=normalized,
custom_llm_provider="databricks",
key="supports_anthropic_thinking_payload",
)

def convert_anthropic_tool_to_databricks_tool(
self, tool: Optional[AllAnthropicToolsValues]
) -> Optional[DatabricksTool]:
Expand Down Expand Up @@ -371,20 +389,22 @@ def map_openai_params(
"response_format", None
) # unsupported for claude models - if json_schema -> convert to tool call

if "reasoning_effort" in non_default_params and "claude" in model:
if "reasoning_effort" in non_default_params and self._databricks_model_uses_anthropic_thinking_param(model):
reasoning_effort_value = non_default_params.get("reasoning_effort")
mapped_thinking = AnthropicConfig._map_reasoning_effort(
reasoning_effort=reasoning_effort_value,
model=model,
custom_llm_provider="databricks",
llm_provider="databricks",
)
is_claude = "claude" in model.lower()
if mapped_thinking is None:
optional_params.pop("thinking", None)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
optional_params.pop("output_config", None)
else:
optional_params["thinking"] = mapped_thinking
if AnthropicConfig._is_adaptive_thinking_model(model, "databricks"):
# output_config + adaptive thinking is an Anthropic-only feature.
if is_claude and AnthropicConfig._is_adaptive_thinking_model(model, "databricks"):
mapped_effort: Optional[str] = None
if isinstance(reasoning_effort_value, str):
mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get(reasoning_effort_value)
Expand Down
10 changes: 10 additions & 0 deletions litellm/model_prices_and_context_window_backup.json
Original file line number Diff line number Diff line change
Expand Up @@ -13339,6 +13339,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-haiku-4-5": {
Expand All @@ -13358,6 +13359,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4": {
Expand All @@ -13377,6 +13379,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-1": {
Expand All @@ -13396,6 +13399,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-5": {
Expand All @@ -13415,6 +13419,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true,
"supports_output_config": true
},
Expand All @@ -13435,6 +13440,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-1": {
Expand All @@ -13454,6 +13460,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-5": {
Expand All @@ -13473,6 +13480,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-flash": {
Expand All @@ -13490,6 +13498,7 @@
"output_dbu_cost_per_token": 3.5714e-05,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-pro": {
Expand All @@ -13507,6 +13516,7 @@
"output_dbu_cost_per_token": 0.000142857,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemma-3-12b": {
Expand Down
1 change: 1 addition & 0 deletions litellm/types/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class ProviderSpecificModelInfo(TypedDict, total=False):
supports_max_reasoning_effort: Optional[bool]
supports_output_config: Optional[bool]
supports_image_size: Optional[bool]
supports_anthropic_thinking_payload: Optional[bool]
bedrock_output_config_effort_ceiling: Optional[Literal["low", "medium", "high", "max", "xhigh"]]
bedrock_converse_supports_strict_tools: Optional[bool]

Expand Down
1 change: 1 addition & 0 deletions litellm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5513,6 +5513,7 @@ def _get_model_info_helper(
supports_reasoning=_model_info.get("supports_reasoning", None),
supports_adaptive_thinking=_model_info.get("supports_adaptive_thinking", None),
supports_mid_conversation_system=_model_info.get("supports_mid_conversation_system", None),
supports_anthropic_thinking_payload=_model_info.get("supports_anthropic_thinking_payload", None),
supports_none_reasoning_effort=_model_info.get("supports_none_reasoning_effort", None),
supports_minimal_reasoning_effort=_model_info.get("supports_minimal_reasoning_effort", None),
supports_low_reasoning_effort=_model_info.get("supports_low_reasoning_effort", None),
Expand Down
10 changes: 10 additions & 0 deletions model_prices_and_context_window.json
Original file line number Diff line number Diff line change
Expand Up @@ -13339,6 +13339,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-haiku-4-5": {
Expand All @@ -13358,6 +13359,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4": {
Expand All @@ -13377,6 +13379,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-1": {
Expand All @@ -13396,6 +13399,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-opus-4-5": {
Expand All @@ -13415,6 +13419,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true,
"supports_output_config": true
},
Expand All @@ -13435,6 +13440,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-1": {
Expand All @@ -13454,6 +13460,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-claude-sonnet-4-5": {
Expand All @@ -13473,6 +13480,7 @@
"supports_assistant_prefill": true,
"supports_function_calling": true,
"supports_reasoning": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-flash": {
Expand All @@ -13490,6 +13498,7 @@
"output_dbu_cost_per_token": 3.5714e-05,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemini-2-5-pro": {
Expand All @@ -13507,6 +13516,7 @@
"output_dbu_cost_per_token": 0.000142857,
"source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
"supports_function_calling": true,
"supports_anthropic_thinking_payload": true,
"supports_tool_choice": true
},
"databricks/databricks-gemma-3-12b": {
Expand Down
Loading
Loading