feat(provider): add new top-level reasoning parameter to spec and support it in generateText and streamText#13553
Conversation
|
|
||
| | Value | Behavior | | ||
| | -------------------- | --------------------------------------------------------------------------- | | ||
| | `'provider-default'` | Explicitly use the provider's default reasoning behavior (same as omitting) | |
There was a problem hiding this comment.
(default when omited) - then 1st sentence below can be removed
| 'abortSignal' | 'headers' | 'maxRetries' | 'reasoning' | ||
| > & { | ||
| reasoning?: LanguageModelV4CallOptions['reasoning']; | ||
| } { |
There was a problem hiding this comment.
this is strange. with my suggestion it could be removed
There was a problem hiding this comment.
I worked on adjusting this, however we still need it if we want the v4 spec to always expect a value here (i.e. not support undefined); because CallSettings will have reasoning optional whereas LanguageModelV4CallOptions will have reasoning required.
Alternatively, if we do support undefined in the v4 spec for reasoning, it would be a bit odd because undefined would be the same as passing 'provider-default'.
That was why I initially left the 'provider-default' value off in the spec. I agree supporting it makes sense, but then not sure about undefined / no value. WDYT?
There was a problem hiding this comment.
that is where you would set the default afaik
There was a problem hiding this comment.
now that we fully align reasoning in language model V4 with CallSettings (including making the parameter optional), this workaround is no longer needed.
|
@lgrammel Updated the language model v4 spec to also include Going to merge this once CI has passed, then I'll follow up with the PRs for the other relevant providers. |
|
🚀 Published in:
|
#13648) ## Background The new top-level `reasoning` parameter was added to the AI SDK spec and core in #13553. Providers need to be migrated to translate this parameter into their native reasoning/thinking configuration. ## Summary Migrates 7 providers to support the new top-level `reasoning` parameter: - **deepseek**: Maps `reasoning` to existing thinking support (already had infrastructure, just needed wiring) - **groq**: Maps `reasoning` to `reasoning_effort` in provider options - **xai**: Maps `reasoning` to `reasoning_effort` for both chat and responses models - **openai-compatible**: Maps `reasoning` to `reasoning_effort` in provider options - **open-responses**: Maps `reasoning` to `reasoning.effort` in the responses format - **alibaba**: Maps `reasoning` to `enable_thinking` + `thinking_budget` via token budget calculation - **cohere**: Maps `reasoning` to `thinking.type` + `thinking.token_budget` via token budget calculation - **fireworks**: Uses **openai-compatible** Together with #13649, this completes the work on #12516. ## Manual Verification Relevant examples were updated or added, then run for verification. ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) ## Future Work N/A ## Related Issues See #12516.
…rameter (#13649) ## Background A new top-level `reasoning` parameter was added to the AI SDK spec in #13553 and is supported in `generateText`/`streamText`. Providers that don't natively support reasoning configuration need to emit an unsupported warning when a custom reasoning value is passed, rather than silently ignoring it. ## Summary - Added unsupported-feature warnings to `perplexity`, `mistral`, and `prodia` providers when `isCustomReasoning(reasoning)` returns `true` - Added documentation to `architecture/provider-abstraction.md` explaining how providers should handle the `reasoning` parameter (effort mapping, budget mapping, or unsupported warning). Together with #13648, this completes the work on #12516. ## Manual Verification N/A ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) ## Future Work N/A ## Related Issues See #12516.
Background
Reasoning/thinking configuration has historically been handled entirely via
providerOptions, requiring provider-specific knowledge from callers and making it impossible to write portable reasoning code.Summary
Adds a top-level
reasoningparameter togenerateTextandstreamText(and the underlyingLanguageModelV4call options spec), as proposed in #12516. The parameter accepts a flat enum —'provider-default' | 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'— aligned with the OpenAI/OpenRouter convention. For the v4 spec,'provider-default'is omitted as that can be resolved at thegenerateTextandstreamTextlevel by simply omitting the value.Existing
providerOptionsfor each provider remain supported, both to help with a smooth transition path and to continue to support cases where a specificproviderOptionsbehavior may be more granular than what the new top-levelreasoningparameter allows.If reasoning-related keys are present in
providerOptions, they take full precedence and the top-levelreasoningparameter is ignored, so existing code continues to work without changes.Two helper functions are added to
provider-utilsto make provider-side mapping straightforward:mapReasoningToProviderEffort— maps the enum to a provider's native effort string, emitting a compatibility warning if coercion is needed.mapReasoningToProviderBudget— maps the enum to a token budget by multiplying the model's max output tokens by a percentage, clamped between a min and max budget.Provider migration status
reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)reasoningparameter #13648)Manual Verification
I ran all the relevant updated examples for each migrated provider, verifying they still work as before.
Checklist
pnpm changesetin the project root)Future Work
providerOptionsvalues that provide no benefit over the new top-levelreasoningparameterRelated Issues
Fixes #12516