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 - PR1] Add xAI grok-3 models to LiteLLM (#9920)
Ishaan Jaff2d6ad534bcfb
diff --git a/docs/my-website/docs/providers/xai.md b/docs/my-website/docs/providers/xai.mdindex a3c56d56199..a951b6bb9e6 100644--- a/docs/my-website/docs/providers/xai.md+++ b/docs/my-website/docs/providers/xai.md@@ -18,13 +18,14 @@ os.environ['XAI_API_KEY']```## Sample Usage-```python++```python showLineNumbers title="LiteLLM python sdk usage - Non-streaming"from litellm import completionimport osos.environ['XAI_API_KEY'] = ""response = completion(- model="xai/grok-2-latest",+ model="xai/grok-3-mini-beta",messages=[{"role": "user",@@ -45,13 +46,14 @@ print(response)```## Sample Usage - Streaming-```python++```python showLineNumbers title="LiteLLM python sdk usage - Streaming"from litellm import completionimport osos.environ['XAI_API_KEY'] = ""response = completion(- model="xai/grok-2-latest",+ model="xai/grok-3-mini-beta",messages=[{"role": "user",@@ -75,7 +77,8 @@ for chunk in response:```## Sample Usage - Vision-```python++```python showLineNumbers title="LiteLLM python sdk usage - Vision"import osfrom litellm import completion@@ -110,7 +113,7 @@ Here's how to call a XAI model with the LiteLLM Proxy Server1. Modify the config.yaml- ```yaml+ ```yaml showLineNumbersmodel_list:- model_name: my-modellitellm_params:@@ -131,7 +134,7 @@ Here's how to call a XAI model with the LiteLLM Proxy Server<TabItem value="openai" label="OpenAI Python v1.0.0+">- ```python+ ```python showLineNumbersimport openaiclient = openai.OpenAI(api_key="sk-1234", # pass litellm proxy key, if you're using virtual keysdiff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex e7485f73786..08e9a7791b9 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -3097,6 +3097,84 @@"supports_vision": true,"supports_tool_choice": true},+ "xai/grok-3-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000003,+ "output_cost_per_token": 0.000015,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-fast-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000005,+ "output_cost_per_token": 0.000025,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-fast-latest": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000005,+ "output_cost_per_token": 0.000025,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000003,+ "output_cost_per_token": 0.0000005,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-fast-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000006,+ "output_cost_per_token": 0.000004,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-fast-latest": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000006,+ "output_cost_per_token": 0.000004,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },"xai/grok-vision-beta": {"max_tokens": 8192,"max_input_tokens": 8192,diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex e7485f73786..08e9a7791b9 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -3097,6 +3097,84 @@"supports_vision": true,"supports_tool_choice": true},+ "xai/grok-3-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000003,+ "output_cost_per_token": 0.000015,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-fast-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000005,+ "output_cost_per_token": 0.000025,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-fast-latest": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.000005,+ "output_cost_per_token": 0.000025,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000003,+ "output_cost_per_token": 0.0000005,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-fast-beta": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000006,+ "output_cost_per_token": 0.000004,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },+ "xai/grok-3-mini-fast-latest": {+ "max_tokens": 131072,+ "max_input_tokens": 131072,+ "max_output_tokens": 131072,+ "input_cost_per_token": 0.0000006,+ "output_cost_per_token": 0.000004,+ "litellm_provider": "xai",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_tool_choice": true,+ "supports_response_schema": false,+ "source": "https://x.ai/api#pricing"+ },"xai/grok-vision-beta": {"max_tokens": 8192,"max_input_tokens": 8192,