API Reference

Overview

The xAI REST 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, embeddings, images, videos, voice, files, batches, models)https://api.x.aiAuthorization: Bearer <xAI API key>
Collections managementhttps://management-api.x.aiAuthorization: Bearer <xAI Management API key>
Collections searchhttps://api.x.aiAuthorization: Bearer <xAI API key>
Management (API keys, teams, billing, audit)https://management-api.x.aiAuthorization: Bearer <xAI Management API key>

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

Inference API

Management-key APIs

Other protocols

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


Last updated: September 2, 2026