Provider options namespacing and multi-provider support
Provider options are set via the `providerOptions` property on functions like `generateText` and `streamText`. They are namespaced by provider name (e.g. `openai`, `anthropic`), allowing you to include options for multiple providers in the same call. Only the options matching the active provider are used.
OpenAI reasoningEffort values and behaviors
The `reasoningEffort` option for OpenAI reasoning models controls how much internal reasoning the model performs. Valid values are: 'none' (no reasoning, GPT-5.1 models only), 'minimal' (bare-minimum reasoning), 'low' (fast, concise reasoning), 'medium' (balanced, default), 'high' (thorough reasoning), and 'xhigh' (maximum reasoning, GPT-5.1-Codex-Max only). The 'none' and 'xhigh' values are only supported on specific models.
OpenAI reasoningSummary option for thinking models
The `reasoningSummary` option surfaces the model's thought process when working with reasoning models. When `reasoningEffort` is set to a value other than 'none', the OpenAI Responses provider defaults `reasoningSummary` to 'detailed'. Valid values are: 'auto' (condensed summary of reasoning) and 'detailed' (comprehensive reasoning output). Set `reasoningSummary: null` to omit reasoning summaries.
OpenAI textVerbosity option values
The `textVerbosity` option controls the length and detail of the model's text response independently of reasoning. Valid values are: 'low' (terse, minimal responses), 'medium' (balanced detail, default), and 'high' (verbose, comprehensive responses).
Anthropic thinking option for extended reasoning
Anthropic's thinking feature gives Claude models a dedicated thinking phase before they respond. It is enabled by providing a `thinking` object with `type: 'enabled'` and a `budgetTokens` value that sets the upper limit on tokens the model can use for internal reasoning. Higher budgets allow deeper reasoning but increase latency and cost.
Anthropic thinking support models
Thinking is supported on claude-opus-4-20250514, claude-sonnet-4-20250514, and claude-sonnet-4-5-20250929 models.
Anthropic effort option values
The `effort` option provides a simpler way to control reasoning depth without specifying a token budget. It affects thinking, text responses, and function calls. Valid values are: 'low' (minimal reasoning, fastest responses), 'medium' (balanced reasoning), and 'high' (thorough reasoning, default).
Anthropic speed option for claude-opus-4-6
For claude-opus-4-6, the `speed` option enables faster output token generation. Valid values are: 'fast' (approximately 2.5x faster output token speeds) and 'standard' (default).
Provider options with AI Gateway routing
Provider options work with the Vercel AI Gateway by using the underlying provider name (e.g. `openai`, `anthropic`) as the key, not `gateway`. The AI Gateway forwards these options to the target provider automatically. You can combine gateway-specific options (like routing and fallbacks) with provider-specific options in the same call.
OpenAI reasoningEffort example with generateText
Example code showing how to use the `reasoningEffort` option with OpenAI's reasoning models:
```ts
import {
openai,
type OpenAILanguageModelResponsesOptions,
} from '@ai-sdk/openai';
import { generateText } from 'ai';
const result = await generateText({
model: openai('gpt-5.2'),
prompt: 'Invent a new holiday and describe its traditions.',
providerOptions: {
openai: {
reasoningEffort: 'low', // 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
} satisfies OpenAILanguageModelResponsesOptions,
},
});
console.log('Text:', result.text);
console.log('Usage:', result.usage);
console.log(
'Reasoning tokens:',
result.finalStep.providerMetadata?.openai?.reasoningTokens,
);
```
OpenAI reasoningSummary non-streaming example
Example code showing how to access reasoning summaries with generateText:
```ts
import {
openai,
type OpenAILanguageModelResponsesOptions,
} from '@ai-sdk/openai';
import { generateText } from 'ai';
const result = await generateText({
model: openai('gpt-5.2'),
prompt: 'Tell me about the Mission burrito debate in San Francisco.',
providerOptions: {
openai: {
reasoningSummary: 'auto',
} satisfies OpenAILanguageModelResponsesOptions,
},
});
console.log('Reasoning:', result.finalStep.reasoning);
```
Anthropic thinking option example
Example code showing how to enable thinking with a token budget:
```ts
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const { text, reasoning, reasoningText } = await generateText({
model: anthropic('claude-opus-4-20250514'),
prompt: 'How many people will live in the world in 2040?',
providerOptions: {
anthropic: {
thinking: { type: 'enabled', budgetTokens: 12000 },
} satisfies AnthropicLanguageModelOptions,
},
});
console.log('Reasoning:', reasoningText);
console.log('Answer:', text);
```
Anthropic effort option example
Example code showing how to use the `effort` option:
```ts
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const { text, usage } = await generateText({
model: anthropic('claude-opus-4-20250514'),
prompt: 'How many people will live in the world in 2040?',
providerOptions: {
anthropic: {
effort: 'low', // 'low' | 'medium' | 'high'
} satisfies AnthropicLanguageModelOptions,
},
});
```
Anthropic speed option example
Example code showing how to enable fast mode for claude-opus-4-6:
```ts
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const { text } = await generateText({
model: anthropic('claude-opus-4-6'),
prompt: 'Write a short poem about the sea.',
providerOptions: {
anthropic: {
speed: 'fast', // 'fast' | 'standard'
} satisfies AnthropicLanguageModelOptions,
},
});
```
Combining OpenAI provider options example
Example code showing how to combine multiple OpenAI provider options:
```ts
import {
openai,
type OpenAILanguageModelResponsesOptions,
} from '@ai-sdk/openai';
import { generateText } from 'ai';
const result = await generateText({
model: openai('gpt-5.2'),
prompt: 'What are the implications of quantum computing for cryptography?',
providerOptions: {
openai: {
reasoningEffort: 'high',
reasoningSummary: 'detailed',
} satisfies OpenAILanguageModelResponsesOptions,
},
});
```
Combining Anthropic provider options example
Example code showing how to combine thinking with effort level:
```ts
import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const result = await generateText({
model: anthropic('claude-opus-4-20250514'),
prompt: 'Explain the Riemann hypothesis in simple terms.',
providerOptions: {
anthropic: {
thinking: { type: 'enabled', budgetTokens: 8000 },
effort: 'medium',
} satisfies AnthropicLanguageModelOptions,
},
});
```
AI Gateway with provider options example
Example code showing how to use provider options with the Vercel AI Gateway:
```ts
import type { OpenAILanguageModelResponsesOptions } from '@ai-sdk/openai';
import { generateText } from 'ai';
const result = await generateText({
model: 'openai/gpt-5.2', // AI Gateway model string
prompt: 'What are the implications of quantum computing for cryptography?',
providerOptions: {
openai: {
reasoningEffort: 'high',
reasoningSummary: 'detailed',
} satisfies OpenAILanguageModelResponsesOptions,
},
});
```
Type safety for provider options
Each provider exports a type for its options that can be used with `satisfies` to get autocomplete and catch typos at build time. For OpenAI, import `OpenAILanguageModelResponsesOptions`. For Anthropic, import `AnthropicLanguageModelOptions`.