Grok on RouterHub
Grok API pricing and setup
Build apps with Grok using the OpenAI-compatible Chat Completions API, one RouterHub API key, and prepaid credits. Compare published input, output, and cached input rates before choosing your model.
Grok models and prices
See Models & pricing for current model IDs, rates, availability, and limits. These details can change; use that page before sending a request.
Input is the prompt you send; output is the response you receive. Cached input rates apply when the provider reports a cache hit. Prices come from RouterHub's current public catalogue; these are RouterHub rates. No separate subscription is required.
Grok models are developed by xAI. Use your RouterHub API key and the RouterHub base URL; a separate xAI account or key is not required. Only available Grok IDs from the current catalogue are listed here.
Get an API key
- Create a RouterHub account.
- Add prepaid credits.
- Create an API key and keep it in your local environment.
- Send a short Chat Completions request, then check Usage for its cost.
Send your first Grok API request
Use the exact model ID grok-4.7 with https://routerhub.si/v1/chat/completions. Set ROUTERHUB_API_KEY in your local environment. This request uses prepaid credits.
cURL
curl --connect-timeout 30 --max-time 600 https://routerhub.si/v1/chat/completions \
-H "Authorization: Bearer $ROUTERHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"grok-4.7","messages":[{"role":"user","content":"Reply with OK."}]}'Python
Install the OpenAI Python SDK with pip install openai.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ROUTERHUB_API_KEY"],
base_url="https://routerhub.si/v1",
timeout=600.0,
)
response = client.chat.completions.create(
model="grok-4.7",
messages=[{"role": "user", "content": "Reply with OK."}],
)
print(response.choices[0].message.content)Node.js
Install the OpenAI JavaScript SDK with npm install openai.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ROUTERHUB_API_KEY,
baseURL: "https://routerhub.si/v1",
timeout: 600000,
});
const response = await client.chat.completions.create({
model: "grok-4.7",
messages: [{ role: "user", content: "Reply with OK." }],
});
console.log(response.choices[0].message.content);Python SDK timeouts use seconds; JavaScript SDK timeouts use milliseconds. Both examples allow ten minutes per attempt. SDKs may retry automatically; check Usage and the request ID before manually rerunning a timeout.
Compare models or connect a tool
Compare all GPT, Claude, DeepSeek, GLM, and Grok prices · OpenCode setup · All setup guides
- DeepSeek API pricing and setup
- GLM 5.3, Flash and Abliterated API pricing and setup
- Grok API pricing and setup
- Kimi K3.1 Pro API pricing and setup
Current model IDs, protocols, and prices · API quickstart · OpenAPI reference · This setup guide