Grok 4.5 went live on July 8, 2026, and the API path is the fastest way to put it to work. The model ID is grok-4.5, pricing is $2 per million input tokens and $6 per million output, and the context window is 500k tokens. xAI’s announcement positions it for coding, agentic tasks, and knowledge work at, in Musk’s words, “Opus-class” capability.
This guide walks through getting a key, making your first call, choosing between grok-4.5 and the older grok-4.3, and testing the endpoint properly in Apidog before you ship anything that depends on it.
One availability note before you start: Grok 4.5 is not yet available in the EU, in either the products or the API console. xAI expects EU access in mid-July 2026.

Step 1: Get an xAI API key
- Go to the xAI console and sign in.
- Open the API Keys section and create a new key.
- Store it as an environment variable. Never hardcode it:
export XAI_API_KEY="xai-..."
New console accounts have received trial credits in the past (reports range from $25 to $150). Check your billing page rather than counting on a specific amount. If you want to explore without credits at all, see how to use Grok 4.5 for free.

Step 2: Make your first request
xAI’s official quickstart uses the Responses endpoint. This is the exact shape from the release page:
curl -s https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.5",
"input": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"
}'
Two details trip people up:
- The model ID contains a dot.
grok-4.5works;grok-4-5returns a model-not-found error. Slugs and URLs use dashes, API calls use the dot. - The quickstart is Responses-shaped, taking an
inputfield rather than amessagesarray. xAI also maintains OpenAI-compatible chat completions, which matters if you’re migrating existing code.
Using the OpenAI SDK
Because xAI keeps compatibility with the OpenAI client libraries, pointing an existing client at https://api.x.ai/v1 is usually a one-line change. This is the same pattern we covered for earlier models in our Grok 4.3 API guide:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["XAI_API_KEY"],
base_url="https://api.x.ai/v1",
)
response = client.chat.completions.create(
model="grok-4.5",
messages=[
{"role": "system", "content": "You are a code review assistant."},
{"role": "user", "content": "Review this handler for race conditions: ..."},
],
)
print(response.choices[0].message.content)
Check the xAI docs for the current parameter surface. Features move quickly in the first weeks after a launch, and the docs are the source of truth for tool calling and structured outputs.
Streaming
For interactive use, enable streaming and consume server-sent events:
stream = client.chat.completions.create(
model="grok-4.5",
messages=[{"role": "user", "content": "Refactor this function step by step: ..."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
Grok 4.5 serves around 80 tokens per second, fast-model territory, so streams feel responsive even on long outputs.
Step 3: Pick the right model ID
xAI now sells two main chat models, and the trade-off between them is unusual:
grok-4.5 |
grok-4.3 |
|
|---|---|---|
| Context window | 500k tokens | 1M tokens |
| Input / output per 1M | $2.00 / $6.00 | $1.25 / $2.50 |
| Batch discount | None listed | 20% off |
| Speed | ~80 TPS | Slower per xAI’s positioning |
| Strengths | Agentic coding, token efficiency | Long-context work, price |
The new model costs more and holds half the context. What you get in exchange is capability and efficiency: on SWE Bench Pro, Grok 4.5 resolves tasks with an average of 15,954 output tokens, about 4.2x fewer than Claude Opus 4.8 (max) on the same benchmark. For agent loops, fewer output tokens means lower bills and shorter waits.
Rule of thumb: long-document RAG and giant-context analysis stay on grok-4.3; multi-step coding and agentic tool use move to grok-4.5. The full cost math, including how token efficiency changes the comparison, is in Grok 4.5 pricing explained.
If you’d rather route through an aggregator for failover or unified billing, Grok 4.5 is also listed on OpenRouter. We covered that setup pattern in how to use Grok models via OpenRouter.
Step 4: Test the endpoint in Apidog
Before Grok 4.5 goes anywhere near production, put the endpoint under a proper test harness. Here’s the workflow in Apidog:

- Create a request for
POST https://api.x.ai/v1/responses(or the chat completions path if you’re using the compatible surface). - Store the key as an environment variable in an Apidog environment, so the Bearer token never lands in a shared collection.
- Send and inspect. Apidog renders SSE streams as they arrive, so you can watch deltas and confirm the stream terminates cleanly.
- Assert on the response. Add visual assertions on the fields your app depends on, like the model name echoed back, finish reason, and usage counts.
- A/B the two models. Duplicate the request, switch
grok-4.5togrok-4.3, and compare output quality, latency, and token usage side by side on your real prompts instead of trusting benchmark averages. - Mock it. Generate a mock server from the response schema so your frontend and QA teams build against a stable shape while you tune prompts. No xAI credits burned on UI development.
The usage object matters more with this model than most. Grok 4.5’s pitch is token efficiency, so track output_tokens per task in your assertions. If your prompts produce Opus-length outputs anyway, the cost advantage shrinks.
Download Apidog free if you want to follow along; the whole flow above works on the free plan.
Costs, limits, and gotchas
- Pricing: $2/M input, $6/M output. Web and X search tool calls bill separately at $5 per 1,000 calls. Priority processing runs at 2x standard rates.
- Cached input: secondary sources report a $0.50/M cached-input rate, but neither the release page nor the docs pricing page confirms it as of July 9. Check the console before building cache-heavy cost models.
- No batch discount is listed for
grok-4.5, unlikegrok-4.3. - EU: blocked until mid-July 2026. Requests from EU-billed accounts fail at the console level, not the API level, so this shows up as an access problem rather than an error code.
- Rate limits are account-tier dependent. The patterns from Grok’s earlier rate-limit tiers still apply: check your console tier and build backoff before you need it.
For the bigger picture on what this model is and where it beats or trails Opus 4.8, start with what is Grok 4.5.
FAQ
What is the Grok 4.5 API model ID? grok-4.5. The dot is required in API calls.
Does the Grok 4.5 API work with the OpenAI SDK? Yes. Set base_url to https://api.x.ai/v1 and pass your xAI key. Existing chat-completions code migrates with minimal changes.
How much does the Grok 4.5 API cost? $2 per million input tokens and $6 per million output tokens, with no batch discount listed. See the full pricing breakdown for effective-cost math.
Is there a free way to call Grok 4.5? Grok Build and Cursor include free Grok 4.5 usage for a limited window, and console trial credits have covered light API testing. Details in our free-access guide.
What’s the context window? 500k tokens. If you need 1M, use grok-4.3 and accept the capability trade-off.



