
API / SDK SpaceXSI (xAI)
xAI API
xAI's (now SpaceXSI) OpenAI-compatible API for Grok text, image, video and voice models, with Python and TypeScript SDKs.
What it is
The xAI API (called the SpaceXSI API in newer docs) serves Grok models at api.x.ai through Responses, Chat Completions, Images, Videos, Voice, Files, Batches and Models endpoints, and states compatibility with the OpenAI REST API. Server-side tools add web search, X search, code execution and collections search. Official SDKs exist for Python (gRPC-based) and TypeScript, and the docs also show the OpenAI SDKs and the Vercel AI SDK provider.
What it's useful for
Switching an existing OpenAI SDK integration to Grok by changing the base URL, or generating images and videos from a backend.
Key features
- Responses and Chat Completions endpoints, compatible with the OpenAI REST API
- Image and video generation and editing endpoints (Grok Imagine)
- Voice API for speech-to-speech, speech-to-text and text-to-speech
- Server-side Web Search, X Search, code execution and remote MCP tools
- Batch API at 20% off standard rates for Grok 4.x models
- Official xai-sdk (Python) and TypeScript SDKs, Apache-2.0
How to use it
Before you start
- console.x.ai account with credits
- API key (XAI_API_KEY)
pip install xai-sdknpm install ai @ai-sdk/xai zodpip install openaiCommands are copied from the official documentation. Check the docs for the latest version before running them.
Limitations to know
- Usage is prepaid: the account must be loaded with credits before making requests
- Server-side tools are billed per call on top of token costs
- Not every model accepts Batch API requests
Website tech stack
- Hosting & CDN
- Cloudflare
- Framework
- Next.js
- Analytics
- Google Analytics, Google Tag Manager
Detected on x.ai on 25 Nov 2026. This describes the public website only; the product itself may use different technology.
Alternatives
Cohere's API for Command chat models, Embed and Rerank, with official Python, TypeScript, Java and Go SDKs and free trial keys.
Anthropic's REST API for Claude models, with official SDKs in Python, TypeScript, Go, Java, C#, PHP and Ruby.
OpenAI's developer API for GPT, image, audio and embedding models, with official SDKs in several languages.
Mistral AI's pay-as-you-go API for chat, code completion, OCR, embeddings, audio and agents, with Python and TypeScript SDKs.
MCP servers for this
Browserbase's hosted MCP server that lets agents drive cloud browsers with natural-language Stagehand actions.
Google Chrome team's MCP server and CLI that let coding agents control, debug and profile a live Chrome browser.
Docker Desktop's MCP Toolkit and Catalog that run MCP servers in containers and connect them to clients through one gateway.
Skills for this
Anthropic skill that guides Claude through designing, building and evaluating MCP servers in TypeScript or Python.
Related resources
Cerebras' cloud API for very fast inference on open-weight models, with an OpenAI-compatible endpoint and per-token pricing.
Cognition's autonomous software engineering agent that works in a cloud VM and opens pull requests.
Open-source sandboxes for AI agents: isolated Firecracker microVMs you start and control from a Python or JavaScript SDK.
Z.ai's GLM model family (GLM-5.3, GLM-5.3-Flash): open-weight MoE language models with a 1M-token context, API and chat app.