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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(fireworks_ai): strip `thinking_blocks` from chat messages before Fireworks API call (#27881)
milan-berri6274b4c2174f
diff --git a/litellm/llms/fireworks_ai/chat/transformation.py b/litellm/llms/fireworks_ai/chat/transformation.pyindex ed6d167a118..eaf01c5fe18 100644--- a/litellm/llms/fireworks_ai/chat/transformation.py+++ b/litellm/llms/fireworks_ai/chat/transformation.py@@ -241,10 +241,13 @@ class FireworksAIConfig(OpenAIGPTConfig):disable_add_transform_inline_image_block=disable_add_transform_inline_image_block,)filter_value_from_dict(cast(dict, message), "cache_control")- # Remove fields not permitted by FireworksAI that may cause:- # "Not permitted, field: 'messages[n].provider_specific_fields'"- if isinstance(message, dict) and "provider_specific_fields" in message:- cast(dict, message).pop("provider_specific_fields", None)+ # Remove fields not permitted by FireworksAI (additionalProperties: false+ # on their ChatMessage schema) that may cause:+ # "Extra inputs are not permitted, field: 'messages[n].<field>'"+ if isinstance(message, dict):+ m = cast(dict, message)+ m.pop("provider_specific_fields", None)+ m.pop("thinking_blocks", None)return messagesdiff --git a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.pyindex 323443b2e15..279f16a3675 100644--- a/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py+++ b/tests/test_litellm/llms/fireworks_ai/chat/test_fireworks_ai_chat_transformation.py@@ -232,3 +232,23 @@ def test_transform_messages_helper_removes_provider_specific_fields():)for msg in out:assert "provider_specific_fields" not in msg+++def test_transform_messages_helper_strips_thinking_blocks():+ """thinking_blocks must not be forwarded to Fireworks chat completions."""+ config = FireworksAIConfig()+ messages = [+ {"role": "user", "content": "Translate a poem."},+ {+ "role": "assistant",+ "content": "I can help.",+ "thinking_blocks": [+ {"type": "thinking", "thinking": "internal", "signature": ""}+ ],+ },+ ]+ out = config._transform_messages_helper(+ messages, model="accounts/fireworks/models/glm-5p1", litellm_params={}+ )+ assert "thinking_blocks" not in out[1]+ assert out[1]["content"] == "I can help."