Skip to main content

Documentation Index

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

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

Every model entry in the bundled resources/models.json catalog declares an explicit list of capabilities. Knowing what a model supports before you call it lets you branch your application logic safely — for example, only enabling streaming for models that advertise it, or choosing a different model when tool calling is required. The SDK exposes this information through the supports() and capabilities() methods available on every model instance.

Available capabilities

The following capability values are used across the catalog. Each is represented by a case on the AiSdk\Capability enum:
CapabilityEnum caseDescription
text_generationCapability::TextGenerationModel can produce text completions
streamingCapability::StreamingModel supports server-sent event streaming
structured_outputCapability::StructuredOutputModel can return JSON matching a schema
reasoningCapability::ReasoningModel exposes a chain-of-thought reasoning trace
tool_callingCapability::ToolCallingModel supports function / tool call requests
text_inputCapability::TextInputModel accepts text as input
image_inputCapability::ImageInputModel accepts image data as input
image_generationCapability::ImageGenerationModel can generate image output
audio_inputCapability::AudioInputModel accepts audio as input
file_inputCapability::FileInputModel accepts file attachments as input

Checking capabilities

Call ->supports(Capability::X) on any model instance to get a boolean result. The method consults the bundled catalog and returns true only when the capability is listed for that model ID.
use AiSdk\Capability;
use AiSdk\OpenRouter;

OpenRouter::create(['apiKey' => 'or-test']);

// Check reasoning support on Claude Sonnet 4
$model = OpenRouter::model('anthropic/claude-sonnet-4');
$model->supports(Capability::Reasoning); // true

// Check image input support on Grok 4.3
$model = OpenRouter::model('x-ai/grok-4.3');
$model->supports(Capability::ImageInput); // true

// Check image generation for an image model
$imageModel = OpenRouter::image('x-ai/grok-imagine-image-quality');
$imageModel->supports(Capability::ImageGeneration); // true
These exact assertions come from the SDK’s own test suite and reflect real entries in the bundled catalog. You can also use capability checks to guard conditional code paths:
use AiSdk\Capability;
use AiSdk\Generate;
use AiSdk\OpenRouter;

OpenRouter::create(['apiKey' => 'or-...']);

$model = OpenRouter::model('google/gemini-3.5-flash');

if ($model->supports(Capability::Streaming)) {
    $stream = Generate::text('Tell me a story')
        ->model($model)
        ->stream();

    foreach ($stream as $chunk) {
        echo $chunk->text;
    }
} else {
    $result = Generate::text('Tell me a story')
        ->model($model)
        ->run();

    echo $result->text;
}

Getting all capabilities

Call ->capabilities() to retrieve every capability the model supports as an array. The return type is array<int, Capability>.
use AiSdk\OpenRouter;

OpenRouter::create(['apiKey' => 'or-...']);

$model = OpenRouter::model('anthropic/claude-sonnet-4');
$capabilities = $model->capabilities();
// e.g. [Capability::TextGeneration, Capability::Streaming, Capability::ToolCalling,
//        Capability::Reasoning, Capability::TextInput,
//        Capability::ImageInput, Capability::FileInput]

foreach ($capabilities as $capability) {
    echo $capability->value . PHP_EOL;
}
The same method is available on image model instances returned by OpenRouter::image().

Fallback for unknown models

When a model ID is not present in the bundled catalog, capabilities() returns an empty array. As a deliberate fallback, OpenRouterTextModel::capability() treats Capability::TextGeneration as supported for any model whose catalog entry is missing, using the internal source label 'unknown-model-fallback'. This ensures that unknown models remain usable for basic text generation even when the catalog has not yet been updated to include them. All other capabilities — including Streaming, Reasoning, ToolCalling, and ImageInput — return unsupported for unknown models.
use AiSdk\Capability;
use AiSdk\OpenRouter;

OpenRouter::create(['apiKey' => 'or-...']);

$model = OpenRouter::model('hypothetical/new-model');

$model->supports(Capability::TextGeneration); // true  (fallback)
$model->supports(Capability::Streaming);      // false (not in catalog)
$model->supports(Capability::Reasoning);      // false (not in catalog)
Always check $model->supports(Capability::Streaming) before calling stream(). Attempting to stream a response from a model that does not support it will result in a runtime error from the underlying HTTP client.

Build docs developers (and LLMs) love