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 PR #32786 (databricks gemini reasoning_effort) into internal_staging, resolving conflicts

milanf5e178634c7c
diff --cc litellm/llms/databricks/chat/transformation.py
index 9c05899c719,8902f4cb061..0b595d15484
--- a/litellm/llms/databricks/chat/transformation.py
+++ b/litellm/llms/databricks/chat/transformation.py
@@@ -376,15 -393,16 +397,17 @@@ class DatabricksConfig(DatabricksBase,
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)
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):
++ 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)
diff --cc litellm/utils.py
index 174bed09396,5f7985b84fd..699d255f9c3
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@@ -5512,7 -5472,7 +5512,8 @@@ 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),
+ 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 tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
index 00f3e7a6faf,59872e9962f..91a6f0683e8
--- a/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
+++ b/tests/test_litellm/llms/databricks/chat/test_databricks_chat_transformation.py
@@@ -418,8 -430,124 +430,131 @@@ def test_transform_request_keeps_parall
assert len([m for m in result if m.get("role") == "assistant"]) == 1
+def test_databricks_config_probes_capabilities_under_databricks_namespace():
+ """Inherited AnthropicConfig capability probes read ``self.custom_llm_provider``;
+ without this override they probed the ``anthropic`` cost-map namespace and
+ ignored the exact ``databricks/databricks-claude-*`` entries."""
+ 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():
+ """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():
+ 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():
+ 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():
+ 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():
+ """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():
+ """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():
+ """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():
+ """`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():
+ """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():
+ """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():
+ """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