Skip to main content

Documentation Index

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

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

Capability is a pure PHP enum that provides a stable, provider-agnostic vocabulary for describing what a model can do. Provider adapters declare which capabilities they support, and the SDK uses these declarations to gate features and surface CapabilityNotSupportedException when a requested capability is absent. New cases are added as feature slices land; a model must never advertise a capability it cannot honor.

Capability enum cases

CaseString nameDescription
TextGenerationtext_generationModel can generate text responses.
StreamingstreamingModel supports token-by-token streaming.
ToolCallingtool_callingModel can call tools and return structured function invocations.
StructuredOutputstructured_outputModel supports constrained JSON output validated against a schema.
ReasoningreasoningModel supports extended thinking/reasoning before producing output.
ImageGenerationimage_generationModel can generate images from text prompts.
TextInputtext_inputModel accepts text as input.
ImageInputimage_inputModel accepts image input (also known as vision).
AudioInputaudio_inputModel accepts audio input.
FileInputfile_inputModel accepts uploaded files as input.

Static methods

Capability::fromName(string $name)
Capability | null
Resolves a string name to its corresponding Capability case. Accepts both the canonical snake_case names and provider aliases (e.g. 'vision' maps to Capability::ImageInput). Returns null for unrecognised strings.
name
string
required
The string capability name to look up. Recognised values: text_generation, streaming, tool_calling, structured_output, reasoning, image_generation, text_input, image_input, vision, audio_input, file_input.
$cap = Capability::fromName('tool_calling');  // Capability::ToolCalling
$cap = Capability::fromName('vision');         // Capability::ImageInput
$cap = Capability::fromName('unknown');        // null
Capability::name()
string
Returns the canonical snake_case string name for this enum case. This is the inverse of fromName().
Capability::ImageInput->name();   // 'image_input'
Capability::ToolCalling->name();  // 'tool_calling'

CapabilitySupport

CapabilitySupport is the value object that provider adapters return to describe how — or whether — a specific capability is available for a given model. It is constructed exclusively through its three static factory methods.
capability
Capability
required
The capability this support descriptor refers to.
state
CapabilitySupportState
required
Whether the capability is natively supported, not supported, or achieved through an adapter strategy.
reason
string | null
A human-readable explanation of why the capability is not supported, when state is NotSupported. null otherwise.
source
string | null
An optional hint indicating the origin of the support declaration (e.g. a feature flag name or model identifier). Used for diagnostics.
strategy
string | null
Describes the adaptation strategy used when state is Adapted — for example 'system-prompt-injection' or 'json-mode'.
metadata
array<string, mixed>
required
Arbitrary key–value metadata attached to this support descriptor by the provider adapter.

Static factories

CapabilitySupport::supported(Capability $capability, ?string $source, array $metadata)
CapabilitySupport
Creates a descriptor indicating the capability is natively supported.
capability
Capability
required
The capability being declared as supported.
source
string | null
Optional provenance hint.
metadata
array<string, mixed>
Optional extra metadata.
CapabilitySupport::notSupported(Capability $capability, ?string $reason, array $metadata)
CapabilitySupport
Creates a descriptor indicating the capability is not available for this model.
capability
Capability
required
The capability being declared as unsupported.
reason
string | null
A human-readable explanation for the lack of support.
metadata
array<string, mixed>
Optional extra metadata.
CapabilitySupport::adapted(Capability $capability, string $strategy, ?string $source, array $metadata)
CapabilitySupport
Creates a descriptor indicating the capability is available through an adapter strategy rather than native model support.
capability
Capability
required
The capability being declared as adapted.
strategy
string
required
Describes how the capability is emulated (e.g. 'json-mode', 'system-prompt-injection').
source
string | null
Optional provenance hint.
metadata
array<string, mixed>
Optional extra metadata.

Instance methods

isSupported()
bool
Returns true when state is Supported or Adapted. Returns false only when state is NotSupported. Use this for boolean capability checks without inspecting the state enum directly.

CapabilitySupportState enum

CapabilitySupportState is a string-backed enum with three cases that classify how a CapabilitySupport was declared.
CaseString valueMeaning
Supported'supported'The model natively supports this capability.
NotSupported'not_supported'The model does not support this capability.
Adapted'adapted'The capability is available via an adapter strategy, not native model support.

FinishReason enum

FinishReason is a string-backed enum that appears on TextResult and FinishPart to describe why a model stopped generating.
CaseString valueDescription
Stop'stop'The model reached a natural stopping point.
Length'length'Generation was truncated at the token or character limit.
ToolCalls'tool-calls'The model paused to issue one or more tool calls.
ContentFilter'content-filter'Output was blocked by a content safety or moderation filter.
Error'error'Generation was halted due to an error condition.
Unknown'unknown'The provider returned an unrecognised or missing stop reason.

Code example

use AiSdk\Capability;
use AiSdk\CapabilitySupport;
use AiSdk\CapabilitySupportState;

// Resolve a string name to an enum case
$cap = Capability::fromName('tool_calling');
echo $cap->name(); // 'tool_calling'

// Declare that a model supports streaming natively
$support = CapabilitySupport::supported(Capability::Streaming, source: 'model-card');
var_dump($support->isSupported()); // true
echo $support->state->value;       // 'supported'

// Declare adapted structured output via JSON mode
$jsonModeSupport = CapabilitySupport::adapted(
    capability: Capability::StructuredOutput,
    strategy: 'json-mode',
);
var_dump($jsonModeSupport->isSupported()); // true
echo $jsonModeSupport->state->value;       // 'adapted'

// Declare that a model lacks audio input
$noAudio = CapabilitySupport::notSupported(
    capability: Capability::AudioInput,
    reason: 'This model only accepts text and image inputs.',
);
var_dump($noAudio->isSupported()); // false

// Check a finish reason
use AiSdk\FinishReason;

$result = $ai->text('Summarise the TCP/IP stack.');
echo match ($result->finishReason) {
    FinishReason::Stop          => 'Complete.',
    FinishReason::Length        => 'Truncated — raise max_tokens.',
    FinishReason::ToolCalls     => 'Model requested tool execution.',
    FinishReason::ContentFilter => 'Blocked by content filter.',
    FinishReason::Error         => 'Generation error.',
    FinishReason::Unknown       => 'Unknown stop reason.',
};

Build docs developers (and LLMs) love