xAI
ModelAPI for xAI's Grok models for text, code, images, video and voice
- Price
- Pay per use
- Access
- API key
About
The xAI API, now run by SpaceXAI, serves Grok 4.7 for chat, coding and agents, plus Grok Imagine for images and video and a voice API. It has built-in web and X search tools. A US-only endpoint costs 10% more.
What you can do with it
- Generate text and code with Grok 4.7 through the Responses API
- Generate and edit images and videos with Grok Imagine
- Ground answers in live results with built-in web and X search
Get started
- Sign up at console.x.ai and add credits
- Create an API key
- Set XAI_API_KEY in your environment
Example
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]}"
}'Details
- Hosting
- Hosted service
- Available in
- Worldwide
- Official SDKs
- Python
- MCP server
- None