xAI website screenshot

xAI

xAI is an AI research lab founded by Elon Musk. The xAI API exposes Grok foundation models for chat, function calling, vision, voice, image generation, and video generation, alongside research outputs from the Colossus training supercluster.

8 APIs 0 Features
AILLMFoundation ModelsGrokGenerative AI

APIs

xAI Chat Completions API

Generates conversational completions using Grok foundation models, including multi-turn conversations, function calling, structured outputs, and reasoning. OpenAI-compatible Cha...

xAI Responses API

The Responses API supports text generation, multi-turn conversations, reasoning, tool/function calling, and built-in tools (Live Search, code execution).

xAI Images API

Generates images from text prompts using the Grok Imagine image models. OpenAI-compatible image generation endpoint.

xAI Video Generation API

Generates video from text or image inputs using the Grok Imagine video models, with editing and detailed control options.

xAI Voice API

Realtime voice API supporting speech-to-text, text-to-speech, and bidirectional realtime voice interaction with Grok.

xAI Embeddings API

Generates vector embeddings of text and other inputs for retrieval, classification, and semantic search workflows.

xAI Models API

Lists available Grok models, model capabilities, context windows, and metadata.

xAI Batch API

Submits offline batch jobs of chat or embedding requests at a discount (20-50% off standard rates), with results returned out-of-band. Batch requests do not count toward rate li...

Collections

Pricing Plans

Xai Plans Pricing

3 plans

PLANS

Rate Limits

Xai Rate Limits

3 limits

RATE LIMITS

FinOps

Xai Finops

FINOPS

Event Specifications

xAI Realtime WebSocket APIs

AsyncAPI 2.6 description of xAI's documented WebSocket APIs: - Real-time Speech-to-Text (STT) streaming at wss://api.x.ai/v1/stt - Voice Agent (bidirectional speech-to-speech) a...

ASYNCAPI

Resources

👥
GitHubOrganization
GitHubOrganization
🔗
LinkedIn
LinkedIn
🔗
Website
Website
🔗
Documentation
Documentation
🔗
Plans
Plans
🔗
RateLimits
RateLimits
🔗
FinOps
FinOps

Sources

Raw ↑
opencollection: 1.0.0
info:
  name: xAI's REST API
  version: 1.0.0
