xAI API
xAI's API platform providing access to Grok models through an OpenAI-compatible endpoint: text, agentic coding, voice, and image and video generation.

Description
The xAI API is xAI's developer platform through which the Grok family of models is served. The API base URL is https://api.x.ai/v1, with Bearer token authentication typically supplied through the XAI_API_KEY environment variable. The platform is compatible with OpenAI clients — pointing a standard client at xAI's base URL is enough to use Grok models without changing code.
The platform is organized into five main services: the Responses API for generating text, holding conversations and building tool-using applications; the Code API for agentic coding on grok-4.7; the Voice API for speech synthesis and transcription; and the Imagine API in two variants — for image generation and editing, and for video generation and editing. Cross-cutting features are also available: function calling, web search, structured outputs and a Batch API for asynchronous processing.
The model catalogue spans text variants with context windows from 256K to 1M tokens — including grok-4.7, grok-4.6 and grok-4.5 (500K tokens, $2–4 per 1M input and $6–12 per 1M output), grok-4.3, and grok-4.20 variants in reasoning, non-reasoning and multi-agent flavours (1M tokens, $1.25–2.50 input and $2.50–5 output), plus grok-build-0.1. Specialized models are billed differently: image generation from $0.02 to $0.05 per image, video at $0.05–0.08 per second, and voice at $0.08 per minute of audio. The Grok 4.7 Fast variant is not available on the public API — it runs only in Cursor and Grok Build.