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(cerebras): add max_retries and extra_headers to get_supported_openai_params (#36601)
Deepanshu Lulla75c4565dde1e
diff --git a/litellm/llms/cerebras/chat.py b/litellm/llms/cerebras/chat.pyindex 8827b0afd87..c3aa26ade35 100644--- a/litellm/llms/cerebras/chat.py+++ b/litellm/llms/cerebras/chat.py@@ -68,6 +68,8 @@ class CerebrasConfig(OpenAIGPTConfig):"tool_choice","tools","user",+ "max_retries",+ "extra_headers",]# Only add reasoning_effort for models that support itdiff --git a/tests/test_litellm/llms/cerebras/__init__.py b/tests/test_litellm/llms/cerebras/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py b/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.pynew file mode 100644index 00000000000..09718b1e6e0--- /dev/null+++ b/tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py@@ -0,0 +1,61 @@+from litellm.llms.cerebras.chat import CerebrasConfig+++def test_max_retries_in_supported_params() -> None:+ config = CerebrasConfig()+ params = config.get_supported_openai_params(model="llama-3.3-70b")+ assert "max_retries" in params, (+ f"max_retries must be in CerebrasConfig.get_supported_openai_params(); got: {params!r}"+ )+++def test_extra_headers_in_supported_params() -> None:+ config = CerebrasConfig()+ params = config.get_supported_openai_params(model="llama-3.3-70b")+ assert "extra_headers" in params, (+ f"extra_headers must be in CerebrasConfig.get_supported_openai_params(); got: {params!r}"+ )+++def test_core_openai_params_still_supported() -> None:+ config = CerebrasConfig()+ params = config.get_supported_openai_params(model="llama-3.3-70b")+ for expected in (+ "max_tokens",+ "max_completion_tokens",+ "response_format",+ "seed",+ "stop",+ "stream",+ "temperature",+ "top_p",+ "tool_choice",+ "tools",+ "user",+ ):+ assert expected in params, f"{expected!r} unexpectedly missing from Cerebras supported params: {params!r}"+++def test_map_openai_params_preserves_max_retries() -> None:+ config = CerebrasConfig()+ result = config.map_openai_params(+ non_default_params={"max_retries": 0, "temperature": 0.7},+ optional_params={},+ model="llama-3.3-70b",+ drop_params=False,+ )+ assert result.get("max_retries") == 0, f"map_openai_params must preserve max_retries=0; got: {result!r}"+ assert result.get("temperature") == 0.7+++def test_map_openai_params_preserves_max_retries_zero_falsy() -> None:+ config = CerebrasConfig()+ result = config.map_openai_params(+ non_default_params={"max_retries": 0},+ optional_params={},+ model="llama-3.3-70b",+ drop_params=False,+ )+ assert "max_retries" in result and result["max_retries"] == 0, (+ f"max_retries=0 (falsy) must not be silently omitted; got: {result!r}"+ )