API Documentation

Models and Pricing

xAI provides the following models through its API:

You can use the aliased model name if you want to automatically access the latest model version, or choose a model with version number to keep a consistent output. For example, grok-2 and grok-2-latest model names are aliased to the latest chat models.

Note your model access might vary depending on various factors such as geographical location, account limitations, etc.

For how the bills are charged or managing a team's API key permissions, visit Teams and Billing for more information.

For the most up-to-date information on your team's model availability, visit Models Page on xAI Console.


  • Chat models
    • No role order limitation: You can mix system, user, or assistant roles in any sequence for your conversation context.
  • Image input models
    • Maximum image size: 10MiB
    • Maximum number of images: No limit
    • Any image/text input order is accepted (e.g. text prompt can precede image prompt)

Each model can have one or multiple input and output capabilities. The input capabilities refer to which type(s) of prompt can the model accept in the request message body. The output capabilities refer to which type(s) of completion will the model generate in the response message body.

This is a prompt example for models with text input capability:

This is a prompt example for models with text and image input capabilities:


The context window determines the maximum amount of token accepted by the model in the prompt.

For more information on how token is counted, visit Usage, Tier and Rate Limits.

If you are sending the entire conversation history in the prompt for use cases like chat assistant, the sum of all the prompts in your conversation history must be no greater than the context window.