API reference

Overview

The Grok API is compatible with the OpenAI REST API. This reference is generated from the OpenAPI specification and organised by resource.

Base URLs and authentication

APIBase URLAuthenticate with
Inference (responses, chat completions, images, videos, voice, files, batches, models)https://api.x.aiAuthorization: Bearer <API key>
Collections managementhttps://management-api.x.aiAuthorization: Bearer <Management API key>
Collections searchhttps://api.x.aiAuthorization: Bearer <API key>
Management (API keys, teams, billing, audit)https://management-api.x.aiAuthorization: Bearer <Management API key>

API keys are created on the API Keys page of the Grok Console. Management keys are created on the Management Keys page; see Using Management API.

Inference API

Management-key APIs

For status codes and their likely causes, see Debugging Errors.


Last updated: November 23, 2026