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]

fix(fireworks_ai): move top-level thinking into extra_body on the text completion path

mateo-berrib3729c50b058
diff --git a/litellm/llms/fireworks_ai/completion/transformation.py b/litellm/llms/fireworks_ai/completion/transformation.py
index 594080beaab..f03baaddaf6 100644
--- a/litellm/llms/fireworks_ai/completion/transformation.py
+++ b/litellm/llms/fireworks_ai/completion/transformation.py
@@ -66,7 +66,9 @@ class FireworksAITextCompletionConfig(FireworksAIMixin, BaseTextCompletionConfig
effort_body: Final = self._translate_chat_template_kwargs(moved_body, optional_params, model)
final_body: Final = self._translate_guided_into_extra_body(effort_body, optional_params)
base: Final = { # mutable-ok: JSON request body
- k: v for k, v in optional_params.items() if k not in ("extra_body", "response_format", "reasoning_effort")
+ k: v
+ for k, v in optional_params.items()
+ if k not in ("extra_body", "response_format", "reasoning_effort", "thinking")
}
if final_body:
base["extra_body"] = final_body
@@ -92,7 +94,7 @@ class FireworksAITextCompletionConfig(FireworksAIMixin, BaseTextCompletionConfig
extra_body: Mapping[str, object], optional_params: Mapping[str, object]
) -> dict: # mutable-ok: JSON request body
moved: Final = dict(extra_body) # mutable-ok: JSON request body
- for key in ("response_format", "reasoning_effort"):
+ for key in ("response_format", "reasoning_effort", "thinking"):
value = optional_params.get(key)
if value is None:
continue
diff --git a/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py b/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
index 78186846fbb..9fe76d142ce 100644
--- a/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
+++ b/tests/test_litellm/llms/fireworks_ai/completion/test_fireworks_ai_text_completion_transformation.py
@@ -93,6 +93,16 @@ def test_map_extra_body_params_top_level_reasoning_effort_moves_into_extra_body(
_REASONING_MODEL,
)
assert result == {"extra_body": {"reasoning_effort": "high"}}
+
+
+def test_map_extra_body_params_top_level_thinking_moves_into_extra_body():
+ config = FireworksAITextCompletionConfig()
+ thinking = {"type": "enabled", "budget_tokens": 1024}
+ result = config.map_extra_body_params(
+ {"thinking": thinking, "max_tokens": 300},
+ _REASONING_MODEL,
+ )
+ assert result == {"max_tokens": 300, "extra_body": {"thinking": thinking}}
assert "reasoning_effort" not in {
k for k in result if k != "extra_body"
}