What is xAI API?
The xAI API, branded SpaceXAI API on its site, gives developers access to Grok models through one endpoint. You create an account at console.x.ai, generate an API key, set the base URL to https://api.x.ai/v1, and call a model such as grok-4.7. It works with the Python xai_sdk, the Vercel AI SDK, the OpenAI SDK, or plain curl.
With the API you can generate text and code, create and edit images and video through the Imagine models, build speech-to-speech voice agents, run text-to-speech and speech-to-text, and search the web and X in real time. Every account includes a Playground for testing models before writing integration code. Usage is billed per token, with prepaid credits and enterprise invoicing available.
Key features
- Grok 4.7 flagship model with 500k context window
- Image generation and editing via Imagine models
- Video generation at 480p, 720p and 1080p
- Realtime speech-to-speech, text-to-speech and speech-to-text
- Real-time web and X search
- OpenAI-compatible endpoint and Python, TypeScript SDKs
Who is it for
- software developers
- AI engineers building agents
- product teams adding AI features
- enterprises needing custom rate limits and SSO
Pros and cons
- Works with existing OpenAI-compatible SDKs
- Playground included with every account, no integration needed to test
- Pay-per-token pricing with no minimum subscription for API use
- Full pricing for every model is only listed in the docs, not on the homepage
- Enterprise features such as SSO and dedicated data plane require contacting sales
xAI API pricing
| Plan | Price | Includes |
|---|---|---|
| grok-4.7 (Text input) | 2 USD | per 1M input tokens, 500k context window |
| grok-4.7 (Output) | 6 USD | per 1M output tokens |
| grok-imagine-image | 0.002 USD | per image input, 1K/2K output $0.02 per image |
| grok-imagine-video-1.5-lite | 0.02 USD | per second of video, 480p to 1080p, from |
| Text to Speech | 15 USD | per 1M characters |
| Speech to Speech | 0.08 USD | per minute |
Prices copied from xAI API pricing, checked October 12, 2026. Currency as shown by the vendor; taxes may apply.
Is xAI API free?
There is a free trial. Playground is included with every Console account for testing models and generating images and video. API usage is billed per token, with no free API tier mentioned.
xAI API alternatives
| Tool | Price from | Free plan | Category |
|---|---|---|---|
| 0,10 USD | ? | APIs & models | |
| not listed | ? | APIs & models | |
| 5 USD | trial | APIs & models | |
| not listed | ? | APIs & models | |
| not listed | yes | APIs & models | |
| not listed | yes | APIs & models |
FAQ
What is xAI API used for?
Developer API for Grok models: text, code, image, video, voice, and real-time web search, billed per token.
Is xAI API free?
There is a free trial. Playground is included with every Console account for testing models and generating images and video. API usage is billed per token, with no free API tier mentioned.
How much does xAI API cost?
The cheapest paid plan is 0.002 USD (vendor pricing, October 12, 2026).
What are the best xAI API alternatives?
Closest alternatives: OpenAI Platform, DeepSeek API, Cerebras, Blackbox AI, Cline.
Data checked October 12, 2026 on the vendor website (x.ai).