items:
- info:
    name: v1
    type: folder
  items:
  - info:
      name: Get information about an API key, including name, status, permissions and users who created or modified this key.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/api-key'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get information about an API key, including name, status, permissions and users who created or modified this key.
  - info:
      name: Create a chat response from text/image chat prompts. This is the endpoint for making requests to chat and image
        understanding models.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/chat/completions'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Create a chat response from text/image chat prompts. This is the endpoint for making requests to chat and image
      understanding models.
  - info:
      name: Tries to fetch a result for a previously-started deferred completion. Returns `200 Success` with the response
        body, if the request has been completed. Returns `202 Accepted` when the request is pending processing.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/chat/deferred-completion/:request_id'
      params:
      - name: request_id
        value: ''
        type: path
        description: The deferred request id returned by a previous deferred chat request.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Tries to fetch a result for a previously-started deferred completion. Returns `200 Success` with the response body,
      if the request has been completed. Returns `202 Accepted` when the request is pending processing.
  - info:
      name: (Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible with
        the Anthropic API.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/complete'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: (Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible with
      the Anthropic API.
  - info:
      name: (Legacy - Not supported by reasoning models) Create a text completion response for a given prompt. Replaced by
        /v1/chat/completions.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/completions'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: (Legacy - Not supported by reasoning models) Create a text completion response for a given prompt. Replaced by /v1/chat/completions.
  - info:
      name: Search for content related to the query within the given collections.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/documents/search'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Search for content related to the query within the given collections.
  - info:
      name: List all embedding models available to the authenticating API key with full information. Additional information
        compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/embedding-models'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: List all embedding models available to the authenticating API key with full information. Additional information
      compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
  - info:
      name: Get full information about an embedding model with its model_id.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/embedding-models/:model_id'
      params:
      - name: model_id
        value: ''
        type: path
        description: ID of the model to get.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get full information about an embedding model with its model_id.
  - info:
      name: Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests
        to embedding models.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/embeddings'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests
      to embedding models.
  - info:
      name: 'List files owned by the authenticated team, paginated. The response

        always returns a `pagination_token`; pass it back as a query parameter

        to fetch the next page. The end of the list is reached when the

        returned `data` array is shorter than `limit`.'
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/files'
      params:
      - name: limit
        value: ''
        type: query
        description: The maximum number of objects to be returned in a single response.
      - name: order
        value: ''
        type: query
        description: The ordering to sort the returned files. Use `asc` for ascending and `desc` for descending order.
      - name: sort_by
        value: ''
        type: query
        description: 'The field to sort by. Valid options: `created_at`, `filename`, `size`. Defaults to `created_at`.'
      - name: pagination_token
        value: ''
        type: query
        description: The pagination token returned by the previous list files request.
      - name: after
        value: ''
        type: query
        description: Only included for compatibility. Use `pagination_token` instead.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'List files owned by the authenticated team, paginated. The response

      always returns a `pagination_token`; pass it back as a query parameter

      to fetch the next page. The end of the list is reached when the

      returned `data` array is shorter than `limit`.'
  - info:
      name: 'Upload a file to xAI''s storage. Returns the file''s metadata. Files can

        be referenced by ID anywhere a `file_id` is accepted (e.g. chat

        attachments). Maximum file size: 50 MB. Files are kept until you

        delete them, or until `expires_after` elapses if set at upload time.'
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/files'
      body:
        type: multipart-form
        data: []
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Upload a file to xAI''s storage. Returns the file''s metadata. Files can

      be referenced by ID anywhere a `file_id` is accepted (e.g. chat

      attachments). Maximum file size: 50 MB. Files are kept until you

      delete them, or until `expires_after` elapses if set at upload time.'
  - info:
      name: 'Retrieve metadata for a single file by ID. Errors with 404 if the file

        doesn''t exist, has been deleted, or has passed its `expires_at`.'
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/files/:file_id'
      params:
      - name: file_id
        value: ''
        type: path
        description: The file's `id` returned by upload or list.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Retrieve metadata for a single file by ID. Errors with 404 if the file

      doesn''t exist, has been deleted, or has passed its `expires_at`.'
  - info:
      name: 'Delete a file by ID. After this returns, the file no longer appears in

        `GET /v1/files`, content download returns 404, and the ID can no longer

        be referenced in chat attachments.'
      type: http
    http:
      method: DELETE
      url: '{{baseUrl}}/v1/files/:file_id'
      params:
      - name: file_id
        value: ''
        type: path
        description: The file's `id` to delete.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Delete a file by ID. After this returns, the file no longer appears in

      `GET /v1/files`, content download returns 404, and the ID can no longer

      be referenced in chat attachments.'
  - info:
      name: 'Download the contents of a file as a stream of raw bytes. The response

        `Content-Type` is `application/octet-stream`. Use this for the binary

        payload; use `GET /v1/files/{file_id}` for metadata only.'
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/files/:file_id/content'
      params:
      - name: file_id
        value: ''
        type: path
        description: The file's `id` to download.
      - name: format
        value: ''
        type: query
        description: Format of the downloaded content.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Download the contents of a file as a stream of raw bytes. The response

      `Content-Type` is `application/octet-stream`. Use this for the binary

      payload; use `GET /v1/files/{file_id}` for metadata only.'
  - info:
      name: List all image generation models available to the authenticating API key with full information. Additional information
        compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/image-generation-models'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: List all image generation models available to the authenticating API key with full information. Additional information
      compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
  - info:
      name: Get full information about an image generation model with its model_id.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/image-generation-models/:model_id'
      params:
      - name: model_id
        value: ''
        type: path
        description: ID of the model to get.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get full information about an image generation model with its model_id.
  - info:
      name: Edit an image based on a prompt. This is the endpoint for making edit requests to image generation models.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/images/edits'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Edit an image based on a prompt. This is the endpoint for making edit requests to image generation models.
  - info:
      name: Generate an image based on a prompt. This is the endpoint for making generation requests to image generation models.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/images/generations'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Generate an image based on a prompt. This is the endpoint for making generation requests to image generation models.
  - info:
      name: List all chat and image understanding models available to the authenticating API key with full information. Additional
        information compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/language-models'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: List all chat and image understanding models available to the authenticating API key with full information. Additional
      information compared to /v1/models includes modalities, pricing, fingerprint and alias(es).
  - info:
      name: Get full information about a chat or image understanding model with its model_id.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/language-models/:model_id'
      params:
      - name: model_id
        value: ''
        type: path
        description: ID of the model to get.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get full information about a chat or image understanding model with its model_id.
  - info:
      name: Create a messages response. This endpoint is compatible with the Anthropic API.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/messages'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Create a messages response. This endpoint is compatible with the Anthropic API.
  - info:
      name: List all models available to the authenticating API key with minimalized information, including model names (ID),
        creation times, etc.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/models'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: List all models available to the authenticating API key with minimalized information, including model names (ID),
      creation times, etc.
  - info:
      name: Get minimalized information about a model with its model_id.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/models/:model_id'
      params:
      - name: model_id
        value: ''
        type: path
        description: ID of the model to get.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get minimalized information about a model with its model_id.
  - info:
      name: Generates a response based on text or image prompts. The response ID can be used to retrieve the response later
        or to continue the conversation without repeating prior context. New responses will be stored for 30 days and then
        permanently deleted.
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/responses'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Generates a response based on text or image prompts. The response ID can be used to retrieve the response later
      or to continue the conversation without repeating prior context. New responses will be stored for 30 days and then permanently
      deleted.
  - info:
      name: Retrieve a previously generated response.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/responses/:response_id'
      params:
      - name: response_id
        value: ''
        type: path
        description: The response id returned by a previous create response request.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Retrieve a previously generated response.
  - info:
      name: Delete a previously generated response.
      type: http
    http:
      method: DELETE
      url: '{{baseUrl}}/v1/responses/:response_id'
      params:
      - name: response_id
        value: ''
        type: path
        description: The response id returned by a previous create response request.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Delete a previously generated response.
  - info:
      name: Tokenize text with the specified model
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/tokenize-text'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Tokenize text with the specified model
  - info:
      name: List all video generation models available to the authenticating API key with full information.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/video-generation-models'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: List all video generation models available to the authenticating API key with full information.
  - info:
      name: Get full information about a video generation model with its model_id.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/video-generation-models/:model_id'
      params:
      - name: model_id
        value: ''
        type: path
        description: ID of the model to get.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: Get full information about a video generation model with its model_id.
  - info:
      name: 'Edit a video based on a prompt.

        This is an asynchronous operation that returns a request_id for polling.'
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/videos/edits'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Edit a video based on a prompt.

      This is an asynchronous operation that returns a request_id for polling.'
  - info:
      name: 'Extend a video by generating continuation content.

        This is an asynchronous operation that returns a request_id for polling.'
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/videos/extensions'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Extend a video by generating continuation content.

      This is an asynchronous operation that returns a request_id for polling.'
  - info:
      name: 'Generate a video from a text prompt and optionally an image.

        This is an asynchronous operation that returns a request_id for polling.'
      type: http
    http:
      method: POST
      url: '{{baseUrl}}/v1/videos/generations'
      body:
        type: json
        data: '{}'
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Generate a video from a text prompt and optionally an image.

      This is an asynchronous operation that returns a request_id for polling.'
  - info:
      name: Get the result of a deferred video generation request.
      type: http
    http:
      method: GET
      url: '{{baseUrl}}/v1/videos/:request_id'
      params:
      - name: request_id
        value: ''
        type: path
        description: The deferred request id returned by a previous video generation request.
      auth:
        type: bearer
        token: '{{bearerToken}}'
    docs: 'Returns the current status of a video generation job. When the job completes

      successfully the response contains the generated video URL. When the job fails

      the response contains a structured `error` object with a machine-readable

      `code` and a human-readable `message`.


      Both successful and failed completions return HTTP 200 — use the `status`

      field (`"done"` or `"failed"`) to distinguish between the two.'
bundled: true