Overview | xAI Docs

Get started with xAI

Build with Grok, the AI model designed to deliver truthful, insightful answers.

Models

We offer a range of models supporting multiple use cases and modalities.

Grok 4.20

The most truth-seeking large language model in the world.

Context- tokens
Input- / 1M tokens
Output- / 1M tokens
View model

Voice API

Capable of real-time conversation, generation and transcription.

ModesAgent, TTS & STT
Realtime$3.00 / hour
TTS$4.20 / 1M characters

Imagine API

Turn ideas into reality with our image and video generation models.

ModesGeneration & editing
Image- / image
Video- / second

Jump straight in

We've prepared some simple examples for you to try.

import os
from xai_sdk import Client
from xai_sdk.chat import user, system

client = Client(
    api_key=os.getenv("XAI_API_KEY"),
)

chat = client.chat.create(model="grok-4.20-reasoning")
chat.append(system("You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy."))
chat.append(user("What is the meaning of life, the universe, and everything?"))
response = chat.sample()

print(response)

Responses API

Generate text, have conversations, use tools, and build AI-powered applications.

Generate text
Multi-turn chat
Function calling
- / 1M input tokens
- / 1M output tokens