close

SpaceXAI API Build with Grok.

Generate text and code, create images and video, build voice agents, and search the web in real time, all through one API.

  • Works with your existing SDK
  • Usage-based pricing from $2/M tokens
  • Playground included with every account

Zero to first token

Start building with your API key

Create an account, generate a key, and ship your first Grok request in about a minute.

  1. 1

    Sign up at console.x.ai.

  2. 2

    Create an API key on the “API Keys” page.

  3. 3

    Set your base URL to https://api.x.ai/v1 and call grok-4.6.

Works with the AI SDKs you already use, in Python, TypeScript, or plain curl.

Usage-based pricing, billed per token. Prepaid credits and enterprise invoicing available. Our latest flagship is below. Full pricing for every Grok model lives in the docs.

grok-4.6
New

Our newest flagship model that leads the industry in coding, non-hallucination rate, and agentic tool calling, with a particular focus on long-running agents and ambitious interactive and visual work.

Capabilities
Context window
500k
Text Input / 1M tokens
$2.00
Output / 1M tokens
$6.00

Imagine API

Image and video generation & editing

grok-imagine-image-2.0

Text, Image → Image

Media Input
$0.01 / img
1K / 2K
from $0.04 / img
grok-imagine-video-1.5

Text, Image, Audio → Video

Media Input
$0.01 / img
480p / 720p / 1080p
from $0.08 / sec
grok-imagine-image-quality

Text, Image → Image

Media Input
$0.01 / img
1K / 2K
from $0.05 / img
grok-imagine-image

Text, Image → Image

Media Input
$0.002 / img
1K / 2K
$0.02 / img
grok-imagine-video

Text, Image, Video → Video

Media Input
$0.01 / sec
$0.002 / img
480p / 720p
from $0.05 / sec

Voice API

Realtime, TTS, and STT

Speech to SpeechStarting at $0.05 / min
Text to Speech$15.00 / 1M characters
Speech to Text$0.10 / hr (REST), $0.20 / hr (Streaming)

Included with Console

Try Grok in the Playground

The Playground comes with every Console account: chat with Grok, generate images and video, and test the latest models before you write any integration code. When you’re ready to ship, API usage is billed per token.

Manage everything in the SpaceXAI Console

Create and manage API keys, monitor usage on a real-time dashboard, top up prepaid credits, set up billing, invite your team, and test models in the Playground.

Choose how to get started

Build on your own

Launch your AI-powered product with:


  • Access to all Grok models
  • Usage-based pricing
  • Automatically increasing rate limits
  • Free Playground on console.x.ai to test Grok models before you buy

Get extra support

Custom rate limits and hands-on support for your team.


  • Dedicated onboarding support
  • Custom rate limits
  • Billing via monthly invoices
  • Single sign-on and audit logging
  • Data residency options

Available on your preferred cloud

Deploy Grok through the cloud you already trust, with first-party support across the major platforms.

Frequently asked questions

How do I get an API key for Grok?
Create a free account at console.x.ai, open “API Keys”, and create a key. It takes about a minute. Then point your existing SDK at https://api.x.ai/v1 and make your first call.
Is Grok free to use through the API?
API usage is billed per token rather than free, but the Playground comes with every Console account, so you can test the latest Grok models before adding billing.
How much does Grok cost through the API?
SpaceXAI API pricing is usage-based: grok-4.6, the latest flagship, costs $2 per million input tokens and $6 per million output tokens. Full, always-current pricing for every Grok model is in the docs.
Can I use the OpenAI or Anthropic SDK with Grok?
Yes. Point your existing SDK at base URL https://api.x.ai/v1 with your SpaceXAI API key. Most integrations need no other changes.
Which Grok models are available in the API?
The SpaceXAI API serves the latest Grok models: grok-4.6, grok-4.5 for text, reasoning, and coding, plus the Grok Imagine and Grok Voice model families. Every model runs on the same API key from the Console. Older models are retired on a published schedule, so check the docs for what is currently served. New Grok models typically land in the API on day one.
Where is the API documentation for Grok?
The full API reference, guides, and quickstart live at docs.x.ai. This page covers pricing, API keys, and what you can build.
Can I use Grok through my cloud provider?
Yes. Grok models are offered in the AI catalogs of the major clouds, including Microsoft, Oracle, Google, and Amazon platforms, alongside the native SpaceXAI API.
Can I use Grok to generate videos, ads, logos, or voiceovers?
Yes. The Grok Imagine API creates and edits images and video, from logos and product shots to animated campaign clips, and the Grok Voice API handles voiceovers, dubbing, and realtime voice agents.