
by xAI
The Grok API gives developers access to Grok models for text, code, reasoning, image and video generation, voice, and live web and X search. It is for developers and companies building apps and agents on Grok.
APIUsage-based
Step 1: Sign up at console.x.ai and add credits to your account.
Step 2: Create an API key on the API Keys page and set it as XAI_API_KEY.
Step 3: Install an SDK: the xAI Python SDK, the OpenAI SDK, or the Vercel AI SDK provider.
Step 4: Set the base URL to https://api.x.ai/v1 and send a request to a Grok model such as grok-4.7.
Step 5: Add tools such as web search, X search or function calling as your app needs them.
Team admins on the enterprise API can enable Zero Data Retention in the Console, so prompts and outputs are not persisted.
Yes. The REST API is compatible with the OpenAI REST API, so you can use the OpenAI SDK with the base URL https://api.x.ai/v1.
Yes. Every Console account includes a free Playground for chatting with Grok and testing image and video generation before you buy.
No. The enterprise FAQ says business inputs and outputs are not used for training, though free credits may sometimes be offered in exchange for permission to train.
Grok Imagine APIThe Grok Imagine API generates, edits and restyles images and video through one API. It supports text-to-video and image-to-video, with clips up to 15 seconds.
Grok Voice APIGrok Voice API provides real-time speech-to-speech voice agents, text-to-speech and speech-to-text through one API. It supports tool calling, custom cloned voices and 25+ languages.
Grok DeepSearchGrok DeepSearch uses AI for AI research mode for searching online information and synthesizing multi-source answers.
E2BE2B gives every AI agent its own isolated cloud machine, a microVM sandbox where it can run code, browse and use tools. It runs in E2B's cloud or in your own AWS, GCP or Azure account.