✳ainav.
xAI API screenshot
xAI API website preview

PRODUCT OVERVIEW

What is xAI API?

xAI API is a developer platform that exposes Grok models through a single API endpoint at api.x.ai/v1. It supports text and code generation, reasoning, image and video generation and editing via the Imagine API, and realtime voice agents through speech-to-speech, text-to-speech, and speech-to-text. Developers can also search the live web and X, and upload files and collections so Grok can reason over PDFs, spreadsheets, and presentations. It works with existing SDKs, including OpenAI-compatible clients, and every Console account includes a Playground for testing models before billing. Usage is billed per token, with prepaid credits and enterprise invoicing available, and enterprise options add SSO, audit logging, data residency, and dedicated support.

How to use xAI API

  1. 1

    Create an account and API key

    Sign up at console.x.ai, open the API Keys page, and create a key. Keys are shown once at creation, so store them securely.

  2. 2

    Point your SDK at the base URL

    Set your base URL to https://api.x.ai/v1 and call a Grok model such as grok-4.7 using Python, TypeScript, an OpenAI-compatible SDK, or plain curl.

  3. 3

    Test models in the Playground

    Every Console account includes a Playground where you can chat with Grok and generate images and video before writing integration code.

  4. 4

    Add billing and monitor usage

    API usage is billed per token. Top up prepaid credits, set up billing, and monitor usage on the Console dashboard.

xAI API Features

Text and code generation with Grok models

Image and video generation and editing via the Imagine API

Realtime voice agents with speech-to-speech, text-to-speech, and speech-to-text

Live web and X search

Files and collections for reasoning over PDFs, spreadsheets, and presentations

Works with existing SDKs, including OpenAI-compatible clients

Playground included with every Console account

Enterprise controls including SSO, audit logging, and data residency

xAI API Use Cases

  • Build coding assistants and agent orchestration

  • Generate and edit images and video for campaigns

  • Create realtime voice agents for customer inquiries

  • Synthesize research with live web and X search

  • Extract structured data from contracts and invoices

  • Build internal tools and custom assistants

xAI API FAQs

Create a free account at console.x.ai, open the API Keys page, and create a key. Then point your SDK at https://api.x.ai/v1 and make your first call.

API usage is billed per token rather than free, but every Console account includes a Playground for testing the latest Grok models before adding billing.

grok-4.7 costs $2 per million input tokens and $6 per million output tokens. Full pricing for every Grok model is in the docs.

Yes. Point your existing SDK at base URL https://api.x.ai/v1 with your xAI API key, and most integrations need no other changes.

The API serves grok-4.7, grok-4.6, and grok-4.5 for text, reasoning, and coding, plus the Grok Imagine and Grok Voice model families. Older models are retired on a published schedule.

Yes. Grok models are offered in the AI catalogs of major clouds, including Microsoft, Oracle, Google, and Amazon platforms, alongside the native xAI API.

Yes. The enterprise API adds SSO, audit logging, SOC 2, HIPAA-eligible deployments with a BAA, data residency, monthly invoicing, custom rate limits, and dedicated support.

Yes. The Grok Imagine API creates and edits images and video, and the Grok Voice API handles voiceovers, dubbing, and realtime voice agents.

xAI API Official Information

Company
SpaceXAI LLC
Website
https://x.ai/api
Documentation
https://docs.x.ai/

Contact ↗

xAI API Pricing

Freemium

API pricing is usage-based and billed per token. Prices shown are in USD and exclude applicable taxes. A free Console account includes a Playground for testing models before adding billing.

Free Console account

$0USD / month

A free Console account for creating API keys and testing Grok models in the Playground before adding billing.

  • Create and manage API keys
  • Playground included with every account
  • Test latest Grok models before writing integration code
  • API usage billed separately per token

grok-4.7 text input

$2.00USD / per 1M input tokens

Usage-based pricing for text input to grok-4.7, the flagship model for coding and knowledge work with a 500k context window.

  • 500k context window
  • Flagship model for coding and knowledge work
  • Billed per token with prepaid credits available

grok-4.7 output

$6.00USD / per 1M output tokens

Usage-based pricing for output generated by grok-4.7.

  • Billed per output token
  • Works with existing SDKs
  • Prepaid credits and enterprise invoicing available

Imagine API image generation

$0.04USD / per image (from)

Image generation and editing through the Imagine API, with starting prices varying by model and resolution.

  • Text and image to image
  • 1K and 2K resolution options
  • Starting price from $0.04 per image for grok-imagine-image-2.0

Imagine API video generation

$0.02USD / per second (from)

Video generation through the Imagine API, with starting prices varying by model and resolution.

  • Text, image, and audio to video
  • 480p, 720p, and 1080p options
  • Starting price from $0.02 per second for grok-imagine-video-1.5-lite

Voice API speech to speech

$0.08USD / per minute

Realtime speech-to-speech pricing for building voice agents.

  • Realtime voice agents
  • Billed per minute

Voice API text to speech

$15.00USD / per 1M characters

Text-to-speech pricing for voiceovers and voice agents.

  • Billed per 1M characters
  • Suitable for voiceovers and dubbing

Voice API speech to text

$0.10USD / per hour (REST)

Speech-to-text pricing, with REST at $0.10 per hour and streaming at $0.20 per hour.

  • REST at $0.10 per hour
  • Streaming at $0.20 per hour

COMMUNITY REVIEWS

xAI API User Reviews

Reader reviews

No reviews yet.

Share your experience with xAI API

Sign in to share your experience. Your display name, rating and review will be public after approval. One review per account per tool.

Your rating