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
feat(azure-ai): add Grok 4.3 model metadata (#27932)
Emerson Gomes4ea5749642de
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 59b90773d39..b288269b0a2 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -9609,6 +9609,24 @@"supports_tool_choice": true,"supports_web_search": true},+ "azure_ai/grok-4.3": {+ "cache_read_input_token_cost": 2e-07,+ "input_cost_per_token": 1.25e-06,+ "litellm_provider": "azure_ai",+ "max_input_tokens": 200000,+ "max_output_tokens": 200000,+ "max_tokens": 200000,+ "mode": "chat",+ "output_cost_per_token": 2.5e-06,+ "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-grok-4-3-on-microsoft-foundry-latest-generation-agentic-capabilities/4517096",+ "supports_function_calling": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_tool_choice": true,+ "supports_vision": true,+ "supports_web_search": true+ },"azure_ai/grok-4-fast-non-reasoning": {"input_cost_per_token": 2e-07,"output_cost_per_token": 5e-07,diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex 0377996021c..4892e3b348c 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -316,6 +316,9 @@ class LiteLLMCompletionResponsesConfig:"custom_llm_provider": custom_llm_provider,"extra_headers": extra_headers,}+ if not tools:+ litellm_completion_request.pop("tool_choice", None)+ litellm_completion_request.pop("tools", None)# Responses API `Completed` events require usage, we pass `stream_options` to litellm.completion to include usageif stream is True:diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 59b90773d39..b288269b0a2 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -9609,6 +9609,24 @@"supports_tool_choice": true,"supports_web_search": true},+ "azure_ai/grok-4.3": {+ "cache_read_input_token_cost": 2e-07,+ "input_cost_per_token": 1.25e-06,+ "litellm_provider": "azure_ai",+ "max_input_tokens": 200000,+ "max_output_tokens": 200000,+ "max_tokens": 200000,+ "mode": "chat",+ "output_cost_per_token": 2.5e-06,+ "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-grok-4-3-on-microsoft-foundry-latest-generation-agentic-capabilities/4517096",+ "supports_function_calling": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_tool_choice": true,+ "supports_vision": true,+ "supports_web_search": true+ },"azure_ai/grok-4-fast-non-reasoning": {"input_cost_per_token": 2e-07,"output_cost_per_token": 5e-07,diff --git a/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py b/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.pyindex 2e75039139c..a541ab2b3c6 100644--- a/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py+++ b/tests/test_litellm/llms/azure_ai/chat/test_azure_ai_transformation.py@@ -1,7 +1,7 @@import jsonimport osimport sys-from unittest.mock import AsyncMock, MagicMock, patch+from unittest.mock import MagicMock, patchimport pytest@@ -110,15 +110,19 @@ def test_azure_ai_grok_stop_parameter_handling():config = AzureAIStudioConfig()# Test Grok model detection- assert config._supports_stop_reason("grok-4-fast") == False- assert config._supports_stop_reason("grok-4") == False- assert config._supports_stop_reason("grok-3-mini") == False- assert config._supports_stop_reason("grok-code-fast") == False- assert config._supports_stop_reason("gpt-4") == True+ assert config._supports_stop_reason("grok-4-fast") is False+ assert config._supports_stop_reason("grok-4.3") is False+ assert config._supports_stop_reason("grok-4") is False+ assert config._supports_stop_reason("grok-3-mini") is False+ assert config._supports_stop_reason("grok-code-fast") is False+ assert config._supports_stop_reason("gpt-4") is True# Test supported parameters for Grok models- grok_params = config.get_supported_openai_params("grok-4-fast")- assert "stop" not in grok_params, "Grok models should not support stop parameter"+ for model in ("grok-4-fast", "grok-4.3"):+ grok_params = config.get_supported_openai_params(model)+ assert (+ "stop" not in grok_params+ ), "Grok models should not support stop parameter"# Test supported parameters for non-Grok modelsgpt_params = config.get_supported_openai_params("gpt-4")diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.pyindex d3aa8eddf45..fef8c2d1349 100644--- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py+++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py@@ -982,6 +982,18 @@ class TestFunctionCallTransformation:assert result["extra_headers"] == {"X-Test-Header": "test-value"}+ def test_drops_tool_choice_when_no_tools(self):+ """Chat completions providers reject tool_choice when no tools are present."""+ result = LiteLLMCompletionResponsesConfig.transform_responses_api_request_to_chat_completion_request(+ model="azure_ai/grok-4.3",+ input="who are you?",+ responses_api_request={"tool_choice": "auto", "tools": []},+ custom_llm_provider="azure_ai",+ )++ assert "tool_choice" not in result+ assert "tools" not in result+def test_function_call_without_call_id_fallback_to_id(self):"""Test that function_call items can use 'id' field when 'call_id' is missing"""function_call_item = {diff --git a/tests/test_litellm/test_azure_ai_grok_4_3_model_metadata.py b/tests/test_litellm/test_azure_ai_grok_4_3_model_metadata.pynew file mode 100644index 00000000000..22cabfbb0eb--- /dev/null+++ b/tests/test_litellm/test_azure_ai_grok_4_3_model_metadata.py@@ -0,0 +1,83 @@+import json+from pathlib import Path++import pytest++import litellm+from litellm import get_model_info+from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider++AZURE_AI_GROK_4_3_MODEL = "azure_ai/grok-4.3"+AZURE_AI_GROK_4_3_SOURCE = "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-grok-4-3-on-microsoft-foundry-latest-generation-agentic-capabilities/4517096"+++def _load_model_cost(path: Path) -> dict:+ with open(path) as f:+ return json.load(f)++[email protected](autouse=True)+def reload_model_costs():+ original_model_cost = litellm.model_cost+ json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json"+ litellm.model_cost = _load_model_cost(json_path)+ get_model_info.cache_clear()+ yield+ litellm.model_cost = original_model_cost+ get_model_info.cache_clear()+++def test_azure_ai_grok_4_3_model_info():+ json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json"+ model_cost = _load_model_cost(json_path)++ info = model_cost.get(AZURE_AI_GROK_4_3_MODEL)+ assert (+ info is not None+ ), f"{AZURE_AI_GROK_4_3_MODEL} not found in model_prices_and_context_window.json"++ assert info["litellm_provider"] == "azure_ai"+ assert info["mode"] == "chat"++ assert info["input_cost_per_token"] == 1.25e-06+ assert info["output_cost_per_token"] == 2.5e-06+ assert info["cache_read_input_token_cost"] == 2e-07++ assert info["max_input_tokens"] == 200000+ assert info["max_output_tokens"] == 200000+ assert info["max_tokens"] == 200000+ assert info["source"] == AZURE_AI_GROK_4_3_SOURCE++ assert info["supports_function_calling"] is True+ assert info["supports_prompt_caching"] is True+ assert info["supports_reasoning"] is True+ assert info["supports_response_schema"] is True+ assert info["supports_tool_choice"] is True+ assert info["supports_vision"] is True+ assert info["supports_web_search"] is True++ routed_model, provider, _, _ = get_llm_provider(model=AZURE_AI_GROK_4_3_MODEL)+ assert routed_model == "grok-4.3"+ assert provider == "azure_ai"++ resolved_info = get_model_info(model="grok-4.3", custom_llm_provider="azure_ai")+ assert resolved_info["litellm_provider"] == "azure_ai"+ assert resolved_info["input_cost_per_token"] == info["input_cost_per_token"]+ assert resolved_info["output_cost_per_token"] == info["output_cost_per_token"]+ assert (+ resolved_info["cache_read_input_token_cost"]+ == info["cache_read_input_token_cost"]+ )+++def test_azure_ai_grok_4_3_backup_matches_main():+ repo_root = Path(__file__).parents[2]+ main_path = repo_root / "model_prices_and_context_window.json"+ backup_path = repo_root / "litellm" / "model_prices_and_context_window_backup.json"++ main_cost = _load_model_cost(main_path)+ backup_cost = _load_model_cost(backup_path)++ assert backup_cost.get(AZURE_AI_GROK_4_3_MODEL) == main_cost.get(+ AZURE_AI_GROK_4_3_MODEL+ )