Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/xai/llms.txt

Use this file to discover all available pages before exploring further.

The aisdk/xai provider ships a bundled model catalog (resources/models.json) that maps every supported Grok model ID — or ID prefix — to its modality, status, and capability set. When you pass a model ID to XAI::model() or XAI::image(), the provider resolves that ID against the catalog at runtime so that capability checks are always based on the official catalog definition rather than hard-coded values in your application code.

Text models

The catalog contains three wildcard text-model families. The * suffix is a prefix-match wildcard: any model ID that starts with the listed prefix resolves to that catalog entry. For example, grok-4, grok-4-turbo, and grok-4.3 all match the grok-4* entry.
Model patternStatusModality
grok-4*stabletext
grok-3*stabletext
grok-2*stabletext

Image models

Model IDStatusModality
grok-imagine-image-qualitystableimage
grok-imagine-image-quality is xAI’s dedicated image-generation model. It accepts both text prompts and image inputs and returns generated images via the /v1/images/generations endpoint. Unlike text models it does not expose streaming, tool calling, or structured output.

Using a model

Instantiate any model by passing its exact ID (text) or the fixed image model ID to the appropriate factory method on the XAI facade:
use AiSdk\XAI;

// Text model — any concrete grok-4* ID works here
$textModel = XAI::model('grok-4');

// Image model
$imageModel = XAI::image('grok-imagine-image-quality');
XAI::model() returns a TextModelInterface backed by XAITextModel, while XAI::image() returns an ImageModelInterface backed by XAIImageModel. Both classes resolve capabilities from the catalog automatically.

Fallback behaviour

If you pass a model ID that does not match any catalog entry — for example, a brand-new model that was released after the installed version of aisdk/xai — the provider does not throw an error. Instead, XAITextModel::capability() detects that the catalog returned an empty capability list for the unknown ID and returns a supported CapabilitySupport value for Capability::TextGeneration with the source set to unknown-model-fallback. This means you can immediately use a newly released Grok text model without upgrading the package; only the capability introspection will be incomplete until the catalog is updated.
Model IDs are forwarded directly to the xAI API without modification. Always check the official xAI documentation at https://docs.x.ai for the latest model names, as new models or renamed variants may not yet appear in the bundled catalog.

Build docs developers (and LLMs) love