import requests r = requests.post( "https://api.aimlapi.com/v1/chat/completions", headers={"Authorization": "Bearer " + AIMLAPI_KEY}, json={ "model": "x-ai/grok-4-7", "messages": [ { "role": "user", "content": "Hello!" } ] }, ) print(r.json())
const r = await fetch("https://api.aimlapi.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.AIMLAPI_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "model": "x-ai/grok-4-7", "messages": [ { "role": "user", "content": "Hello!" } ] }), }); console.log(await r.json());
curl -X POST https://api.aimlapi.com/v1/chat/completions \ -H "Authorization: Bearer $AIMLAPI_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"x-ai/grok-4-7","messages":[{"role":"user","content":"Hello!"}]}'
OpenAI-compatible — swap the base URL and it works with your existing SDK.
| Type | Price |
|---|---|
| Input | |
| Output | |
| Cached input |
Tiered pricing: $2.6/$7.8 per 1M tokens up to 200K context, $5.2/$15.6 above 200K. Cached input: $0.65/1M (≤200K) or $1.3/1M (>200K).
Yes. Grok 4.7 is live on AI/ML API. Call it on the OpenAI-compatible chat completions endpoint with the model id x-ai/grok-4-7; the short alias grok-4-7 also resolves to it.
Grok 4.7 has a 500,000 token context window, the same as Grok 4.5 and Grok 4.6.
Pricing is tiered by context length. Up to 200K context it is $2.6 / 1M input tokens and $7.8 / 1M output; above 200K both double, to $5.2 and $15.6. Cached input is $0.65 / 1M (≤200K) or $1.3 / 1M (>200K). Reasoning tokens are billed at the output rate.
xAI calls Grok 4.7 the most capable model it has built. Elon Musk described it as a 2.1-trillion-parameter model, up from 1.5T in Grok 4.6, and “better than 4.6 in every way, except slightly slower to serve, albeit with even better token efficiency”. Those are the vendor's own statements — xAI has not published a parameter count or a benchmark card.
Text and file input, text output. Grok 4.7 is a text model — it does not accept images, audio or video.
Requests whose context stays under 200,000 tokens bill at the standard rate. Once a prompt crosses 200K, both the input and output rates double for that request. If your prompts sit near the boundary, it is worth designing around it.
Yes. Like the rest of the Grok 4 line it supports tool calling, parallel tool calls, streaming and prompt caching.
Grok 4.7 was built by xAI as the newest flagship in the Grok 4 family, following Grok 4.5 and Grok 4.6.