Grok 4.6 is now live — 8 Grok models behind one endpoint, routed to whichever Grok model fits the request.Read more

ONE API TO EVERY GROK MODEL — GROK 4.6, GROK 4.5, GROK 4.1 FAST AND BEYOND.

AI Infrastructure • GA

Reliable Routing, Your Keys, Full Control.

Grok API adds health-aware routing, automatic failover, billing visibility, and governance on top of your xAI account.

Keep your existing xAI relationship and pricing. Grok API becomes the infrastructure layer for routing, policy control, and team visibility.

See How It Works
8Grok Models
1Provider
2MMax Context
<200msRouting Latency
3 linesTo Integrate

TRUST SIGNALS YOU CAN VERIFY TODAY

  • Encrypted at Rest
  • No Prompt Storage by Default
  • Stripe Checkout

POWERED BY XAI'S GROK MODELS

View Grok models →

Why Grok API

Not just an API proxy — a control plane that makes your AI stack more reliable, transparent, and flexible.

1 lineto switch models

Zero Lock-in

Keep your xAI account and pricing. Switch Grok models by changing one string — no migration, no rewrite.

  • OpenAI SDK compatible — works with Cursor, Claude Code, any client
  • Bring your own xAI key, keep your existing contract
  • Add or drop a Grok model in seconds, not sprints
3 controlsfallback, objective, basket

Smart Routing

Automatic failover, Grok model health tracking, and approved cost-aware routing keep requests moving without hiding what the gateway did.

  • Automatic failover when a Grok model goes down
  • Approved model-basket optimization (Beta)
  • Measured routing evidence in request logs and analytics
100%spend transparency

Full Visibility

See exactly where every token goes. Track usage by team, key, or model — and set limits before you get a surprise bill.

  • Real-time token & cost tracking per API key
  • Spending limits and budget alerts
  • Full audit trail for every request

Power OpenClaw Agents Across Every Channel

Build reliable multi-channel AI bots with automatic failover, multimodal support (vision, audio, PDF), and 8 Grok models. Grok API adds health-aware routing, cost visibility, and enterprise security to your OpenClaw deployments.

WhatsApp

Telegram

Discord

Slack

Explore OpenClaw Integration →

Cut AI Spend With Guardrails

Grok API helps you compare baseline cost vs selected route, shadow-test cheaper approved Grok models, and prove savings in logs and analytics.

BETA

Approved Model Basket

Pick a baseline Grok model, then approve cheaper Grok alternatives for the same workload. Start in shadow mode, then opt into live cost routing only for that basket.

Baseline: Grok 4.6 → Approved alt: Grok 4.1 Fast

GA

Prompt Caching

On models whose vendor publishes a cached input rate, cache hits are billed at that rate, not at the full input rate. This matters most for agents and workflows with a long, repeated system prompt.

Where a cached rate is published it is typically 4-10x below uncached input

GA

Measured Savings Evidence

Request logs and Activity show baseline charge, selected route, realized savings, and shadow-mode recommendations so teams can verify what changed.

Logs: baseline vs selected vs saved, per request

ILLUSTRATIVE EXAMPLE: SUPPORT TRIAGE TEAM

Before: every request stays on one premium baseline model

After: baseline stays protected, a cheaper approved model runs in shadow first, then goes live for eligible flows

Illustrative: 20-35% lower model spend

Illustrative example only. Actual savings depend on your approved model basket, traffic mix, and prompt shape.

Up and Running in Minutes

Change one line. Get access to every Grok model with built-in reliability.

01

Point Your SDK

Swap your base URL to Grok API. Works with any OpenAI-compatible client — Cursor, Claude Code, LangChain, your own app.

02

We Apply Your Policy

Grok API applies model health, fallback rules, and your routing objective. If the first route fails, it moves to the next approved path automatically.

03

You Get Results

Same response format you already use. Plus usage tracking, cost visibility, and team controls — with zero extra code.

Your App
Grok API
Policy + Failover
xAI
Grok 4.6
Grok 4.5

Featured Models

Access every Grok model through a single unified API.

xai

Grok 4.6

500,000 ctx
Input$2.16 / 1M tokens
Output$6.48 / 1M tokens
textimage
xai

Grok 4.5

500,000 ctx
Input$2.16 / 1M tokens
Output$6.48 / 1M tokens
textimage
xai

Grok 4.1 Fast

2,000,000 ctx
Input$0.324 / 1M tokens
Output$0.810 / 1M tokens
textimage
xai

Grok 4.20 Reasoning

2,000,000 ctx
Input$1.35 / 1M tokens
Output$2.70 / 1M tokens
textimage
xai

Grok Build 0.1

256,000 ctx
Input$1.08 / 1M tokens
Output$2.16 / 1M tokens
text
View all models →

Common Questions

Learn how Grok API handles routing, billing visibility, BYOK, and tool compatibility.

Is Grok API just a model gateway?

No. Grok API is the infrastructure layer between your apps and xAI's Grok models. It keeps an OpenAI-compatible integration surface while adding routing, billing visibility, spend controls, and team governance.

Can we keep our existing xAI account and contract?

Yes. Grok API supports bring-your-own-key workflows so teams can keep their existing xAI relationship and pricing while using Grok API for reliability, policy control, and shared visibility.

Does it work with Cursor, Claude Code, and OpenAI-compatible SDKs?

Yes. Teams can start with the OpenAI-compatible quickstart and use the dedicated vibe coding setup flow for Cursor, Claude Code, Windsurf, Cline, and similar tools.

How does Grok API improve reliability?

Grok API applies model health checks, routing policy, and automatic failover before a request is sent. Teams can verify outcomes with direct xAI headers and request traces.

What do teams get beyond a single API key?

Grok API adds request-level usage tracking, spend visibility, auditability, and team controls so finance, ops, and engineering can manage shared AI traffic without building that layer themselves.

Start building in 3 lines of code

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.grokapi.lol/v1",
  apiKey: "sk-your-key",
});

const response = await client.chat.completions.create({
  model: "xai/grok-4.6",
  messages: [{ role: "user", content: "Hello!" }],
});
Grok API | Every Grok Model Behind One OpenAI-Compatible Endpoint