xAI logo
xAI

Grok-4

xAI's latest flagship model with real-time internet search capabilities and timely knowledge updates

Category Text Model ID grok-4
Context Length128K tokens
Model TypeLarge Language Model (LLM)
Special CapabilitiesReal-time Internet Search

Pricing & Specs

💰 Pricing

Input$5 / M tokens
Output$15 / M tokens

⚙️ Specs

Context Length128K tokens
Model TypeLarge Language Model (LLM)
Special CapabilitiesReal-time Internet Search
Training Cutoff DateReal-time updates

API Examples

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://api.xairouter.com/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model="grok-4",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

cURL

curl https://api.xairouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "grok-4",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'