Grok 4.7 API
A chat model with a context window of 500K tokens, called through Hyperouter's OpenAI-compatible API.
Price
Prices per 1M tokens: input / cached input / output.
| Model | Context | Price |
|---|---|---|
x-ai/grok-4.7 | 500K | $2.00 / $0.50 / $6.00 |
On the x-ai/ models, a request with 200,000 prompt tokens or more is billed entirely at the long-context rates, which are twice these.
Call it with the OpenAI SDK
Set HYPEROUTER_API_KEY to an API key from the dashboard. Any OpenAI SDK works once its base URL is https://api.hyperouter.app/v1.
curl https://api.hyperouter.app/v1/chat/completions \ -H "Authorization: Bearer $HYPEROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "x-ai/grok-4.7", "messages": [{"role": "user", "content": "Hello"}] }'
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.hyperouter.app/v1", apiKey: process.env.HYPEROUTER_API_KEY, }); const res = await client.chat.completions.create({ model: "x-ai/grok-4.7", messages: [{ role: "user", content: "Hello" }], }); console.log(res.choices[0].message.content);
import os from openai import OpenAI client = OpenAI( base_url="https://api.hyperouter.app/v1", api_key=os.environ["HYPEROUTER_API_KEY"], ) res = client.chat.completions.create( model="x-ai/grok-4.7", messages=[{"role": "user", "content": "Hello"}], ) print(res.choices[0].message.content)
Reference
- Chat completions: parameters, streaming, routing and errors
GET /v1/models: the models your account can call at the time of the request, with prices and parameters
Related models
- Grok 4.6
x-ai/grok-4.6 - Grok 4.5
x-ai/grok-4.5 - Grok 4.3
x-ai/grok-4.3 - Grok Build 0.1
x-ai/grok-build-0.1 - DeepSeek V4.1 Flash
deepseek/deepseek-v4.1-flash - DeepSeek V4.1 Flash 1017
deepseek/deepseek-v4.1-flash-1017 - GPT-6 Astra
openai/gpt-6-astra - GPT-6.1 Sol
openai/gpt-6.1-sol - GLM-5.3
z-ai/glm-5.3 - Face Detect
lumina/face-detect