Get started with SpaceXAI
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-4.5",
"input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}'Models
Grok 4.5
New
Our flagship model for code and everything else: agentic tool calling, minimal hallucinations, configurable reasoning.
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-4.5")
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