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 origin/main into litellm_perf_convert_model_response_frozensets

Ryan Crabbebb24ebebd9d5
diff --cc litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
index 0f7779e8b5c,a6e502a32b3..a2b03d0eb6d
--- a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
+++ b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
@@@ -550,10 -546,15 +550,13 @@@ def convert_to_model_response_object(
message = litellm.Message(content=json_mode_content_str)
finish_reason = "stop"
if message is None:
- provider_specific_fields = {
- f: choice["message"][f]
- for f in choice["message"].keys() - _MESSAGE_FIELDS
- }
+ # Preserve provider_specific_fields if already present
+ # in the response (e.g. from proxy passthrough)
+ provider_specific_fields = dict(
+ choice["message"].get("provider_specific_fields", None) or {}
+ )
- message_keys = Message.model_fields.keys()
- for field in choice["message"].keys():
- if field not in message_keys:
- provider_specific_fields[field] = choice["message"][field]
++ for f in choice["message"].keys() - _MESSAGE_FIELDS:
++ provider_specific_fields[f] = choice["message"][f]
# Handle reasoning models that display `reasoning_content` within `content`
reasoning_content, content = _extract_reasoning_content(