xAI API logo

xAI API

Developer API for Grok models: text, code, image, video, voice, and real-time web search, billed per token.

Price from0.002 USD
Freefree trial
Platformsapi
xAI API - zrzut strony

What is xAI API?

The xAI API, branded SpaceXAI API on its site, gives developers access to Grok models through one endpoint. You create an account at console.x.ai, generate an API key, set the base URL to https://api.x.ai/v1, and call a model such as grok-4.7. It works with the Python xai_sdk, the Vercel AI SDK, the OpenAI SDK, or plain curl.

With the API you can generate text and code, create and edit images and video through the Imagine models, build speech-to-speech voice agents, run text-to-speech and speech-to-text, and search the web and X in real time. Every account includes a Playground for testing models before writing integration code. Usage is billed per token, with prepaid credits and enterprise invoicing available.

Key features

  • Grok 4.7 flagship model with 500k context window
  • Image generation and editing via Imagine models
  • Video generation at 480p, 720p and 1080p
  • Realtime speech-to-speech, text-to-speech and speech-to-text
  • Real-time web and X search
  • OpenAI-compatible endpoint and Python, TypeScript SDKs

Who is it for

  • software developers
  • AI engineers building agents
  • product teams adding AI features
  • enterprises needing custom rate limits and SSO

Pros and cons

Pros
  • Works with existing OpenAI-compatible SDKs
  • Playground included with every account, no integration needed to test
  • Pay-per-token pricing with no minimum subscription for API use
Cons
  • Full pricing for every model is only listed in the docs, not on the homepage
  • Enterprise features such as SSO and dedicated data plane require contacting sales

xAI API pricing

PlanPriceIncludes
grok-4.7 (Text input)2 USDper 1M input tokens, 500k context window
grok-4.7 (Output)6 USDper 1M output tokens
grok-imagine-image0.002 USDper image input, 1K/2K output $0.02 per image
grok-imagine-video-1.5-lite0.02 USDper second of video, 480p to 1080p, from
Text to Speech15 USDper 1M characters
Speech to Speech0.08 USDper minute

Prices copied from xAI API pricing, checked October 12, 2026. Currency as shown by the vendor; taxes may apply.

xAI API pricing details →

Is xAI API free?

There is a free trial. Playground is included with every Console account for testing models and generating images and video. API usage is billed per token, with no free API tier mentioned.

xAI API alternatives

ToolPrice fromFree planCategory
OpenAI Platform logoOpenAI Platform0,10 USD?APIs & models
DeepSeek API logoDeepSeek APInot listed?APIs & models
Cerebras logoCerebras5 USDtrialAPIs & models
Blackbox AI logoBlackbox AInot listed?APIs & models
Cline logoClinenot listedyesAPIs & models
OpenRouter logoOpenRouternot listedyesAPIs & models

All alternatives to xAI API →

FAQ

What is xAI API used for?

Developer API for Grok models: text, code, image, video, voice, and real-time web search, billed per token.

Is xAI API free?

There is a free trial. Playground is included with every Console account for testing models and generating images and video. API usage is billed per token, with no free API tier mentioned.

How much does xAI API cost?

The cheapest paid plan is 0.002 USD (vendor pricing, October 12, 2026).

What are the best xAI API alternatives?

Closest alternatives: OpenAI Platform, DeepSeek API, Cerebras, Blackbox AI, Cline.

Data checked October 12, 2026 on the vendor website (x.ai).