From 4ff251e6b1ae6e2bf89424af8c06a453ded64e9b Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 21 Sep 2026 22:37:13 +0000 Subject: [PATCH] fix(xai): accept max_completion_tokens as a supported param Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../llms/xai/test_xai_chat_transformation.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_litellm/llms/xai/test_xai_chat_transformation.py b/tests/test_litellm/llms/xai/test_xai_chat_transformation.py index 3fd666e4f50..0a9e3234f12 100644 --- a/tests/test_litellm/llms/xai/test_xai_chat_transformation.py +++ b/tests/test_litellm/llms/xai/test_xai_chat_transformation.py @@ -13,6 +13,7 @@ from litellm.types.utils import ( ModelResponse, Usage, ) +from litellm.utils import get_optional_params class TestXAIReasoningTokenFolding: @@ -309,3 +310,15 @@ class TestXAIReportedCost: 0.0, 0.0037756, ) + + +class TestXAIMaxCompletionTokens: + def test_max_completion_tokens_is_accepted_and_mapped_to_max_tokens(self): + result = get_optional_params( + model="grok-4.20-beta", + custom_llm_provider="xai", + max_completion_tokens=64, + ) + + assert result["max_tokens"] == 64 + assert "max_completion_tokens" not in result