ai 6.0.111 → 6.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.112
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [db3d4ca]
8
+ - @ai-sdk/gateway@3.0.64
9
+
3
10
  ## 6.0.111
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1230,7 +1230,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
1230
1230
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1231
1231
 
1232
1232
  // src/version.ts
1233
- var VERSION = true ? "6.0.111" : "0.0.0-test";
1233
+ var VERSION = true ? "6.0.112" : "0.0.0-test";
1234
1234
 
1235
1235
  // src/util/download/download.ts
1236
1236
  var download = async ({
package/dist/index.mjs CHANGED
@@ -1121,7 +1121,7 @@ import {
1121
1121
  } from "@ai-sdk/provider-utils";
1122
1122
 
1123
1123
  // src/version.ts
1124
- var VERSION = true ? "6.0.111" : "0.0.0-test";
1124
+ var VERSION = true ? "6.0.112" : "0.0.0-test";
1125
1125
 
1126
1126
  // src/util/download/download.ts
1127
1127
  var download = async ({
@@ -153,7 +153,7 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
153
153
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
154
154
 
155
155
  // src/version.ts
156
- var VERSION = true ? "6.0.111" : "0.0.0-test";
156
+ var VERSION = true ? "6.0.112" : "0.0.0-test";
157
157
 
158
158
  // src/util/download/download.ts
159
159
  var download = async ({
@@ -132,7 +132,7 @@ import {
132
132
  } from "@ai-sdk/provider-utils";
133
133
 
134
134
  // src/version.ts
135
- var VERSION = true ? "6.0.111" : "0.0.0-test";
135
+ var VERSION = true ? "6.0.112" : "0.0.0-test";
136
136
 
137
137
  // src/util/download/download.ts
138
138
  var download = async ({
@@ -0,0 +1,337 @@
1
+ ---
2
+ title: Provider Options
3
+ description: Learn how to use provider-specific options to control reasoning, caching, and other advanced features.
4
+ ---
5
+
6
+ # Provider Options
7
+
8
+ Provider options let you pass provider-specific configuration that goes beyond the [standard settings](/docs/ai-sdk-core/settings) shared by all providers. They are set via the `providerOptions` property on functions like `generateText` and `streamText`.
9
+
10
+ ```ts
11
+ const result = await generateText({
12
+ model: openai('gpt-5.2'),
13
+ prompt: 'Explain quantum entanglement.',
14
+ providerOptions: {
15
+ openai: {
16
+ reasoningEffort: 'low',
17
+ },
18
+ },
19
+ });
20
+ ```
21
+
22
+ Provider options are namespaced by the provider name (e.g. `openai`, `anthropic`) so you can even include options for multiple providers in the same call — only the options matching the active provider are used. See [Prompts: Provider Options](/docs/foundations/prompts#provider-options) for details on applying options at the message and message-part level.
23
+
24
+ ## Common Provider Options
25
+
26
+ The sections below cover the most frequently used provider options, focusing on reasoning and output control for OpenAI and Anthropic. For a complete reference, see the individual provider pages:
27
+
28
+ - [OpenAI provider options](/providers/ai-sdk-providers/openai)
29
+ - [Anthropic provider options](/providers/ai-sdk-providers/anthropic)
30
+
31
+ ---
32
+
33
+ ## OpenAI
34
+
35
+ ### Reasoning Effort
36
+
37
+ For reasoning models (e.g. `o3`, `o4-mini`, `gpt-5.2`), `reasoningEffort` controls how much internal reasoning the model performs before responding. Lower values are faster and cheaper; higher values produce more thorough answers.
38
+
39
+ ```ts
40
+ import {
41
+ openai,
42
+ type OpenAILanguageModelResponsesOptions,
43
+ } from '@ai-sdk/openai';
44
+ import { generateText } from 'ai';
45
+
46
+ const { text, usage, providerMetadata } = await generateText({
47
+ model: openai('gpt-5.2'),
48
+ prompt: 'Invent a new holiday and describe its traditions.',
49
+ providerOptions: {
50
+ openai: {
51
+ reasoningEffort: 'low', // 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
52
+ } satisfies OpenAILanguageModelResponsesOptions,
53
+ },
54
+ });
55
+
56
+ console.log('Reasoning tokens:', providerMetadata?.openai?.reasoningTokens);
57
+ ```
58
+
59
+ | Value | Behavior |
60
+ | ----------- | ------------------------------------------ |
61
+ | `'none'` | No reasoning (GPT-5.1 models only) |
62
+ | `'minimal'` | Bare-minimum reasoning |
63
+ | `'low'` | Fast, concise reasoning |
64
+ | `'medium'` | Balanced (default) |
65
+ | `'high'` | Thorough reasoning |
66
+ | `'xhigh'` | Maximum reasoning (GPT-5.1-Codex-Max only) |
67
+
68
+ <Note>
69
+ `'none'` and `'xhigh'` are only supported on specific models. Using them with
70
+ unsupported models will result in an error.
71
+ </Note>
72
+
73
+ ### Reasoning Summary
74
+
75
+ When working with reasoning models, you may want to see _how_ the model arrived at its answer. The `reasoningSummary` option surfaces the model's thought process.
76
+
77
+ #### Streaming
78
+
79
+ ```ts
80
+ import {
81
+ openai,
82
+ type OpenAILanguageModelResponsesOptions,
83
+ } from '@ai-sdk/openai';
84
+ import { streamText } from 'ai';
85
+
86
+ const result = streamText({
87
+ model: openai('gpt-5.2'),
88
+ prompt: 'Tell me about the Mission burrito debate in San Francisco.',
89
+ providerOptions: {
90
+ openai: {
91
+ reasoningSummary: 'detailed', // 'auto' | 'detailed'
92
+ } satisfies OpenAILanguageModelResponsesOptions,
93
+ },
94
+ });
95
+
96
+ for await (const part of result.fullStream) {
97
+ if (part.type === 'reasoning') {
98
+ console.log(`Reasoning: ${part.textDelta}`);
99
+ } else if (part.type === 'text-delta') {
100
+ process.stdout.write(part.textDelta);
101
+ }
102
+ }
103
+ ```
104
+
105
+ #### Non-streaming
106
+
107
+ ```ts
108
+ import {
109
+ openai,
110
+ type OpenAILanguageModelResponsesOptions,
111
+ } from '@ai-sdk/openai';
112
+ import { generateText } from 'ai';
113
+
114
+ const result = await generateText({
115
+ model: openai('gpt-5.2'),
116
+ prompt: 'Tell me about the Mission burrito debate in San Francisco.',
117
+ providerOptions: {
118
+ openai: {
119
+ reasoningSummary: 'auto',
120
+ } satisfies OpenAILanguageModelResponsesOptions,
121
+ },
122
+ });
123
+
124
+ console.log('Reasoning:', result.reasoning);
125
+ ```
126
+
127
+ | Value | Behavior |
128
+ | ------------ | ------------------------------ |
129
+ | `'auto'` | Condensed summary of reasoning |
130
+ | `'detailed'` | Comprehensive reasoning output |
131
+
132
+ ### Text Verbosity
133
+
134
+ Control the length and detail of the model's text response independently of reasoning:
135
+
136
+ ```ts
137
+ import {
138
+ openai,
139
+ type OpenAILanguageModelResponsesOptions,
140
+ } from '@ai-sdk/openai';
141
+ import { generateText } from 'ai';
142
+
143
+ const result = await generateText({
144
+ model: openai('gpt-5-mini'),
145
+ prompt: 'Write a poem about a boy and his first pet dog.',
146
+ providerOptions: {
147
+ openai: {
148
+ textVerbosity: 'low', // 'low' | 'medium' | 'high'
149
+ } satisfies OpenAILanguageModelResponsesOptions,
150
+ },
151
+ });
152
+ ```
153
+
154
+ | Value | Behavior |
155
+ | ---------- | -------------------------------- |
156
+ | `'low'` | Terse, minimal responses |
157
+ | `'medium'` | Balanced detail (default) |
158
+ | `'high'` | Verbose, comprehensive responses |
159
+
160
+ ---
161
+
162
+ ## Anthropic
163
+
164
+ ### Thinking (Extended Reasoning)
165
+
166
+ Anthropic's thinking feature gives Claude models a dedicated "thinking" phase before they respond. You enable it by providing a `thinking` object with a token budget.
167
+
168
+ ```ts
169
+ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
170
+ import { generateText } from 'ai';
171
+
172
+ const { text, reasoning, reasoningText } = await generateText({
173
+ model: anthropic('claude-opus-4-20250514'),
174
+ prompt: 'How many people will live in the world in 2040?',
175
+ providerOptions: {
176
+ anthropic: {
177
+ thinking: { type: 'enabled', budgetTokens: 12000 },
178
+ } satisfies AnthropicLanguageModelOptions,
179
+ },
180
+ });
181
+
182
+ console.log('Reasoning:', reasoningText);
183
+ console.log('Answer:', text);
184
+ ```
185
+
186
+ The `budgetTokens` value sets the upper limit on how many tokens the model can use for its internal reasoning. Higher budgets allow deeper reasoning but increase latency and cost.
187
+
188
+ <Note>
189
+ Thinking is supported on `claude-opus-4-20250514`, `claude-sonnet-4-20250514`,
190
+ and `claude-sonnet-4-5-20250929` models.
191
+ </Note>
192
+
193
+ ### Effort
194
+
195
+ The `effort` option provides a simpler way to control reasoning depth without specifying a token budget. It affects thinking, text responses, and function calls.
196
+
197
+ ```ts
198
+ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
199
+ import { generateText } from 'ai';
200
+
201
+ const { text, usage } = await generateText({
202
+ model: anthropic('claude-opus-4-20250514'),
203
+ prompt: 'How many people will live in the world in 2040?',
204
+ providerOptions: {
205
+ anthropic: {
206
+ effort: 'low', // 'low' | 'medium' | 'high'
207
+ } satisfies AnthropicLanguageModelOptions,
208
+ },
209
+ });
210
+ ```
211
+
212
+ | Value | Behavior |
213
+ | ---------- | ------------------------------------ |
214
+ | `'low'` | Minimal reasoning, fastest responses |
215
+ | `'medium'` | Balanced reasoning |
216
+ | `'high'` | Thorough reasoning (default) |
217
+
218
+ ### Fast Mode
219
+
220
+ For `claude-opus-4-6`, the `speed` option enables approximately 2.5x faster output token speeds:
221
+
222
+ ```ts
223
+ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
224
+ import { generateText } from 'ai';
225
+
226
+ const { text } = await generateText({
227
+ model: anthropic('claude-opus-4-6'),
228
+ prompt: 'Write a short poem about the sea.',
229
+ providerOptions: {
230
+ anthropic: {
231
+ speed: 'fast', // 'fast' | 'standard'
232
+ } satisfies AnthropicLanguageModelOptions,
233
+ },
234
+ });
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Combining Options
240
+
241
+ You can combine multiple provider options in a single call. For example, using both reasoning effort and reasoning summaries with OpenAI:
242
+
243
+ ```ts
244
+ import {
245
+ openai,
246
+ type OpenAILanguageModelResponsesOptions,
247
+ } from '@ai-sdk/openai';
248
+ import { generateText } from 'ai';
249
+
250
+ const result = await generateText({
251
+ model: openai('gpt-5.2'),
252
+ prompt: 'What are the implications of quantum computing for cryptography?',
253
+ providerOptions: {
254
+ openai: {
255
+ reasoningEffort: 'high',
256
+ reasoningSummary: 'detailed',
257
+ } satisfies OpenAILanguageModelResponsesOptions,
258
+ },
259
+ });
260
+ ```
261
+
262
+ Or enabling thinking with a low effort level for Anthropic:
263
+
264
+ ```ts
265
+ import { anthropic, AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
266
+ import { generateText } from 'ai';
267
+
268
+ const result = await generateText({
269
+ model: anthropic('claude-opus-4-20250514'),
270
+ prompt: 'Explain the Riemann hypothesis in simple terms.',
271
+ providerOptions: {
272
+ anthropic: {
273
+ thinking: { type: 'enabled', budgetTokens: 8000 },
274
+ effort: 'medium',
275
+ } satisfies AnthropicLanguageModelOptions,
276
+ },
277
+ });
278
+ ```
279
+
280
+ ## Using Provider Options with the AI Gateway
281
+
282
+ Provider options work the same way when using the [Vercel AI Gateway](/providers/ai-sdk-providers/ai-gateway). Use the underlying provider name (e.g. `openai`, `anthropic`) as the key — not `gateway`. The AI Gateway forwards these options to the target provider automatically.
283
+
284
+ ```ts
285
+ import type { OpenAILanguageModelResponsesOptions } from '@ai-sdk/openai';
286
+ import { generateText } from 'ai';
287
+
288
+ const result = await generateText({
289
+ model: 'openai/gpt-5.2', // AI Gateway model string
290
+ prompt: 'What are the implications of quantum computing for cryptography?',
291
+ providerOptions: {
292
+ openai: {
293
+ reasoningEffort: 'high',
294
+ reasoningSummary: 'detailed',
295
+ } satisfies OpenAILanguageModelResponsesOptions,
296
+ },
297
+ });
298
+ ```
299
+
300
+ You can also combine gateway-specific options (like routing and fallbacks) with provider-specific options in the same call:
301
+
302
+ ```ts
303
+ import type { AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
304
+ import type { GatewayLanguageModelOptions } from '@ai-sdk/gateway';
305
+ import { generateText } from 'ai';
306
+
307
+ const result = await generateText({
308
+ model: 'anthropic/claude-sonnet-4',
309
+ prompt: 'Explain quantum computing',
310
+ providerOptions: {
311
+ // Gateway-specific: control routing
312
+ gateway: {
313
+ order: ['vertex', 'anthropic'],
314
+ } satisfies GatewayLanguageModelOptions,
315
+ // Provider-specific: enable reasoning
316
+ anthropic: {
317
+ thinking: { type: 'enabled', budgetTokens: 12000 },
318
+ } satisfies AnthropicLanguageModelOptions,
319
+ },
320
+ });
321
+ ```
322
+
323
+ For more on gateway routing, fallbacks, and other gateway-specific options, see the [AI Gateway provider documentation](/providers/ai-sdk-providers/ai-gateway#provider-options).
324
+
325
+ ## Type Safety
326
+
327
+ Each provider exports a type for its options, which you can use with `satisfies` to get autocomplete and catch typos at build time:
328
+
329
+ ```ts
330
+ import { type OpenAILanguageModelResponsesOptions } from '@ai-sdk/openai';
331
+ import { type AnthropicLanguageModelOptions } from '@ai-sdk/anthropic';
332
+ ```
333
+
334
+ For a full list of available options, see the provider-specific documentation:
335
+
336
+ - [OpenAI Provider](/providers/ai-sdk-providers/openai)
337
+ - [Anthropic Provider](/providers/ai-sdk-providers/anthropic)
@@ -29,6 +29,12 @@ description: A section that covers foundational knowledge around LLMs and concep
29
29
  description: 'Learn about tools in the AI SDK.',
30
30
  href: '/docs/foundations/tools',
31
31
  },
32
+ {
33
+ title: 'Provider Options',
34
+ description:
35
+ 'Learn how to use provider-specific options for reasoning, caching, and more.',
36
+ href: '/docs/foundations/provider-options',
37
+ },
32
38
  {
33
39
  title: 'Streaming',
34
40
  description: 'Learn why streaming is used for AI applications.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.111",
3
+ "version": "6.0.112",
4
4
  "description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@opentelemetry/api": "1.9.0",
48
- "@ai-sdk/gateway": "3.0.63",
48
+ "@ai-sdk/gateway": "3.0.64",
49
49
  "@ai-sdk/provider": "3.0.8",
50
50
  "@ai-sdk/provider-utils": "4.0.17"
51
51
  },