Voice API
Real-time conversations, speech-to-text, and text-to-speech.
- Agent
- $0.08 / min
- TTS
- $15.00 / 1M chars
- STT (Batch)
- $0.10 / hour
- STT (Streaming)
- $0.20 / hour
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.7",
"input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}'A flagship model for code and many other tasks: agent tool calling, extremely low hallucination, and configurable reasoning.
Real-time conversations, speech-to-text, and text-to-speech.
Turn ideas into reality with image and video generation.
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.7")
chat.append(user("Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"))
print(chat.sample().content)Agentic coding with Grok Build on the API—refactor, debug, and build in your own tools.