xAI: Grok 4

Model details

xAI: Grok 4

Model
x-ai/grok-4
Provider
openrouter
API
openai-completions
Base URL
https://openrouter.ai/api/v1
Input
text, image
Reasoning
Yes
Context window
256,000
Max tokens
4,096
Cost / million input
$3
Cost / million output
$15
Cost / million cache read
$0.75
Cost / million cache write
$0
Model config JSON
{
  "providers": {
    "openrouter": {
      "apiKey": "YOUR_API_KEY",
      "models": [
        {
          "id": "x-ai/grok-4",
          "name": "xAI: Grok 4",
          "reasoning": true,
          "input": [
            "text",
            "image"
          ],
          "contextWindow": 256000,
          "maxTokens": 4096,
          "cost": {
            "input": 3,
            "output": 15,
            "cacheRead": 0.75,
            "cacheWrite": 0
          }
        }
      ],
      "api": "openai-completions",
      "baseUrl": "https://openrouter.ai/api/v1"
    }
  }
}