Some AI models can expose their internal chain-of-thought as a separate reasoning or “thinking” trace before producing their final answer.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.
aisdk/core exposes this through the ->reasoning() method on PendingTextRequest and the Reasoning value object, giving you a portable, provider-agnostic way to control how much thinking budget a model receives.
Enabling Reasoning
Call->reasoning() on any Generate::text() chain before ->run(). You can pass either a Reasoning instance or a plain effort string.
Reasoning support is provider- and model-specific. The SDK requires
Capability::Reasoning to be advertised by the model before it sends the request — if the capability is missing, a CapabilityNotSupportedException is thrown without making any network call. Check your provider’s documentation to confirm which models support extended thinking.Effort Levels
Reasoning::effort(string $effort) accepts one of four named levels. Each level maps to a percentage of the model’s maximum reasoning budget:
| Constant | String | Budget Percentage |
|---|---|---|
Reasoning::EFFORT_MINIMAL | 'minimal' | 2% of max budget |
Reasoning::EFFORT_LOW | 'low' | 10% of max budget |
Reasoning::EFFORT_MEDIUM | 'medium' | 30% of max budget |
Reasoning::EFFORT_HIGH | 'high' | 60% of max budget |
ReasoningBudget::calculate() and is always clamped to at least MIN_BUDGET (1024 tokens) and at most the model’s declared maximum budget.
Token Budget
Reasoning::budget(int $tokens) sets an exact number of reasoning tokens. The value you pass is clamped by the provider driver:
- Lower bound:
MIN_BUDGET— 1024 tokens. Values below this are raised automatically. - Upper bound: The model’s declared maximum budget. Values above this are reduced automatically.
Shorthand String Syntax
Because->reasoning() is defined in the ConfiguresGeneration trait, it also accepts a plain string that is forwarded to Reasoning::effort(). This removes the use AiSdk\Reasoning import when the effort level is all you need:
Reasoning::EFFORT_MEDIUM:
Reading the Reasoning Trace
After->run() completes, the model’s thinking text is available on $result->reasoning. It is null when the model did not emit a reasoning trace (either because reasoning was not requested or the provider does not support it).
The ReasoningBudget Class
Provider drivers use ReasoningBudget internally to translate a portable Reasoning value into a concrete token count. The default percentages and minimum budget are defined as overridable constants, so provider packages can subclass ReasoningBudget to apply provider-specific curves or clamping logic without changing the public API.
ReasoningBudget directly unless you are writing a provider driver. From application code, Reasoning::effort() and Reasoning::budget() are the only two entry points.
Required Capability
The SDK checks forCapability::Reasoning on the model before the request is dispatched. If you are registering a custom model, include it explicitly: