The Grok API is xAI's developer access to Grok: you sign up at console.x.ai, load the account with credits, create an API key and send requests to Grok 4.7, the flagship model for code and chat. As of Nov 2026 xAI's docs list Grok 4.7 at $2.00 per 1M input tokens and $6.00 per 1M output tokens, with separate Imagine APIs for images and video and a Voice API for speech.
This is the developer side of Grok. If you just want to chat with it, my guide to using the Grok app is the better place to start, and what you get for free covers the no-cost options. One small thing that confuses people: xAI's developer docs currently carry the name SpaceXSI Docs at the top. Same docs, so don't be thrown if that's what you land on.
Who the Grok API is for
You don't need the API to use Grok. You need it when you want Grok working inside something of your own: a website tool, an internal app, an automation, or a product a developer is building for you. The docs show three ways to call it: xAI's own SDK, a plain curl request, and OpenAI's SDK pointed at xAI's address, api.x.ai/v1. That last one matters if your developer already knows OpenAI's tools.
Your first request in five steps
Here's the quickstart in words, as of Nov 2026:
- Sign up for an account at console.x.ai, then load it with credits. The docs are clear that credits come before usage.
- Create an API key on the API Keys page.
- Save the key as an environment variable called XAI_API_KEY, or add it to a .env file in your project, so it never sits inside code you share.
- Install an SDK. The quickstart offers xAI's Python SDK, the OpenAI SDK for Python or JavaScript, and the AI SDK package for JavaScript.
- Send a first prompt to the model grok-4.7, with your key sent as a Bearer token. The quickstart's own sample asks Grok to fix a small function and explain the bug.
Set your key in a Mac or Linux terminal
export XAI_API_KEY="your_api_key"
Which Grok model does which job
xAI's models page keeps this simple. There are dedicated models and APIs for audio, image and video, and for everything else, including code, the page says to use Grok 4.7, which it calls the most capable model xAI has built. It describes Grok 4.7 as the flagship for agentic tool calling, minimal hallucinations and configurable reasoning, with a context window of 500k tokens and a knowledge cut-off of May 2026.
| Job | Model or API | Price as of Nov 2026 |
|---|---|---|
| Code and chat | Grok 4.7 | $2.00 per 1M input tokens, $6.00 per 1M output tokens |
| Images | Grok Imagine Image 2.0 | Starting at $0.02 per image, at 1K or 2K |
| Video | Grok Imagine Video 1.5 | Starting at $0.02 per second, at 480p, 720p or 1080p |
| Voice conversations | Grok Voice API, speech to speech | $0.08 per minute |
| Reading text aloud | Grok Voice API, text to speech | $15.00 per 1M characters |
| Transcription | Grok Voice API, speech to text | $0.10 per hour batch, $0.20 per hour streaming |
Model names come with aliases. The plain name points to the latest stable version, a name ending in latest gets the newest features, and a dated name never changes, which suits workflows that need consistent answers. If you want ideas for the image side, I've collected Grok Imagine prompts that work.
Fresh facts need search switched on
This is the catch most people miss. The models page says Grok has no knowledge of current events or data beyond what was in its training data. To bring in live information you have to enable the server-side Web Search or X Search tools on your request. If you're building something that answers questions about prices, news or competitors, the model on its own will be working from a May 2026 snapshot.
Spend tiers, rate limits and the 429 error
Every xAI API team has per-model limits on requests per second and tokens per minute. Those limits grow with your tier, and your tier is set by cumulative spend on the API since January 1, 2026:
| Tier | Spend threshold as of Nov 2026 |
|---|---|
| Tier 0 | $0 (the default) |
| Tier 1 | $50 |
| Tier 2 | $250 |
| Tier 3 | $1,000 |
| Tier 4 | $5,000 |
| Enterprise | Available on request |
Two details are worth knowing. Tiers move up automatically and never downgrade: once you qualify, you stay there. And qualification is based on revenue xAI has received, through prepaid credit purchases or fulfilled invoices. These tiers cover text, embedding and voice models; for higher Imagine limits, the docs say to contact xAI's sales team. You can see your current tier and per-model limits on the Models page in the xAI Console.
Want AI doing the heavy lifting in your marketing?
I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.
Every token counts toward the tokens per minute limit: prompt tokens (text, image and audio), completion tokens, reasoning tokens and cached prompt tokens. Cached tokens are billed at a reduced rate, but they still use up your limit.
Go over a limit and the API returns a 429 Too Many Requests error. The docs recommend exponential backoff, which in plain words means wait and try again, doubling the wait each time. Their own example waits one second, then two, then four, then eight, and gives up after five attempts. If you need more room, you can spend more, request an increase through the xAI Console without extra spend, or email sales for enterprise capacity.
Extras in the docs worth a look
- Files and Collections, so Grok can answer from your own documents.
- A Batch API for jobs that don't need an instant answer, though not every model accepts batch requests.
- Prompt Caching, Remote MCP Tools and Regional Endpoints.
- A migration guide for the Imagine image quality retirement on November 2, 2026, if you use that model.
Is the Grok API worth it for a small business?
I'd test Grok 4.7 on one real task next to whatever you use now, with the same prompt and your own data, before you commit any budget. Skip the Imagine and Voice APIs until the text side has earned its place. Remember to switch on search if answers need to be current, and remember credits are loaded before you use them, so start small. Prices and limits here are xAI's own figures as of Nov 2026; check xAI's models page for the latest.
If you're weighing up which AI provider to build on, that's the kind of AI enablement I help with. I run AI training and workshops for teams, and help businesses with AI enablement and workflow automation, so the busywork runs itself and people get time back. Most of that work is with SaaS marketing teams and small businesses. Here's how we can work together.
Frequently asked questions
How do I get a Grok API key?
Sign up at console.x.ai, load the account with credits, then create a key on the API Keys page and save it as an environment variable called XAI_API_KEY.
How much does the Grok API cost?
As of Nov 2026, xAI's docs list Grok 4.7 at $2.00 per 1M input tokens and $6.00 per 1M output tokens. Voice, image and video APIs are priced separately.
Can I use the OpenAI SDK with the Grok API?
Yes. xAI's own examples include OpenAI's SDK pointed at the address api.x.ai/v1 with your xAI key.
What does a 429 error mean on the Grok API?
It means you've gone over a rate limit. The docs recommend exponential backoff: wait, retry, and double the wait each time.
Does the Grok API know about current events?
Not on its own. The docs say Grok has no knowledge beyond its training data, so you need to enable the Web Search or X Search tools for live information.


