API Documentation

Models and Pricing

xAI provides the following models through its API:

ModelInputOutputContext (Tokens)Price (Per Million Tokens)
grok-2-vision-1212
image
text
text
8192

Text input

$2.00

Image input

$2.00

Completion

$10.00

grok-2-1212
text
text
131072

Text input

$2.00

Image input

-

Completion

$10.00

grok-vision-beta
image
text
text
8192

Text input

$5.00

Image input

$5.00

Completion

$15.00

grok-beta
text
text
131072

Text input

$5.00

Image input

-

Completion

$15.00

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

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

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


  • 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.