Grok API
Run xAI Grok 4.6 and Grok 4.5 through one Inference.net API key with OpenAI /v1/chat/completions, /v1/responses, and Anthropic /v1/messages support. Compare live standard and >200K long-context per-token pricing, x-grok-conv-id prompt-cache savings, and 500K-token context windows. Because live Grok models route externally to xAI, they follow xAI's upstream data-handling and retention terms (default Zero Data Retention applies to eligible Inference.net-hosted routes).
- Live Grok 4.6 and Grok 4.5 pricing with 500K context and 500K max output
- Prompt caching via x-grok-conv-id (75% savings on Grok 4.6, 85% on Grok 4.5)
- OpenAI /v1/chat/completions, /v1/responses, and Anthropic /v1/messages support
- Vision input, tool calling, structured outputs, and configurable reasoning
All live Grok models on Inference.net
Every rate, context limit, and capability below is pulled directly from the live public catalog. Select any model for full specs, live latency benchmarks, and prompt-caching guidance.
Call Grok over OpenAI or Anthropic SDKs
Use the top live model ID (grok-4.6) with the standard OpenAI SDK, curl, or Claude Code over native /v1/messages.
import OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'https://api.inference.net/v1',
apiKey: process.env.INFERENCE_API_KEY,
})
const completion = await client.chat.completions.create({
model: 'grok-4.6',
messages: [{ role: 'user', content: 'Hello' }],
})import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.inference.net/v1",
api_key=os.environ["INFERENCE_API_KEY"],
)
completion = client.chat.completions.create(
model="grok-4.6",
messages=[{"role": "user", "content": "Hello"}],
)curl https://api.inference.net/v1/chat/completions \
-H "Authorization: Bearer $INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.6",
"messages": [
{ "role": "user", "content": "Hello" }
]
}'Point Claude Code or any Anthropic SDK client at Inference.net with zero proxy setup and full prompt-cache support.
export ANTHROPIC_BASE_URL="https://api.inference.net"
export ANTHROPIC_AUTH_TOKEN="$INFERENCE_API_KEY"
export ANTHROPIC_MODEL='grok-4.6'
export ANTHROPIC_DEFAULT_OPUS_MODEL='grok-4.6'
export ANTHROPIC_DEFAULT_SONNET_MODEL='grok-4.6'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='grok-4.6'
export CLAUDE_CODE_SUBAGENT_MODEL='grok-4.6'
export CLAUDE_CODE_MAX_CONTEXT_TOKENS="500000"
claudeBenchmark, compare, and model Grok costs
Verify unit economics across prompt-cache hit rates, compare providers, and explore engineering guides for Grok.
Explore other open-weight model families
Switch across DeepSeek, Kimi, GLM, and the full catalog with one API key and one OpenAI-compatible client.
Frequently asked questions.
Quick answers to help you get started
Inference.net currently serves 2 live Grok models with transparent pay-as-you-go per-token billing. Input rates start at $2.00 per 1M input tokens ($6.00 per 1M output tokens) on Grok 4.6. Prompts exceeding 200K input tokens on Grok 4.6 and Grok 4.5 use the long-context tier ($4.00/1M input, $12.00/1M output, and $1.00/1M cached on Grok 4.6 or $0.60/1M cached on Grok 4.5). Every rate in the comparison table above pulls directly from the live public catalog.
Yes. Pass a stable x-grok-conv-id request header across turns in the same conversation while keeping repeated system instructions, tool schemas, and context byte-identical (prompts above 200K input tokens use the long-context cached-read tier). On Grok 4.6, cached input reads are $0.50 per 1M tokens (75% less than standard input). Estimate multi-turn savings with the Prompt Cache Calculator.
Yes. Point the official OpenAI TypeScript or Python SDK to https://api.inference.net/v1 with your INFERENCE_API_KEY and set model to "grok-4.6". All live Grok catalog models support /v1/chat/completions, /v1/responses, and native Anthropic /v1/messages for Anthropic SDK apps and Claude Code.
No. Because Grok 4.6 and Grok 4.5 route externally to xAI rather than running on Inference.net GPUs, they are excluded from Inference.net's Zero Data Retention (ZDR) policy and follow xAI's upstream data-handling and retention terms. Default ZDR under SOC 2 Type II controls applies to eligible Inference.net-hosted routes; review our ZDR policy for full details. Live Grok routes run over the global https://api.inference.net/v1 endpoint.
Live Grok models on Inference.net scale up to a 500K-token context window (500,000 tokens) and up to 500K output tokens on Grok 4.6. Context limits and caching vary by checkpoint, so check each model row above for exact specs and multimodal capabilities.
Start calling Grok in minutes
Create a project API key with Zero Data Retention enabled by default on eligible Inference.net-hosted routes and route requests to grok-4.6 with pay-as-you-go billing.