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(groq/chat/transformation.py): fix groq response_format transformation (#7565)
Krish Dholakiace97e7e05491
diff --git a/litellm/llms/groq/chat/transformation.py b/litellm/llms/groq/chat/transformation.pyindex 000ec87b2a3..5b24f7d1124 100644--- a/litellm/llms/groq/chat/transformation.py+++ b/litellm/llms/groq/chat/transformation.py@@ -150,7 +150,9 @@ class GroqChatConfig(OpenAIGPTConfig):optional_params["tools"] = [_tool]optional_params["tool_choice"] = _tool_choiceoptional_params["json_mode"] = True- non_default_params.pop("response_format", None)+ non_default_params.pop(+ "response_format", None+ ) # only remove if it's a json_schema - handled via using groq's tool calling params.return super().map_openai_params(non_default_params, optional_params, model, drop_params)diff --git a/tests/llm_translation/test_optional_params.py b/tests/llm_translation/test_optional_params.pyindex 41b9d0d6866..5d6390e34cd 100644--- a/tests/llm_translation/test_optional_params.py+++ b/tests/llm_translation/test_optional_params.py@@ -1019,3 +1019,14 @@ def test_gemini_frequency_penalty():)assert optional_params is not Noneassert "frequency_penalty" in optional_params+++def test_groq_response_format_json_schema():+ optional_params = get_optional_params(+ model="llama-3.1-70b-versatile",+ custom_llm_provider="groq",+ response_format={"type": "json_object"},+ )+ assert optional_params is not None+ assert "response_format" in optional_params+ assert optional_params["response_format"]["type"] == "json_object"