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.

Every model in aisdk/xai exposes a structured capability system. When you call ->supports() or ->capability() on a model instance, the provider resolves the capability against three sources in order: any per-instance configured override, a custom ModelRegistry entry (if you registered a custom definition), and finally the bundled resources/models.json catalog. This layered resolution means the catalog acts as a sensible default while still allowing you to extend or override it for your own use cases.

Capabilities table

The table below shows which capabilities are declared for each model family in the catalog.
Capabilitygrok-4*grok-3*grok-2*grok-imagine-image-quality
text_generation
streaming
tool_calling
structured_output
reasoning
text_input
image_input
image_generation
Key observations:
  • Reasoning is available on grok-4* and grok-3* only. The grok-2* family predates xAI’s reasoning API and does not expose this capability.
  • Image generation is exclusive to grok-imagine-image-quality.
  • All model families accept both text input and image input, making multimodal prompts possible across the entire range.
  • grok-imagine-image-quality has no streaming, tool calling, structured output, or text generation capabilities — it is a pure image-generation model.

Checking capabilities at runtime

Use ->supports() for a simple boolean check, or ->capability() to retrieve a CapabilitySupport value that also carries metadata (such as the resolution source):
use AiSdk\Capability;
use AiSdk\XAI;

$model = XAI::model('grok-4');

if ($model->supports(Capability::Reasoning)) {
    // safe to use reasoning
}

$support = $model->capability(Capability::ToolCalling);
CapabilitySupport::isSupported() returns true when the capability is present. The source property on the returned object tells you where the support was determined — catalog, registry, or unknown-model-fallback for unrecognised model IDs.

The Capability enum

The PHP AI SDK exposes capabilities as a typed enum. The cases relevant to xAI models are:
Enum caseCatalog key
Capability::TextGenerationtext_generation
Capability::Streamingstreaming
Capability::ToolCallingtool_calling
Capability::StructuredOutputstructured_output
Capability::Reasoningreasoning
Capability::TextInputtext_input
Capability::ImageInputimage_input
Capability::ImageGenerationimage_generation
Always use the enum cases rather than raw strings when calling ->supports() or ->capability() so that your code benefits from IDE autocompletion and remains compatible with future SDK versions.

Custom capability override

If the bundled catalog does not reflect the actual capabilities of a model you are using — for example, because xAI has extended an existing model with new functionality between aisdk/xai releases — you can register a custom definition via the ModelRegistry on a custom XAIProvider instance:
use AiSdk\Capability;
use AiSdk\Support\ModelRegistry;
use AiSdk\XAI\XAIOptions;
use AiSdk\XAI\XAIProvider;

$registry = new ModelRegistry;
$registry->register('xai', 'grok-2-custom', [
    Capability::TextGeneration,
    Capability::Streaming,
    Capability::ToolCalling,
    Capability::Reasoning, // override: enable reasoning for this model
    Capability::TextInput,
    Capability::ImageInput,
]);

$provider = new XAIProvider(XAIOptions::fromArray(['apiKey' => '...']), $registry);
$model = $provider->textModel('grok-2-custom');
Any capability returned by the ModelRegistry takes precedence over the catalog, allowing per-instance overrides without modifying the shared catalog file.

Build docs developers (and LLMs) love