Grok API: Models, Rate Limits, Tools, and X Search
The xAI API gives you Grok 4.5 at a 500,000-token context window, a set of server-side tools including first-party search over X, and rate limits at the free tier that are frankly hard to believe. It speaks the OpenAI SDK, so moving an existing app over is usually a base URL and a model string.
This is what’s actually in it as of July 2026, including the one thing that will quietly change your bill.
Start here: the limits before you spend anything
Most API posts bury rate limits at the bottom as a caveat. With xAI they’re the headline, because Tier 0 — the default, at $0 cumulative spend — gets you this on grok-4.5:
- 150 requests per second
- 50 million tokens per minute
For comparison inside xAI’s own lineup, the older grok-4.3 starts at 37 RPS and 10M TPM at the same tier. Grok 4.5 gets roughly four times the throughput before you’ve paid anything.
Tiers unlock on cumulative spend since January 1, 2026 — $50 for Tier 1, $250 for Tier 2, $1,000 for Tier 3, $5,000 for Tier 4, Enterprise on request — and they scale to 500 RPS and 100M TPM at Tier 4. Two details worth knowing: tiers never downgrade once you qualify, and your per-second limit is derived from your per-minute budget (RPM ÷ 60), so you can’t burn a minute’s allowance in one burst. Exceeding either dimension returns a 429.
Everything counts toward TPM — prompt tokens, completion tokens, reasoning tokens, and cached prompt tokens, the last of which still count against the limit even though they bill at a reduced rate.
Practically, this means you can build and load-test something real on a Grok API key without a procurement conversation. That’s the pitch, and it’s a good one.
The models and what they cost
Grok 4.5 is the flagship and, per xAI’s own guidance, the answer for both code and chat — there’s no separate coding model to choose between. 500k context, configurable reasoning effort, agentic tool calling. It runs $2.00 per million input tokens and $6.00 per million output tokens.
Beyond text, the lineup splits by modality rather than by size:
| API | What it does | Rate |
|---|---|---|
| Voice | Real-time conversation agent | $3.00 / hour |
| Voice | Text to speech | $15.00 / 1M chars |
| Voice | Speech to text, batch | $0.10 / hour |
| Voice | Speech to text, streaming | $0.20 / hour |
| Imagine | Image generation and editing, 1K/2K | $0.02 / image |
| Imagine | Video, 480p/720p/1080p | $0.05 / second |
Image and video generation sit at a flat 5 RPS and 10 RPS respectively across all tiers — those don’t scale with spend, and increases go through sales rather than automatically.
Prices verified against xAI’s docs on July 22, 2026. Model pricing in this market moves faster than anything else on this page, so treat the numbers as a snapshot and check the console before you build a margin on them.
X Search is the part nobody else has
Every frontier API does web search now. X Search is the one capability with no equivalent at OpenAI, Anthropic, or Google, because it’s first-party access to the X corpus rather than a scrape.
It does keyword search, semantic search, user search, and thread fetch, and the parameters are more precise than the marketing suggests:
allowed_x_handles— restrict to a list of up to 20 handlesexcluded_x_handles— exclude up to 20 (mutually exclusive with the above)from_date/to_date— ISO8601 range, inclusiveenable_image_understanding— analyze images inside postsenable_video_understanding— analyze video inside posts, and this one is X Search only, not available on Web Search
from xai_sdk import Client
from xai_sdk.chat import user
from xai_sdk.tools import x_search
client = Client(api_key=os.getenv("XAI_API_KEY"))
chat = client.chat.create(
model="grok-4.5",
tools=[x_search(allowed_x_handles=["nasa"], enable_image_understanding=True)],
)
chat.append(user("What has NASA posted about the launch window?"))
If you’re building anything in social listening, market sentiment, breaking-news monitoring, or brand tracking, this is a genuine reason to pick xAI over a better-known API. Handle allowlists plus date ranges plus video understanding is a hard combination to assemble any other way.
The rest of the tool surface
Built-in tools run on xAI’s servers — you send the configuration, xAI executes and returns results with citations. Web Search, X Search, Code Interpreter, and Collections Search (over documents you’ve uploaded). Function calling covers your own logic, and there’s remote MCP support for pointing Grok at your own MCP server.
Tool requests bill on two axes: token usage and tool invocations. Since the model may chain several calls to answer one query, cost scales with question complexity rather than with prompt length — worth instrumenting early if you expose this to users.
The advanced surface is deeper than most people expect: prompt caching, a Batch API, deferred chat completions, context compaction, priority processing, websocket mode, and mTLS.
The billing trap
On May 15, 2026, xAI retired eight model slugs: grok-4-1-fast-reasoning, grok-4-1-fast-non-reasoning, grok-4-fast-reasoning, grok-4-fast-non-reasoning, grok-4-0709, grok-code-fast-1, grok-3, and grok-imagine-image-pro.
Here’s the part that matters: the slugs still resolve. Requests to a retired model silently redirect to grok-4.3 — reasoning models at low effort, non-reasoning at none. Nothing breaks. No error, no deprecation exception, no failed deploy.
You just get billed at grok-4.3 rates — $1.25 per 1M input and $2.50 per 1M output — instead of whatever your original model cost.
So if you have a service that’s been running since before May and nobody’s touched the model string, it is currently pointed somewhere you didn’t choose, at a price you didn’t pick, with a reasoning effort set by a redirect rule. Worth a grep. xAI’s own recommendation is to name the replacement explicitly, precisely so you control which reasoning effort you’re paying for.
The real-time caveat
Grok’s whole public identity is real-time information, so this catches people: through the API, Grok has no knowledge of current events beyond its training data unless you enable the search tools.
Grok 4.5’s knowledge cutoff is February 1, 2026. Web Search and X Search are opt-in, server-side tools you pass in the request. The consumer app has them on; your API call does not unless you say so.
Compatibility
The base URL is https://api.x.ai/v1, with a Responses API at /v1/responses. You have four reasonable paths in:
xai_sdk— the native Python SDK, with the fullest surface- The OpenAI SDK — point it at the xAI base URL; the docs ship a “Python (OpenAI)” tab beside nearly every example
- Vercel AI SDK — tools exposed as
xai.tools.xSearch()and friends - Any Responses-API-compatible SDK
xAI also publishes Grok through Amazon Bedrock, Google Cloud Vertex AI, Microsoft Foundry, and Databricks, which is often the shorter path if your compliance posture already covers one of those.
There’s one asymmetry to plan around: logprobs and top_logprobs are silently ignored on grok-4.20 and newer. Not an error — ignored. If you have an eval harness or a classifier reading token probabilities, it will quietly return nothing useful.
What the API doesn’t hand you
An API gives you a model. It does not give you the thing most people are actually trying to build.
If your goal is an assistant that works across someone’s tools, the model call is the small part. The rest is OAuth for every app you touch, token refresh, per-user credential storage, webhook receivers, retry and replay logic, deduplication, and an audit trail — and then the same again for the second integration. Teams routinely spend a quarter on that scaffolding before the interesting behavior ships.
Grok’s own product answers this in two shapes, both worth knowing before you build: connectors for reaching apps from a conversation, and Automations for running work unattended. Both are consumer-side, not API primitives — you can’t provision them for your users through api.x.ai.
Carly is the built version of that layer. Agents fire on events across 200+ integrations — a record changing, a form arriving, a file landing — with the auth, triggers, and retries already handled, and each agent has its own name and email address so people delegate to it by writing to it. Anything with a public API that isn’t already native connects with your own key. Free, unlimited Zapier-style workflows; AI agents from $35/month.
The honest split: build on the Grok API when the model is your product, or when you need X data nobody else sells. Buy the layer when the model was only ever a means to getting work done across tools you don’t control.
FAQ
How much does the Grok API cost?
Grok 4.5 is $2.00 per million input tokens and $6.00 per million output tokens as of July 2026. Voice and image generation price separately — $3.00/hour for the voice agent, $0.02 per image, $0.05 per second of video. Check the console for current rates before committing to a budget.
What are the Grok API rate limits?
On grok-4.5, Tier 0 starts at 150 RPS and 50M TPM at zero spend, scaling to 500 RPS and 100M TPM at Tier 4. Tiers unlock on cumulative spend since January 1, 2026 and never downgrade. Image generation is capped at 5 RPS and video at 10 RPS across all tiers.
Is the Grok API compatible with the OpenAI SDK?
Yes. Point the OpenAI SDK at https://api.x.ai/v1 and change the model string. xAI’s docs include an OpenAI-SDK example alongside nearly every native one, and the Vercel AI SDK is supported too.
Does the Grok API have access to live X data?
Yes, through the X Search tool — keyword, semantic, and user search plus thread fetch, with handle allowlists and exclusions, date ranges, and image and video understanding. It’s opt-in per request, not on by default.
How current is Grok 4.5?
Its knowledge cutoff is February 1, 2026. Through the API it has no awareness of anything after that unless you enable Web Search or X Search in the request — the consumer app’s real-time behavior isn’t the API default.
Which Grok model should I use for coding?
Grok 4.5. xAI’s guidance is that it covers code and everything else; grok-build-0.1 exists for agentic coding workflows, and the retired grok-code-fast-1 now redirects there.
How do I get a Grok API key?
Create one in the xAI Console, then purchase credits. Rate-limit tier is tracked per team on cumulative spend, so a new key starts at Tier 0 with the limits above.
Ready to automate your busywork?
Carly schedules, researches, and briefs you—so you can focus on what matters.
See what people say
"Before Carly, I relied on a Calendly link, but the whole process felt impersonal and not very professional. Carly changed that by handling all the back-and-forth, so I'm no longer stuck in endless email threads trying to line up schedules.
Now Carly reaches out to candidates, shares my real-time availability, lets them pick a slot, then sends a Zoom link and drops it straight into my calendar. She sends reminders to both of us before each call, which has significantly reduced no-shows and last-minute confusion.
On top of scheduling, Carly acts like a full executive assistant, sending me my schedule the night before so I can prepare for each call. It reminds me of the old x.ai assistant, but Carly is noticeably smarter, faster, and better suited to my healthcare recruitment business."


