Grok APIDeveloper platform

Build with Grok.

One key. Every model. Text, code, images, video, voice and live search — one usage-based API that works with the SDKs you already use.

import { xai } from "@ai-sdk/xai";
import { generateText } from "ai";

const { text } = await generateText({
  model: xai.responses("grok-4.7"),
  prompt: "Explain quantum computing",
});

console.log(text);

Explain quantum computing

Sending…

A request, and what comes back.

grok-4.7 · OpenAI-compatible · api.x.ai/v1

Quickstart

Zero to first token in about a minute.

Create a key in the Console, paste it into the client you already have, send a request. The scene on the right is the whole thing.

import { xai } from "@ai-sdk/xai";
import { generateText } from "ai";

const { text } = await generateText({
  model: xai.responses("grok-4.7"),
  prompt: "Explain quantum computing",
});

console.log(text);

Already using the Vercel AI SDK? Add @ai-sdk/xai and pass xai.responses("grok-4.7"). Those two lines are the whole migration.

The APIs

Three APIs, one key.

Text and code, images and video, speech — each with its own endpoints and models, all on one key and one bill.

  • Grok API

    grok-4.7 and grok-4.6 and grok-4.5 for text, reasoning and code — structured outputs, tool calls, live web and X search, and collections over your files.

    Endpoints
    POST /v1/chat/completionsPOST /v1/responses
    Models
    grok-4.7grok-4.6grok-4.5
  • Image & Video API

    Images from text or a reference, edits with one to three source images, and video up to 15 seconds with audio, from text, an image or up to 14 references.

    Endpoints
    POST /v1/images/generationsPOST /v1/videos/generations
    Models
    Image 2.0Video 1.5
  • Voice API

    Speech to speech over WebSocket with tool calls and barge-in, text to speech across 25+ voices, speech to text with diarization.

    Endpoints
    WebSocket /v1/realtimePOST /v1/ttsPOST /v1/stt
    Models
    grok-voice-latest

Pricing

Usage-based, billed per token.

Prepaid credits or invoicing. Rate limits rise with use. Full, always-current rates for every model are in the docs.

Text and reasoningLearn more
grok-4.7NewText, Image → Text · 500k context$2.00 / 1M tokens$6.00 / 1M tokens
grok-4.6Text, Image → Text · 500k context$2.00 / 1M tokens$6.00 / 1M tokens
grok-4.5Text, Image → Text · 500k context$2.00 / 1M tokens$6.00 / 1M tokens
Image and videoLearn more
Image 2.0Text, Image → Image · 1K / 2K$0.01 / imgfrom $0.04 / img
Video 1.5Text, Image, Audio → Video · 480p / 720p / 1080p$0.01 / imgfrom $0.08 / sec
Video 1.5 LiteText, Image → Video · 480p / 720p / 1080p$0.01 / imgfrom $0.02 / sec

For business

Controls, compliance and support.

The same Grok models, with the controls your security team asks for. A team on the Business plan shares keys, credits and usage by user; the Enterprise plan adds the rest.

  • AccessSAML SSO, roles and an audit log; rate limits scaled to your traffic; a named support path.
  • ComplianceSOC 2 Type II, HIPAA eligible, and a DPA with EU data residency — the documents your reviewer asks for.
  • Data and billingZero Data Retention on request. Usage by member, on one monthly invoice or prepaid credits.

Your first request, in about a minute.

api.x.ai/v1
$