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: Extra inputs are not permitted, field: 'messages[2].provider_specific_fields'

Sameer Kankute3765d88809bb
diff --git a/litellm/llms/fireworks_ai/chat/transformation.py b/litellm/llms/fireworks_ai/chat/transformation.py
index 86bcd94450f..f6ea9c57f77 100644
--- a/litellm/llms/fireworks_ai/chat/transformation.py
+++ b/litellm/llms/fireworks_ai/chat/transformation.py
@@ -236,6 +236,10 @@ 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:
+ message.pop("provider_specific_fields", None)
return messages
diff --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.py
index 43c1c413747..8006ffdff1f 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
@@ -108,3 +108,32 @@ def test_get_supported_openai_params_reasoning_effort():
"fireworks_ai/accounts/fireworks/models/llama-v3-70b-instruct"
)
assert "reasoning_effort" not in unsupported_params
+
+
+def test_transform_messages_helper_removes_provider_specific_fields():
+ """
+ Test that _transform_messages_helper removes provider_specific_fields from messages.
+ """
+ config = FireworksAIConfig()
+ # Simulated messages, as dicts, including provider_specific_fields
+ messages = [
+ {
+ "role": "user",
+ "content": "Hello!",
+ "provider_specific_fields": {"extra": "should be removed"},
+ },
+ {
+ "role": "assistant",
+ "content": "Hi there!",
+ "provider_specific_fields": {"more": "remove this"},
+ },
+ {
+ "role": "user",
+ "content": "How are you?",
+ # no provider_specific_fields
+ }
+ ]
+ # Call helper
+ out = config._transform_messages_helper(messages, model="fireworks/test", litellm_params={})
+ for msg in out:
+ assert "provider_specific_fields" not in msg