Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge litellm_internal_staging into devin/1784568628-databricks-gemini-reasoning-effort

milan4b157ed5a493
diff --cc litellm/llms/databricks/chat/transformation.py
index 76e2a5169d2,8a625569cfa..4da0d850fe7
--- a/litellm/llms/databricks/chat/transformation.py
+++ b/litellm/llms/databricks/chat/transformation.py
@@@ -269,27 -256,7 +257,25 @@@ class DatabricksConfig(DatabricksBase,
"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(".", "-")
++ normalized: Final = 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]:
+ def convert_anthropic_tool_to_databricks_tool(self, tool: AllAnthropicToolsValues | None) -> DatabricksTool | None:
if tool is None:
return None
@@@ -390,30 -357,21 +376,29 @@@
"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_value: Final = non_default_params.get("reasoning_effort")
+ mapped_thinking: Final = AnthropicConfig._map_reasoning_effort(
reasoning_effort=reasoning_effort_value,
model=model,
custom_llm_provider="databricks",
llm_provider="databricks",
)
- is_claude = "claude" in model.lower()
++ is_claude: Final = "claude" in model.lower()
if mapped_thinking is None:
optional_params.pop("thinking", None)
optional_params.pop("output_config", None)
else:
- is_adaptive = mapped_thinking.get("type") == "adaptive"
++ is_adaptive: Final = mapped_thinking.get("type") == "adaptive"
+ if is_adaptive and not is_claude:
+ raise BadRequestError(
+ message=(f"Adaptive thinking is only supported on Databricks Claude models, not {model!r}."),
+ model=model,
+ llm_provider="databricks",
+ )
optional_params["thinking"] = mapped_thinking
- # output_config + adaptive thinking is an Anthropic-only feature.
- if AnthropicConfig._is_adaptive_thinking_model(model, "databricks"):
+ if is_claude and is_adaptive:
- mapped_effort: Optional[str] = None
+ mapped_effort: str | None = None
if isinstance(reasoning_effort_value, str):
mapped_effort = REASONING_EFFORT_TO_OUTPUT_CONFIG_EFFORT.get(reasoning_effort_value)
if mapped_effort is None:
diff --cc litellm/model_prices_and_context_window_backup.json
index 0aeb8c19fb1,3af7d9e5019..96e98eec8e6
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@@ -13480,9 -14735,27 +14742,28 @@@
"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-6": {
+ "input_cost_per_token": 2.9999900000000002e-06,
+ "input_dbu_cost_per_token": 4.2857e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 64000,
+ "max_tokens": 64000,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_assistant_prefill": true,
+ "supports_function_calling": true,
+ "supports_reasoning": true,
+ "supports_tool_choice": true
+ },
"databricks/databricks-gemini-2-5-flash": {
"input_cost_per_token": 3.0001999999999996e-07,
"input_dbu_cost_per_token": 4.285999999999999e-06,
@@@ -13516,9 -14788,76 +14797,77 @@@
"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-gemini-3-1-flash-lite": {
+ "input_cost_per_token": 3.1248e-07,
+ "input_dbu_cost_per_token": 4.464e-06,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.87502e-06,
+ "output_dbu_cost_per_token": 2.6786e-05,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-1-pro": {
+ "input_cost_per_token": 2.49998e-06,
+ "input_dbu_cost_per_token": 3.5714e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-flash": {
+ "input_cost_per_token": 6.2503e-07,
+ "input_dbu_cost_per_token": 8.929e-06,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 3.74997e-06,
+ "output_dbu_cost_per_token": 5.3571e-05,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-pro": {
+ "input_cost_per_token": 2.49998e-06,
+ "input_dbu_cost_per_token": 3.5714e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
"databricks/databricks-gemma-3-12b": {
"input_cost_per_token": 1.5000999999999998e-07,
"input_dbu_cost_per_token": 2.1429999999999996e-06,
diff --cc litellm/types/utils.py
index c6e2ff13260,67eae2b4f21..1abafb15ebd
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@@ -125,36 -135,38 +135,39 @@@ class ProviderField(TypedDict)
class ProviderSpecificModelInfo(TypedDict, total=False):
- supports_system_messages: Optional[bool]
- supports_response_schema: Optional[bool]
- supports_vision: Optional[bool]
- supports_function_calling: Optional[bool]
- supports_tool_choice: Optional[bool]
- supports_assistant_prefill: Optional[bool]
- supports_prompt_caching: Optional[bool]
- supports_computer_use: Optional[bool]
- supports_audio_input: Optional[bool]
- supports_embedding_image_input: Optional[bool]
- supports_audio_output: Optional[bool]
- supports_pdf_input: Optional[bool]
- supports_native_streaming: Optional[bool]
- supports_native_structured_output: Optional[bool]
- supports_parallel_function_calling: Optional[bool]
- supports_web_search: Optional[bool]
- supports_reasoning: Optional[bool]
- supports_adaptive_thinking: Optional[bool]
- supports_mid_conversation_system: Optional[bool]
- supports_url_context: Optional[bool]
- supports_none_reasoning_effort: Optional[bool]
- supports_minimal_reasoning_effort: Optional[bool]
- supports_low_reasoning_effort: Optional[bool]
- supports_xhigh_reasoning_effort: Optional[bool]
- 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]
+ supports_system_messages: bool | None
+ supports_response_schema: bool | None
+ supports_vision: bool | None
+ supports_function_calling: bool | None
+ supports_tool_choice: bool | None
+ supports_assistant_prefill: bool | None
+ supports_prompt_caching: bool | None
+ supports_prompt_cache_breakpoint: ReadOnly[bool | None]
+ supports_computer_use: bool | None
+ supports_audio_input: bool | None
+ supports_embedding_image_input: bool | None
+ supports_audio_output: bool | None
+ supports_pdf_input: bool | None
+ supports_native_streaming: bool | None
+ supports_native_structured_output: bool | None
+ supports_parallel_function_calling: bool | None
+ supports_web_search: bool | None
+ supports_reasoning: bool | None
+ supports_adaptive_thinking: bool | None
+ thinking_always_on: ReadOnly[bool | None]
+ supports_tool_search: bool | None
+ supports_mid_conversation_system: bool | None
+ supports_url_context: bool | None
+ supports_none_reasoning_effort: bool | None
+ supports_minimal_reasoning_effort: bool | None
+ supports_low_reasoning_effort: bool | None
+ supports_xhigh_reasoning_effort: bool | None
+ supports_max_reasoning_effort: bool | None
+ supports_output_config: bool | None
+ supports_image_size: bool | None
++ supports_anthropic_thinking_payload: bool | None
+ bedrock_output_config_effort_ceiling: Literal["low", "medium", "high", "max", "xhigh"] | None
+ bedrock_converse_supports_strict_tools: bool | None
class SearchContextCostPerQuery(TypedDict, total=False):
diff --cc litellm/utils.py
index 699d255f9c3,e5ce7157e77..f1c674586a8
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@@ -5512,8 -5753,9 +5753,10 @@@ def _get_model_info_helper
supports_url_context=_model_info.get("supports_url_context", None),
supports_reasoning=_model_info.get("supports_reasoning", None),
supports_adaptive_thinking=_model_info.get("supports_adaptive_thinking", None),
+ thinking_always_on=_model_info.get("thinking_always_on", None),
+ supports_tool_search=_model_info.get("supports_tool_search", 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),
diff --cc model_prices_and_context_window.json
index d22ca0e3ee1,3af7d9e5019..96e98eec8e6
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@@ -13480,9 -14735,27 +14742,28 @@@
"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-6": {
+ "input_cost_per_token": 2.9999900000000002e-06,
+ "input_dbu_cost_per_token": 4.2857e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 64000,
+ "max_tokens": 64000,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_assistant_prefill": true,
+ "supports_function_calling": true,
+ "supports_reasoning": true,
+ "supports_tool_choice": true
+ },
"databricks/databricks-gemini-2-5-flash": {
"input_cost_per_token": 3.0001999999999996e-07,
"input_dbu_cost_per_token": 4.285999999999999e-06,
@@@ -13516,9 -14788,76 +14797,77 @@@
"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-gemini-3-1-flash-lite": {
+ "input_cost_per_token": 3.1248e-07,
+ "input_dbu_cost_per_token": 4.464e-06,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.87502e-06,
+ "output_dbu_cost_per_token": 2.6786e-05,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-1-pro": {
+ "input_cost_per_token": 2.49998e-06,
+ "input_dbu_cost_per_token": 3.5714e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-flash": {
+ "input_cost_per_token": 6.2503e-07,
+ "input_dbu_cost_per_token": 8.929e-06,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 3.74997e-06,
+ "output_dbu_cost_per_token": 5.3571e-05,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
+ "databricks/databricks-gemini-3-pro": {
+ "input_cost_per_token": 2.49998e-06,
+ "input_dbu_cost_per_token": 3.5714e-05,
+ "litellm_provider": "databricks",
+ "max_input_tokens": 1048576,
+ "max_output_tokens": 65536,
+ "max_tokens": 65536,
+ "metadata": {
+ "notes": "Input/output cost per token is dbu cost * $0.070. Number provided for reference, '*_dbu_cost_per_token' used in actual calculation."
+ },
+ "mode": "chat",
+ "output_cost_per_token": 1.5000020000000002e-05,
+ "output_dbu_cost_per_token": 0.000214286,
+ "source": "https://www.databricks.com/product/pricing/proprietary-foundation-model-serving",
+ "supports_function_calling": true,
+ "supports_tool_choice": true
+ },
"databricks/databricks-gemma-3-12b": {
"input_cost_per_token": 1.5000999999999998e-07,
"input_dbu_cost_per_token": 2.1429999999999996e-06,
diff --cc tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
index c00f5a5d1a8,41fb2589655..217f5def7df
--- a/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
+++ b/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
@@@ -5,15 -3,8 +3,14 @@@ import jso
import pytest
from fastapi.testclient import TestClient
- sys.path.insert(0, os.path.abspath("../../../../..")) # Adds the parent directory to the system path
from unittest.mock import MagicMock, patch
+import litellm
+from litellm.constants import (
+ DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET,
+ DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET,
+ DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET,
+)
from litellm.llms.databricks.chat.transformation import (
DatabricksChatResponseIterator,
DatabricksConfig,
@@@ -437,142 -422,74 +434,215 @@@ def test_databricks_config_probes_capab
assert DatabricksConfig().custom_llm_provider == "databricks"
+# ---------------------------------------------------------------------------
+# reasoning_effort translation
+#
+# Databricks foundation-model endpoints take reasoning controls via different
+# payload shapes depending on the underlying model family:
+#
+# Claude: Anthropic-style `thinking={"type":"enabled","budget_tokens":N}`
+# Gemini 2.5: Same Anthropic-style `thinking` payload as Claude
+# (per docs.databricks.com/.../query-reason-models)
+# Gemini 3+: Native OpenAI-style top-level `reasoning_effort`
+# GPT-5/GPT-OSS: Native OpenAI-style top-level `reasoning_effort`
+#
+# LiteLLM should translate `reasoning_effort` into the right shape for the
+# first two families and pass it through unchanged for the latter two.
+# ---------------------------------------------------------------------------
+
+
+def _map_reasoning_effort(model: str, reasoning_effort, **extra_non_default):
+ """Run map_openai_params with reasoning_effort + optional extras."""
+ non_default = {"reasoning_effort": reasoning_effort}
+ non_default.update(extra_non_default)
+ return DatabricksConfig().map_openai_params(
+ non_default_params=non_default,
+ optional_params={},
+ model=model,
+ drop_params=False,
+ )
+
+
+def test_claude_translates_reasoning_effort_to_thinking(_use_local_model_cost_map):
+ """Regression: Claude path must still translate to Anthropic-style thinking."""
+ params = _map_reasoning_effort("databricks-claude-3-7-sonnet", "low")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_5_low_translates_to_thinking_budget(_use_local_model_cost_map):
+ params = _map_reasoning_effort("databricks-gemini-2-5-flash", "low")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_5_medium_translates_to_thinking_budget(_use_local_model_cost_map):
+ params = _map_reasoning_effort("databricks-gemini-2-5-flash", "medium")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_MEDIUM_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_5_high_translates_to_thinking_budget(_use_local_model_cost_map):
+ params = _map_reasoning_effort("databricks-gemini-2-5-flash", "high")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_5_pro_translates_to_thinking_budget(_use_local_model_cost_map):
+ """Cover the gemini-2-5-pro endpoint too, not just flash."""
+ params = _map_reasoning_effort("databricks-gemini-2-5-pro", "high")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_HIGH_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_5_with_dot_notation_translates(_use_local_model_cost_map):
+ """A user passing the upstream Google-style `gemini-2.5-...` form should
+ still trigger the Anthropic-thinking translation, not pass through."""
+ params = _map_reasoning_effort("databricks-gemini-2.5-flash", "low")
+ assert params.get("thinking") == {
+ "type": "enabled",
+ "budget_tokens": DEFAULT_REASONING_EFFORT_LOW_THINKING_BUDGET,
+ }
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_2_0_does_not_match(_use_local_model_cost_map):
+ """Guard against over-matching: `gemini-2-0` (hypothetical or future) is
+ NOT a Gemini 2.5 endpoint and must not get the thinking translation."""
+ params = _map_reasoning_effort("databricks-gemini-2-0-flash", "low")
+ assert "thinking" not in params
+ assert params.get("reasoning_effort") == "low"
+
+
+def test_gemini_2_5_none_drops_thinking_and_reasoning_effort(_use_local_model_cost_map):
+ """`reasoning_effort='none'` mirrors the Claude behavior: no thinking emitted."""
+ params = _map_reasoning_effort("databricks-gemini-2-5-flash", "none")
+ assert "thinking" not in params
+ assert "reasoning_effort" not in params
+
+
+def test_gemini_3_passes_reasoning_effort_through(_use_local_model_cost_map):
+ """Databricks-Gemini-3+ accepts reasoning_effort natively — do not translate."""
+ params = _map_reasoning_effort("databricks-gemini-3-1-pro", "low")
+ assert params.get("reasoning_effort") == "low"
+ assert "thinking" not in params
+
+
+def test_gpt_5_passes_reasoning_effort_through(_use_local_model_cost_map):
+ """Databricks-GPT-5 family accepts reasoning_effort natively."""
+ params = _map_reasoning_effort("databricks-gpt-5-1", "low")
+ assert params.get("reasoning_effort") == "low"
+ assert "thinking" not in params
+
+
+def test_gpt_oss_passes_reasoning_effort_through(_use_local_model_cost_map):
+ """Databricks-GPT-OSS accepts reasoning_effort natively."""
+ params = _map_reasoning_effort("databricks-gpt-oss-120b", "high")
+ assert params.get("reasoning_effort") == "high"
+ assert "thinking" not in params
+
+
+def test_non_claude_adaptive_thinking_flag_is_rejected(monkeypatch, _use_local_model_cost_map):
+ """Adaptive thinking + output_config is Claude-only; a non-Claude model that
+ resolves to an adaptive payload would send Databricks' Gemini endpoint a shape
+ it can't parse, so the translation must fail loudly instead of passing it through."""
+ fake_model = "databricks-gemini-2-5-adaptive-probe"
+ monkeypatch.setitem(
+ litellm.model_cost,
+ fake_model,
+ {
+ "litellm_provider": "databricks",
+ "supports_anthropic_thinking_payload": True,
+ "supports_adaptive_thinking": True,
+ },
+ )
+ with pytest.raises(litellm.exceptions.BadRequestError):
+ _map_reasoning_effort(fake_model, "high")
++
++
+ def _streaming_chunk(usage=None, choices=None):
+ base = {
+ "id": "chatcmpl-test",
+ "created": 1234567890,
+ "model": "databricks-claude-sonnet-5",
+ "choices": [{"delta": {"content": "hi"}}] if choices is None else choices,
+ }
+ return base if usage is None else {**base, "usage": usage}
+
+
+ @pytest.mark.parametrize(
+ "cache_read, cache_creation, expected_cached, expected_written",
+ [
+ (12002, 0, 12002, 0),
+ (0, 12002, 0, 12002),
+ ],
+ ids=["warm_cache_read", "cold_cache_write"],
+ )
+ def test_chunk_parser_surfaces_prompt_cache_usage(cache_read, cache_creation, expected_cached, expected_written):
+ iterator = DatabricksChatResponseIterator(streaming_response=None, sync_stream=True)
+
+ result = iterator.chunk_parser(
+ _streaming_chunk(
+ usage={
+ "prompt_tokens": 12011,
+ "completion_tokens": 8,
+ "total_tokens": 12019,
+ "cache_read_input_tokens": cache_read,
+ "cache_creation_input_tokens": cache_creation,
+ }
+ )
+ )
+
+ assert result.usage is not None
+ assert result.usage.prompt_tokens == 12011
+ assert result.usage.completion_tokens == 8
+ assert result.usage.prompt_tokens_details is not None
+ assert result.usage.prompt_tokens_details.cached_tokens == expected_cached
+ assert result.usage._cache_creation_input_tokens == expected_written
+
+
+ def test_chunk_parser_surfaces_usage_only_final_chunk():
+ """stream_options={"include_usage": True} emits a trailing chunk whose choices
+ list is empty; usage must still reach the caller."""
+ iterator = DatabricksChatResponseIterator(streaming_response=None, sync_stream=True)
+
+ result = iterator.chunk_parser(
+ _streaming_chunk(
+ usage={
+ "prompt_tokens": 100,
+ "completion_tokens": 5,
+ "total_tokens": 105,
+ "cache_read_input_tokens": 90,
+ },
+ choices=[],
+ )
+ )
+
+ assert result.choices == []
+ assert result.usage is not None
+ assert result.usage.prompt_tokens_details.cached_tokens == 90
+
+
+ def test_chunk_parser_without_usage_still_parses_content():
+ iterator = DatabricksChatResponseIterator(streaming_response=None, sync_stream=True)
+
+ result = iterator.chunk_parser(_streaming_chunk())
+
+ assert result.id == "chatcmpl-test"
+ assert result.model == "databricks-claude-sonnet-5"
+ assert result.choices[0]["delta"]["content"] == "hi"
diff --cc tests/test_litellm/test_utils.py
index 9b36a84bec8,d655eb96a02..56a384a260c
--- a/tests/test_litellm/test_utils.py
+++ b/tests/test_litellm/test_utils.py
@@@ -862,7 -993,7 +993,8 @@@ def test_aaamodel_prices_and_context_wi
"supports_xhigh_reasoning_effort": {"type": "boolean"},
"supports_max_reasoning_effort": {"type": "boolean"},
"supports_adaptive_thinking": {"type": "boolean"},
+ "supports_anthropic_thinking_payload": {"type": "boolean"},
+ "thinking_always_on": {"type": "boolean"},
"supports_mid_conversation_system": {"type": "boolean"},
"supports_sampling_params": {"type": "boolean"},
"supports_output_config": {"type": "boolean"},