Get started with xAI
Intelligent, fast, and cost-effective models across code, text, voice, image, and video.
curl https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-build-0.1",
"input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}'Models
Grok Build 0.1
New
Our coding model — trained specifically for agentic coding workflows. Use Grok Build for code.
Context256k tokens
Input$1.00 / 1M tokens
Output$2.00 / 1M tokens
Grok 4.3
For everything except code, audio, image, and video. The most intelligent and fastest model we’ve built.
Voice API
Real-time conversations, speech-to-text, and text-to-speech.
Agent$3.00 / hour
TTS$15.00 / 1M chars
STT (Batch)$0.10 / hour
STT (Streaming)$0.20 / hour
Jump straight in
Try code, text, voice, image, and video models below
import os
from xai_sdk import Client
from xai_sdk.chat import user
client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(model="grok-build-0.1")
chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))
print(chat.sample().content)Responses API
Agentic coding with Grok Build on the API—refactor, debug, and build in your own tools.
- Agentic coding
- IDE & tool integrations
- Early access
- - / 1M input tokens
- - / 1M output tokens