Skip to content

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]

Feat: add support for Grok 4.1 Fast models (#16936)

Cesar Garcia1c65800f4a28
diff --git a/docs/my-website/docs/providers/xai.md b/docs/my-website/docs/providers/xai.md
index 49a3640991d..afeecc21528 100644
--- a/docs/my-website/docs/providers/xai.md
+++ b/docs/my-website/docs/providers/xai.md
@@ -11,6 +11,68 @@ https://docs.x.ai/docs
:::
+## Supported Models
+
+
+
+**Latest Release** - Grok 4.1 Fast: Optimized for high-performance agentic tool calling with 2M context and prompt caching.
+
+| Model | Context | Features |
+|-------|---------|----------|
+| `xai/grok-4-1-fast-reasoning` | 2M tokens | **Reasoning**, Function calling, Vision, Audio, Web search, Caching |
+| `xai/grok-4-1-fast-non-reasoning` | 2M tokens | Function calling, Vision, Audio, Web search, Caching |
+
+**When to use:**
+- ✅ **Reasoning model**: Complex analysis, planning, multi-step reasoning problems
+- ✅ **Non-reasoning model**: Simple queries, faster responses, lower token usage
+
+**Example:**
+```python
+from litellm import completion
+
+# With reasoning
+response = completion(
+ model="xai/grok-4-1-fast-reasoning",
+ messages=[{"role": "user", "content": "Analyze this problem step by step..."}]
+)
+
+# Without reasoning
+response = completion(
+ model="xai/grok-4-1-fast-non-reasoning",
+ messages=[{"role": "user", "content": "What's 2+2?"}]
+)
+```
+
+---
+
+### All Available Models
+
+| Model Family | Model | Context | Features |
+|--------------|-------|---------|----------|
+| **Grok 4.1** | `xai/grok-4-1-fast-reasoning` | 2M | **Reasoning**, Tools, Vision, Audio, Web search, Caching |
+| | `xai/grok-4-1-fast-non-reasoning` | 2M | Tools, Vision, Audio, Web search, Caching |
+| **Grok 4** | `xai/grok-4` | 256K | Tools, Web search |
+| | `xai/grok-4-0709` | 256K | Tools, Web search |
+| | `xai/grok-4-fast-reasoning` | 2M | **Reasoning**, Tools, Web search |
+| | `xai/grok-4-fast-non-reasoning` | 2M | Tools, Web search |
+| **Grok 3** | `xai/grok-3` | 131K | Tools, Web search |
+| | `xai/grok-3-mini` | 131K | Tools, Web search |
+| | `xai/grok-3-fast-beta` | 131K | Tools, Web search |
+| **Grok Code** | `xai/grok-code-fast` | 256K | **Reasoning**, Tools, Code generation, Caching |
+| **Grok 2** | `xai/grok-2` | 131K | Tools, **Vision** |
+| | `xai/grok-2-vision-latest` | 32K | Tools, **Vision** |
+
+**Features:**
+- **Reasoning** = Chain-of-thought reasoning with reasoning tokens
+- **Tools** = Function calling / Tool use
+- **Web search** = Live internet search
+- **Vision** = Image understanding
+- **Audio** = Audio input support
+- **Caching** = Prompt caching for cost savings
+- **Code generation** = Optimized for code tasks
+
+**Pricing:** See [xAI's pricing page](https://docs.x.ai/docs/models) for current rates.
+
## API Key
```python
# env variable
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 43c9c050308..fb3d4c91710 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -26179,6 +26179,104 @@
"supports_tool_choice": true,
"supports_web_search": true
},
+ "xai/grok-4-1-fast": {
+ "cache_read_input_token_cost": 0.05e-06,
+ "input_cost_per_token": 0.2e-06,
+ "input_cost_per_token_above_128k_tokens": 0.4e-06,
+ "litellm_provider": "xai",
+ "max_input_tokens": 2e6,
+ "max_output_tokens": 2e6,
+ "max_tokens": 2e6,
+ "mode": "chat",
+ "output_cost_per_token": 0.5e-06,
+ "output_cost_per_token_above_128k_tokens": 1e-06,
+ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
+ "supports_audio_input": true,
+ "supports_function_calling": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "xai/grok-4-1-fast-reasoning": {
+ "cache_read_input_token_cost": 0.05e-06,
+ "input_cost_per_token": 0.2e-06,
+ "input_cost_per_token_above_128k_tokens": 0.4e-06,
+ "litellm_provider": "xai",
+ "max_input_tokens": 2e6,
+ "max_output_tokens": 2e6,
+ "max_tokens": 2e6,
+ "mode": "chat",
+ "output_cost_per_token": 0.5e-06,
+ "output_cost_per_token_above_128k_tokens": 1e-06,
+ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
+ "supports_audio_input": true,
+ "supports_function_calling": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "xai/grok-4-1-fast-reasoning-latest": {
+ "cache_read_input_token_cost": 0.05e-06,
+ "input_cost_per_token": 0.2e-06,
+ "input_cost_per_token_above_128k_tokens": 0.4e-06,
+ "litellm_provider": "xai",
+ "max_input_tokens": 2e6,
+ "max_output_tokens": 2e6,
+ "max_tokens": 2e6,
+ "mode": "chat",
+ "output_cost_per_token": 0.5e-06,
+ "output_cost_per_token_above_128k_tokens": 1e-06,
+ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
+ "supports_audio_input": true,
+ "supports_function_calling": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "xai/grok-4-1-fast-non-reasoning": {
+ "cache_read_input_token_cost": 0.05e-06,
+ "input_cost_per_token": 0.2e-06,
+ "input_cost_per_token_above_128k_tokens": 0.4e-06,
+ "litellm_provider": "xai",
+ "max_input_tokens": 2e6,
+ "max_output_tokens": 2e6,
+ "max_tokens": 2e6,
+ "mode": "chat",
+ "output_cost_per_token": 0.5e-06,
+ "output_cost_per_token_above_128k_tokens": 1e-06,
+ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-non-reasoning",
+ "supports_audio_input": true,
+ "supports_function_calling": true,
+ "supports_response_schema": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "xai/grok-4-1-fast-non-reasoning-latest": {
+ "cache_read_input_token_cost": 0.05e-06,
+ "input_cost_per_token": 0.2e-06,
+ "input_cost_per_token_above_128k_tokens": 0.4e-06,
+ "litellm_provider": "xai",
+ "max_input_tokens": 2e6,
+ "max_output_tokens": 2e6,
+ "max_tokens": 2e6,
+ "mode": "chat",
+ "output_cost_per_token": 0.5e-06,
+ "output_cost_per_token_above_128k_tokens": 1e-06,
+ "source": "https://docs.x.ai/docs/models/grok-4-1-fast-non-reasoning",
+ "supports_audio_input": true,
+ "supports_function_calling": true,
+ "supports_response_schema": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
"xai/grok-beta": {
"input_cost_per_token": 5e-06,
"litellm_provider": "xai",