mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
[Feat - PR1] Add xAI grok-3 models to LiteLLM (#9920)
* add xai/grok-3-mini-beta, xai/grok-3-beta * add grok-3-fast-latest models * supports_response_schema * fix pricing * docs xai
This commit is contained in:
parent
fc14931be9
commit
2d6ad534bc
3 changed files with 166 additions and 7 deletions
|
@ -18,13 +18,14 @@ os.environ['XAI_API_KEY']
|
|||
```
|
||||
|
||||
## Sample Usage
|
||||
```python
|
||||
|
||||
```python showLineNumbers title="LiteLLM python sdk usage - Non-streaming"
|
||||
from litellm import completion
|
||||
import os
|
||||
|
||||
os.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 completion
|
||||
import os
|
||||
|
||||
os.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 os
|
||||
from litellm import completion
|
||||
|
||||
|
@ -110,7 +113,7 @@ Here's how to call a XAI model with the LiteLLM Proxy Server
|
|||
|
||||
1. Modify the config.yaml
|
||||
|
||||
```yaml
|
||||
```yaml showLineNumbers
|
||||
model_list:
|
||||
- model_name: my-model
|
||||
litellm_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 showLineNumbers
|
||||
import openai
|
||||
client = openai.OpenAI(
|
||||
api_key="sk-1234", # pass litellm proxy key, if you're using virtual keys
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue