ai 7.0.112 → 7.0.114

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +6 -6
  3. package/dist/index.d.ts +16 -0
  4. package/dist/index.js +378 -256
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +2 -1
  7. package/dist/internal/index.js +182 -78
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/02-foundations/02-providers-and-models.mdx +3 -0
  10. package/docs/02-foundations/03-prompts.mdx +1 -1
  11. package/docs/02-foundations/04-tools.mdx +2 -2
  12. package/docs/02-foundations/06-provider-options.mdx +11 -11
  13. package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
  14. package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
  15. package/docs/02-getting-started/03-nextjs-pages-router.mdx +3 -3
  16. package/docs/02-getting-started/04-svelte.mdx +7 -7
  17. package/docs/02-getting-started/05-nuxt.mdx +7 -7
  18. package/docs/02-getting-started/06-nodejs.mdx +3 -3
  19. package/docs/02-getting-started/07-expo.mdx +3 -3
  20. package/docs/02-getting-started/08-tanstack-start.mdx +3 -3
  21. package/docs/02-getting-started/09-coding-agents.mdx +1 -1
  22. package/docs/03-agents/03-workflows.mdx +2 -2
  23. package/docs/03-agents/04-loop-control.mdx +1 -1
  24. package/docs/03-agents/05-configuring-call-options.mdx +4 -2
  25. package/docs/03-agents/06-memory.mdx +2 -2
  26. package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
  27. package/docs/03-agents/06-tool-approvals.mdx +16 -0
  28. package/docs/03-agents/07-workflow-agent.mdx +11 -11
  29. package/docs/03-agents/08-terminal-ui.mdx +2 -2
  30. package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
  31. package/docs/03-ai-sdk-core/17-mcp-apps.mdx +1 -1
  32. package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
  33. package/docs/03-ai-sdk-core/26-reasoning.mdx +13 -12
  34. package/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
  35. package/docs/03-ai-sdk-core/32-evaluation.mdx +1 -1
  36. package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -2
  37. package/docs/03-ai-sdk-core/37-speech.mdx +8 -6
  38. package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
  39. package/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
  40. package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
  41. package/docs/03-ai-sdk-core/45-provider-management.mdx +21 -21
  42. package/docs/03-ai-sdk-core/60-telemetry.mdx +1 -1
  43. package/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
  44. package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +1 -1
  45. package/docs/04-ai-sdk-ui/02-chatbot.mdx +3 -3
  46. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
  47. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +1 -1
  48. package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
  49. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
  50. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
  51. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
  52. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +5 -3
  53. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -3
  54. package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
  55. package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
  56. package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +3 -3
  57. package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
  58. package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
  59. package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +18 -0
  60. package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +1 -1
  61. package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +4 -4
  62. package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
  63. package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +1 -1
  64. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
  65. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +1 -1
  66. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
  67. package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +1 -1
  68. package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
  69. package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
  70. package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
  71. package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
  72. package/package.json +11 -11
  73. package/src/embed/embed-many.ts +18 -2
  74. package/src/evaluate/evaluate.ts +1 -10
  75. package/src/generate-speech/generate-speech.ts +15 -4
  76. package/src/generate-speech/generated-audio-file.ts +0 -8
  77. package/src/generate-text/execute-tools-from-stream.ts +0 -2
  78. package/src/generate-text/generate-text.ts +1 -0
  79. package/src/generate-text/generated-file.ts +0 -8
  80. package/src/generate-text/invoke-tool-callbacks-from-stream.ts +9 -8
  81. package/src/generate-text/output.ts +0 -2
  82. package/src/generate-text/parse-tool-call.ts +38 -25
  83. package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
  84. package/src/generate-text/stream-text.ts +1 -0
  85. package/src/generate-text/to-response-messages.ts +7 -0
  86. package/src/generate-text/tool-call.ts +26 -0
  87. package/src/generate-text/validate-tool-approvals.ts +39 -3
  88. package/src/generate-video/generate-video.ts +0 -2
  89. package/src/middleware/extract-reasoning-middleware.ts +1 -1
  90. package/src/middleware/wrap-embedding-model.ts +9 -1
  91. package/src/model/get-embedding-model-provider-options-transformer.ts +17 -0
  92. package/src/prompt/content-part.ts +3 -0
  93. package/src/prompt/standardize-prompt.ts +2 -0
  94. package/src/registry/custom-provider.ts +12 -5
  95. package/src/telemetry/create-telemetry-dispatcher.ts +58 -6
  96. package/src/telemetry/filter-included-context.ts +57 -2
  97. package/src/ui/chat.ts +108 -17
  98. package/src/ui/convert-to-model-messages.ts +8 -0
  99. package/src/ui/direct-chat-transport.ts +2 -0
  100. package/src/ui/process-ui-message-stream.ts +6 -0
  101. package/src/ui/ui-messages.ts +10 -0
  102. package/src/ui/validate-ui-messages.ts +98 -132
  103. package/src/ui-message-stream/to-ui-message-chunk.ts +7 -0
  104. package/src/ui-message-stream/ui-message-chunks.ts +2 -0
  105. package/src/util/write-to-server-response.ts +0 -2
@@ -47,7 +47,7 @@ export async function sendMessage(message: string) {
47
47
  messages.update([...messages.get(), { role: 'user', content: message }]);
48
48
 
49
49
  const { value: stream } = await streamUI({
50
- model: openai('gpt-4o'),
50
+ model: openai('gpt-6-astra'),
51
51
  instructions: 'you are a friendly assistant!',
52
52
  messages: messages.get(),
53
53
  text: async function* ({ content, done }) {
@@ -187,7 +187,7 @@ import { getWeather } from '@/utils/queries';
187
187
  import { Weather } from '@/components/weather';
188
188
 
189
189
  const { value: stream } = await streamUI({
190
- model: openai('gpt-4o'),
190
+ model: openai('gpt-6-astra'),
191
191
  instructions: 'you are a friendly assistant!',
192
192
  messages,
193
193
  text: async function* ({ content, done }) {
@@ -399,7 +399,7 @@ import { openai } from '@ai-sdk/openai';
399
399
  import { streamUI } from '@ai-sdk/rsc';
400
400
 
401
401
  const { value: stream } = await streamUI({
402
- model: openai('gpt-4o'),
402
+ model: openai('gpt-6-astra'),
403
403
  instructions: 'you are a friendly assistant!',
404
404
  messages,
405
405
  initial: <div>Loading...</div>,
@@ -40,7 +40,7 @@ To see `generateText` in action, check out [these examples](#examples).
40
40
  {
41
41
  name: 'model',
42
42
  type: 'LanguageModel',
43
- description: "The language model to use. Example: openai('gpt-4o')",
43
+ description: "The language model to use. Example: openai('gpt-6-astra')",
44
44
  },
45
45
  {
46
46
  name: 'instructions',
@@ -1117,7 +1117,8 @@ To see `generateText` in action, check out [these examples](#examples).
1117
1117
  {
1118
1118
  name: 'modelId',
1119
1119
  type: 'string',
1120
- description: 'The specific model identifier (e.g., "gpt-4o").',
1120
+ description:
1121
+ 'The specific model identifier (e.g., "gpt-6-astra").',
1121
1122
  },
1122
1123
  {
1123
1124
  name: 'instructions',
@@ -1269,7 +1270,8 @@ To see `generateText` in action, check out [these examples](#examples).
1269
1270
  {
1270
1271
  name: 'modelId',
1271
1272
  type: 'string',
1272
- description: 'The specific model identifier (e.g., "gpt-4o").',
1273
+ description:
1274
+ 'The specific model identifier (e.g., "gpt-6-astra").',
1273
1275
  },
1274
1276
  {
1275
1277
  name: 'instructions',
@@ -42,7 +42,7 @@ To see `streamText` in action, check out [these examples](#examples).
42
42
  {
43
43
  name: 'model',
44
44
  type: 'LanguageModel',
45
- description: "The language model to use. Example: openai('gpt-4.1')",
45
+ description: "The language model to use. Example: openai('gpt-6-astra')",
46
46
  },
47
47
  {
48
48
  name: 'instructions',
@@ -2131,7 +2131,8 @@ To see `streamText` in action, check out [these examples](#examples).
2131
2131
  {
2132
2132
  name: 'modelId',
2133
2133
  type: 'string',
2134
- description: 'The specific model identifier (e.g., "gpt-4o").',
2134
+ description:
2135
+ 'The specific model identifier (e.g., "gpt-6-astra").',
2135
2136
  },
2136
2137
  {
2137
2138
  name: 'instructions',
@@ -2283,7 +2284,8 @@ To see `streamText` in action, check out [these examples](#examples).
2283
2284
  {
2284
2285
  name: 'modelId',
2285
2286
  type: 'string',
2286
- description: 'The specific model identifier (e.g., "gpt-4o").',
2287
+ description:
2288
+ 'The specific model identifier (e.g., "gpt-6-astra").',
2287
2289
  },
2288
2290
  {
2289
2291
  name: 'instructions',
@@ -14,7 +14,7 @@ import { cohere } from '@ai-sdk/cohere';
14
14
  import { rerank } from 'ai';
15
15
 
16
16
  const { ranking } = await rerank({
17
- model: cohere.reranking('rerank-v3.5'),
17
+ model: cohere.reranking('rerank-v4.0-pro'),
18
18
  documents: ['sunny day at the beach', 'rainy afternoon in the city'],
19
19
  query: 'talk about rain',
20
20
  });
@@ -34,7 +34,7 @@ const { ranking } = await rerank({
34
34
  name: 'model',
35
35
  type: 'RerankingModel',
36
36
  description:
37
- "The reranking model to use. Example: cohere.reranking('rerank-v3.5')",
37
+ "The reranking model to use. Example: cohere.reranking('rerank-v4.0-pro')",
38
38
  },
39
39
  {
40
40
  name: 'documents',
@@ -262,7 +262,7 @@ import { cohere } from '@ai-sdk/cohere';
262
262
  import { rerank } from 'ai';
263
263
 
264
264
  const { ranking, rerankedDocuments } = await rerank({
265
- model: cohere.reranking('rerank-v3.5'),
265
+ model: cohere.reranking('rerank-v4.0-pro'),
266
266
  documents: [
267
267
  'sunny day at the beach',
268
268
  'rainy afternoon in the city',
@@ -302,7 +302,7 @@ const documents = [
302
302
  ];
303
303
 
304
304
  const { ranking } = await rerank({
305
- model: cohere.reranking('rerank-v3.5'),
305
+ model: cohere.reranking('rerank-v4.0-pro'),
306
306
  documents,
307
307
  query: 'Which pricing did we get from Oracle?',
308
308
  topN: 1,
@@ -319,7 +319,7 @@ import { cohere } from '@ai-sdk/cohere';
319
319
  import { rerank } from 'ai';
320
320
 
321
321
  const { ranking } = await rerank({
322
- model: cohere.reranking('rerank-v3.5'),
322
+ model: cohere.reranking('rerank-v4.0-pro'),
323
323
  documents: ['sunny day at the beach', 'rainy afternoon in the city'],
324
324
  query: 'talk about rain',
325
325
  providerOptions: {
@@ -13,7 +13,7 @@ import { openai } from '@ai-sdk/openai';
13
13
  import { readFile } from 'fs/promises';
14
14
 
15
15
  const { text: transcript } = await transcribe({
16
- model: openai.transcription('whisper-1'),
16
+ model: openai.transcription('gpt-4o-transcribe'),
17
17
  audio: await readFile('audio.mp3'),
18
18
  });
19
19
 
@@ -12,7 +12,7 @@ import { generateSpeech } from 'ai';
12
12
  import { openai } from '@ai-sdk/openai';
13
13
 
14
14
  const { audio } = await generateSpeech({
15
- model: openai.speech('tts-1'),
15
+ model: openai.speech('gpt-4o-mini-tts'),
16
16
  text: 'Hello from the AI SDK!',
17
17
  voice: 'alloy',
18
18
  });
@@ -29,7 +29,7 @@ import { generateSpeech } from 'ai';
29
29
  import { openai } from '@ai-sdk/openai';
30
30
 
31
31
  const { audio } = await generateSpeech({
32
- model: openai.speech('tts-1'),
32
+ model: openai.speech('gpt-4o-mini-tts'),
33
33
  text: 'Hello from the AI SDK!',
34
34
  voice: 'alloy',
35
35
  });
@@ -79,7 +79,7 @@ const { audio } = await generateSpeech({
79
79
  type: 'string',
80
80
  isOptional: true,
81
81
  description:
82
- 'The output format to use for the speech e.g. "mp3", "wav", etc.',
82
+ 'The output format to use for the speech, such as "mp3", "wav", or headerless "audio/l16", "audio/mulaw", and "audio/alaw". Supported formats and defaults vary by provider and model.',
83
83
  },
84
84
  {
85
85
  name: 'instructions',
@@ -172,7 +172,8 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
172
172
  {
173
173
  name: 'modelId',
174
174
  type: 'string',
175
- description: 'The specific model identifier (e.g., "gpt-4o").',
175
+ description:
176
+ 'The specific model identifier (e.g., "gpt-6-astra").',
176
177
  },
177
178
  {
178
179
  name: 'instructions',
@@ -319,7 +320,8 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
319
320
  {
320
321
  name: 'modelId',
321
322
  type: 'string',
322
- description: 'The specific model identifier (e.g., "gpt-4o").',
323
+ description:
324
+ 'The specific model identifier (e.g., "gpt-6-astra").',
323
325
  },
324
326
  {
325
327
  name: 'instructions',
@@ -20,7 +20,7 @@ const batch = await startBatch({
20
20
  {
21
21
  id: 'france',
22
22
  type: 'text',
23
- model: 'gpt-4.1-nano',
23
+ model: 'gpt-5.4-nano',
24
24
  prompt: 'What is the capital of France?',
25
25
  },
26
26
  ],
@@ -100,6 +100,24 @@ const validatedMessages = await validateUIMessages({
100
100
  });
101
101
  ```
102
102
 
103
+ When validating approval messages produced with
104
+ `experimental_refineToolInput`, pass the same refinement functions so
105
+ `validateUIMessages` can reconstruct and verify the approved input:
106
+
107
+ ```typescript
108
+ const experimental_refineToolInput = {
109
+ weather: (input: { location: string }) => ({
110
+ location: input.location.trim(),
111
+ }),
112
+ };
113
+
114
+ const validatedMessages = await validateUIMessages({
115
+ messages,
116
+ tools,
117
+ experimental_refineToolInput,
118
+ });
119
+ ```
120
+
103
121
  ## Deprecated `rawInput` field
104
122
 
105
123
  For backward compatibility, validation still accepts `rawInput` on tool parts
@@ -62,7 +62,7 @@ import { generateText } from 'ai';
62
62
  import { registry } from './registry';
63
63
 
64
64
  const { text } = await generateText({
65
- model: registry.languageModel('openai:gpt-4.1'),
65
+ model: registry.languageModel('openai:gpt-6-astra'),
66
66
  prompt: 'Invent a new holiday and describe its traditions.',
67
67
  });
68
68
  ```
@@ -24,8 +24,8 @@ import { customProvider } from 'ai';
24
24
  export const myOpenAI = customProvider({
25
25
  languageModels: {
26
26
  // replacement model with custom settings:
27
- 'gpt-5': wrapLanguageModel({
28
- model: openai('gpt-5'),
27
+ 'gpt-6-astra': wrapLanguageModel({
28
+ model: openai('gpt-6-astra'),
29
29
  middleware: defaultSettingsMiddleware({
30
30
  settings: {
31
31
  providerOptions: {
@@ -37,8 +37,8 @@ export const myOpenAI = customProvider({
37
37
  }),
38
38
  }),
39
39
  // alias model with custom settings:
40
- 'gpt-4o-reasoning-high': wrapLanguageModel({
41
- model: openai('gpt-4o'),
40
+ 'gpt-6-astra-reasoning-high': wrapLanguageModel({
41
+ model: openai('gpt-6-astra'),
42
42
  middleware: defaultSettingsMiddleware({
43
43
  settings: {
44
44
  providerOptions: {
@@ -13,7 +13,7 @@ See [Language Model Middleware](/docs/ai-sdk-core/middleware) for more informati
13
13
  import { wrapLanguageModel, gateway } from 'ai';
14
14
 
15
15
  const wrappedLanguageModel = wrapLanguageModel({
16
- model: gateway('openai/gpt-4.1'),
16
+ model: gateway('openai/gpt-6-astra'),
17
17
  middleware: yourLanguageModelMiddleware,
18
18
  });
19
19
  ```
@@ -13,7 +13,7 @@ import { generateImage, wrapImageModel } from 'ai';
13
13
  import { openai } from '@ai-sdk/openai';
14
14
 
15
15
  const model = wrapImageModel({
16
- model: openai.image('gpt-image-2'),
16
+ model: openai.image('gpt-image-2.5-sunburst'),
17
17
  middleware: yourImageModelMiddleware,
18
18
  });
19
19
 
@@ -202,7 +202,7 @@ import { DirectChatTransport, ToolLoopAgent } from 'ai';
202
202
  import { openai } from '@ai-sdk/openai';
203
203
 
204
204
  const agent = new ToolLoopAgent({
205
- model: openai('gpt-4o'),
205
+ model: openai('gpt-6-astra'),
206
206
  instructions: 'You are a helpful assistant.',
207
207
  });
208
208
 
@@ -246,7 +246,7 @@ const weatherTool = tool({
246
246
  });
247
247
 
248
248
  const agent = new ToolLoopAgent({
249
- model: openai('gpt-4o'),
249
+ model: openai('gpt-6-astra'),
250
250
  instructions: 'You are a helpful assistant with access to weather data.',
251
251
  tools: { weather: weatherTool },
252
252
  });
@@ -268,7 +268,7 @@ import { DirectChatTransport, ToolLoopAgent } from 'ai';
268
268
  import { openai } from '@ai-sdk/openai';
269
269
 
270
270
  const agent = new ToolLoopAgent<{ userId: string }>({
271
- model: openai('gpt-4o'),
271
+ model: openai('gpt-6-astra'),
272
272
  prepareCall: ({ options, ...rest }) => ({
273
273
  ...rest,
274
274
  providerOptions: {
@@ -26,7 +26,7 @@ To see `streamUI` in action, check out [these examples](#examples).
26
26
  {
27
27
  name: 'model',
28
28
  type: 'LanguageModel',
29
- description: 'The language model to use. Example: openai("gpt-4.1")',
29
+ description: 'The language model to use. Example: openai("gpt-6-astra")',
30
30
  },
31
31
  {
32
32
  name: 'initial',
@@ -17,7 +17,7 @@ import { tool } from 'ai';
17
17
  import { z } from 'zod';
18
18
 
19
19
  const agent = new WorkflowAgent({
20
- model: 'anthropic/claude-sonnet-4-6',
20
+ model: 'anthropic/claude-sonnet-5',
21
21
  instructions: 'You are a helpful assistant.',
22
22
  tools: {
23
23
  weather: tool({
@@ -71,7 +71,7 @@ To see `WorkflowAgent` in action, check out [these examples](#examples).
71
71
  type: 'LanguageModel',
72
72
  isRequired: true,
73
73
  description:
74
- "The language model to use. A string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-sonnet-4-6') or a provider instance (e.g., `openai('gpt-4o')`).",
74
+ "The language model to use. A string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-sonnet-5') or a provider instance (e.g., `openai('gpt-6-astra')`).",
75
75
  },
76
76
  {
77
77
  name: 'instructions',
@@ -808,7 +808,7 @@ Infers the UI message type for a `WorkflowAgent` instance. Optionally accepts a
808
808
  import { WorkflowAgent, InferWorkflowAgentUIMessage } from '@ai-sdk/workflow';
809
809
 
810
810
  const agent = new WorkflowAgent({
811
- model: 'anthropic/claude-sonnet-4-6',
811
+ model: 'anthropic/claude-sonnet-5',
812
812
  tools: { weather: weatherTool },
813
813
  });
814
814
 
@@ -835,7 +835,7 @@ import { tool } from 'ai';
835
835
  import { z } from 'zod';
836
836
 
837
837
  const agent = new WorkflowAgent({
838
- model: 'anthropic/claude-sonnet-4-6',
838
+ model: 'anthropic/claude-sonnet-5',
839
839
  instructions: 'You are a helpful assistant.',
840
840
  tools: {
841
841
  weather: tool({
@@ -890,7 +890,7 @@ export async function chat(messages: UIMessage[]) {
890
890
  const modelMessages = await convertToModelMessages(messages);
891
891
 
892
892
  const agent = new WorkflowAgent({
893
- model: 'anthropic/claude-sonnet-4-6',
893
+ model: 'anthropic/claude-sonnet-5',
894
894
  instructions: 'You are a flight booking assistant.',
895
895
  tools: {
896
896
  searchFlights: tool({
@@ -937,7 +937,7 @@ import { WorkflowAgent, Output } from '@ai-sdk/workflow';
937
937
  import { z } from 'zod';
938
938
 
939
939
  const analysisAgent = new WorkflowAgent({
940
- model: 'anthropic/claude-sonnet-4-6',
940
+ model: 'anthropic/claude-sonnet-5',
941
941
  });
942
942
 
943
943
  const result = await analysisAgent.stream({
@@ -977,7 +977,7 @@ import { tool } from 'ai';
977
977
  import { z } from 'zod';
978
978
 
979
979
  const agent = new WorkflowAgent({
980
- model: 'anthropic/claude-sonnet-4-6',
980
+ model: 'anthropic/claude-sonnet-5',
981
981
  experimental_toolApprovalSecret: {
982
982
  environmentVariable: 'TOOL_APPROVAL_SECRET',
983
983
  },
@@ -1009,7 +1009,7 @@ serialize it. A stream-level reference overrides the constructor value.
1009
1009
  import { WorkflowAgent } from '@ai-sdk/workflow';
1010
1010
 
1011
1011
  const agent = new WorkflowAgent({
1012
- model: 'anthropic/claude-sonnet-4-6',
1012
+ model: 'anthropic/claude-sonnet-5',
1013
1013
  tools: { weather: weatherTool },
1014
1014
 
1015
1015
  // Agent-wide callbacks
@@ -17,7 +17,7 @@ import { runAgentTUI } from '@ai-sdk/tui';
17
17
  import { ToolLoopAgent } from 'ai';
18
18
 
19
19
  const agent = new ToolLoopAgent({
20
- model: openai('gpt-5'),
20
+ model: openai('gpt-6-astra'),
21
21
  instructions: 'You are a helpful terminal assistant.',
22
22
  });
23
23
 
@@ -73,7 +73,7 @@ const { messages, sendMessage } = useChat({
73
73
  'X-App-ID': 'my-app', // Static app identifier
74
74
  },
75
75
  body: {
76
- model: 'gpt-5.1', // Default model
76
+ model: 'gpt-6-astra', // Default model
77
77
  stream: true, // Static configuration
78
78
  },
79
79
  credentials: 'include', // Static credentials policy
@@ -125,7 +125,7 @@ const { messages, sendMessage } = useChat({
125
125
  'X-API-Version': 'v1',
126
126
  },
127
127
  body: {
128
- model: 'gpt-5.1',
128
+ model: 'gpt-6-astra',
129
129
  },
130
130
  }),
131
131
  });
@@ -139,7 +139,7 @@ sendMessage(
139
139
  'X-Request-ID': '123', // This is added
140
140
  },
141
141
  body: {
142
- model: 'gpt-5-mini', // This overrides the hook-level body field
142
+ model: 'gpt-4.1-mini', // Supports the temperature setting below
143
143
  temperature: 0.5, // This is added
144
144
  },
145
145
  },
@@ -15,7 +15,7 @@ export async function POST(req: Request) {
15
15
  const { messages } = await req.json();
16
16
 
17
17
  const result = streamText({
18
- model: 'openai/gpt-5-mini',
18
+ model: 'openai/gpt-6-luna',
19
19
  messages: await convertToModelMessages(messages),
20
20
  tools: {
21
21
  weather: {
@@ -49,7 +49,7 @@ export async function POST(req: Request) {
49
49
  const { messages } = await req.json();
50
50
 
51
51
  const result = streamText({
52
- model: 'openai/gpt-5-mini',
52
+ model: 'openai/gpt-6-luna',
53
53
  messages: await convertToModelMessages(messages),
54
54
  tools: {
55
55
  weather: {
@@ -128,7 +128,7 @@ export async function POST(req: Request) {
128
128
  const { messages, temperature, userId } = await req.json();
129
129
 
130
130
  const result = streamText({
131
- model: 'openai/gpt-5-mini',
131
+ model: 'openai/gpt-4.1-mini', // Supports dynamic temperature settings
132
132
  messages: await convertToModelMessages(messages),
133
133
  temperature, // Use the dynamic temperature from the request
134
134
  // ... other configuration
@@ -30,7 +30,7 @@ import { generateText } from 'ai';
30
30
  import { openai } from '@ai-sdk/openai';
31
31
 
32
32
  const result = await generateText({
33
- model: openai('gpt-4o'),
33
+ model: openai('gpt-6-astra'),
34
34
  messages: [
35
35
  {
36
36
  role: 'user',
@@ -85,7 +85,7 @@ const results = [];
85
85
 
86
86
  for (const imageUrl of imageUrls) {
87
87
  const result = await generateText({
88
- model: openai('gpt-4o'),
88
+ model: openai('gpt-6-astra'),
89
89
  messages: [
90
90
  {
91
91
  role: 'user',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.112",
3
+ "version": "7.0.114",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -42,20 +42,20 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.90",
45
+ "@ai-sdk/gateway": "4.0.92",
46
46
  "@ai-sdk/provider": "4.0.18",
47
- "@ai-sdk/provider-utils": "5.0.46"
47
+ "@ai-sdk/provider-utils": "5.0.47"
48
48
  },
49
49
  "devDependencies": {
50
- "@ai-sdk/amazon-bedrock": "5.0.92",
51
- "@ai-sdk/deepseek": "3.0.51",
52
- "@ai-sdk/google": "4.0.78",
53
- "@ai-sdk/groq": "4.0.47",
54
- "@ai-sdk/huggingface": "2.0.54",
55
- "@ai-sdk/moonshotai": "3.0.55",
56
- "@ai-sdk/openai": "4.0.73",
50
+ "@ai-sdk/amazon-bedrock": "5.0.94",
51
+ "@ai-sdk/deepseek": "3.0.52",
52
+ "@ai-sdk/google": "4.0.80",
53
+ "@ai-sdk/groq": "4.0.48",
54
+ "@ai-sdk/huggingface": "2.0.55",
55
+ "@ai-sdk/moonshotai": "3.0.56",
56
+ "@ai-sdk/openai": "4.0.75",
57
57
  "@ai-sdk/test-server": "2.0.1",
58
- "@ai-sdk/xai": "5.0.6",
58
+ "@ai-sdk/xai": "5.0.8",
59
59
  "@edge-runtime/vm": "^5.0.0",
60
60
  "@smithy/eventstream-codec": "^4.3.3",
61
61
  "@smithy/util-utf8": "^4.3.3",
@@ -7,6 +7,7 @@ import {
7
7
  } from '@ai-sdk/provider-utils';
8
8
  import { logWarnings } from '../logger/log-warnings';
9
9
  import { getEmbeddingModelMaxInputBytesPerCall } from '../model/get-embedding-model-max-input-bytes-per-call';
10
+ import { getEmbeddingModelProviderOptionsTransformer } from '../model/get-embedding-model-provider-options-transformer';
10
11
  import { resolveEmbeddingModel } from '../model/resolve-model';
11
12
  import { createRestrictedTelemetryDispatcher } from './restricted-telemetry-dispatcher';
12
13
  import type { TelemetryOptions } from '../telemetry/telemetry-options';
@@ -321,6 +322,8 @@ export async function embedMany<RUNTIME_CONTEXT extends Context = Context>({
321
322
  ? maxInputBytesPerCall
322
323
  : Infinity,
323
324
  });
325
+ const providerOptionsTransformer =
326
+ getEmbeddingModelProviderOptionsTransformer(model);
324
327
 
325
328
  const embeddings: Array<Embedding> = [];
326
329
  const warnings: Array<Warning> = [];
@@ -339,9 +342,22 @@ export async function embedMany<RUNTIME_CONTEXT extends Context = Context>({
339
342
  supportsParallelCalls ? maxParallelCalls : 1,
340
343
  );
341
344
 
345
+ let nextChunkStartIndex = 0;
342
346
  for (const parallelChunk of parallelChunks) {
343
347
  const results = await Promise.all(
344
348
  parallelChunk.map(async chunk => {
349
+ // Capture the range before awaiting transformations or retrying.
350
+ const startIndex = nextChunkStartIndex;
351
+ nextChunkStartIndex += chunk.length;
352
+ const chunkProviderOptions = providerOptionsTransformer
353
+ ? await providerOptionsTransformer({
354
+ providerOptions,
355
+ values,
356
+ startIndex,
357
+ endIndex: startIndex + chunk.length,
358
+ })
359
+ : providerOptions;
360
+
345
361
  const result = await retry(async () => {
346
362
  const embedCallId = generateCallId();
347
363
 
@@ -361,7 +377,7 @@ export async function embedMany<RUNTIME_CONTEXT extends Context = Context>({
361
377
  values: chunk,
362
378
  abortSignal,
363
379
  headers: headersWithUserAgent,
364
- providerOptions,
380
+ providerOptions: chunkProviderOptions,
365
381
  });
366
382
 
367
383
  const chunkEmbeddings = modelResponse.embeddings;
@@ -412,7 +428,7 @@ export async function embedMany<RUNTIME_CONTEXT extends Context = Context>({
412
428
  result.providerMetadata,
413
429
  )) {
414
430
  providerMetadata[providerName] = {
415
- ...(providerMetadata[providerName] ?? {}),
431
+ ...providerMetadata[providerName],
416
432
  ...metadata,
417
433
  };
418
434
  }
@@ -10,7 +10,6 @@ import {
10
10
  } from '@ai-sdk/provider-utils';
11
11
  import { resolveEvaluationModel } from '../model/resolve-model';
12
12
  import { logWarnings } from '../logger/log-warnings';
13
- import { filterIncludedContext } from '../telemetry/filter-included-context';
14
13
  import type { TelemetryOptions } from '../telemetry/telemetry-options';
15
14
  import type { Callback } from '../util/callback';
16
15
  import { notify } from '../util/notify';
@@ -112,17 +111,9 @@ export async function evaluate<
112
111
  headers,
113
112
  providerOptions,
114
113
  };
115
- const tracingStartEvent = {
116
- ...startEvent,
117
- runtimeContext: filterIncludedContext({
118
- context: runtimeContext,
119
- includeContext: telemetry?.includeRuntimeContext,
120
- }),
121
- };
122
-
123
114
  return await runInTracingChannelSpan({
124
115
  type: 'experimental_evaluate',
125
- event: tracingStartEvent,
116
+ event: startEvent,
126
117
  execute: async () => {
127
118
  await notify({
128
119
  event: startEvent,
@@ -204,10 +204,21 @@ function getOutputFormatMediaType(outputFormat: string | undefined) {
204
204
 
205
205
  const normalizedOutputFormat = outputFormat.trim().toLowerCase();
206
206
 
207
- return normalizedOutputFormat === 'pcm' ||
208
- normalizedOutputFormat === 'audio/pcm'
209
- ? 'audio/pcm'
210
- : undefined;
207
+ switch (normalizedOutputFormat) {
208
+ case 'pcm':
209
+ case 'audio/pcm':
210
+ return 'audio/pcm';
211
+ case 'audio/l16':
212
+ return 'audio/l16';
213
+ case 'mulaw':
214
+ case 'audio/mulaw':
215
+ return 'audio/mulaw';
216
+ case 'alaw':
217
+ case 'audio/alaw':
218
+ return 'audio/alaw';
219
+ default:
220
+ return undefined;
221
+ }
211
222
  }
212
223
 
213
224
  class DefaultSpeechResult implements SpeechResult {
@@ -53,12 +53,4 @@ export class DefaultGeneratedAudioFile
53
53
 
54
54
  export class DefaultGeneratedAudioFileWithType extends DefaultGeneratedAudioFile {
55
55
  readonly type = 'audio';
56
-
57
- constructor(options: {
58
- data: string | Uint8Array;
59
- mediaType: string;
60
- format: string;
61
- }) {
62
- super(options);
63
- }
64
56
  }
@@ -265,8 +265,6 @@ export function executeToolsFromStream<
265
265
  }
266
266
  }),
267
267
  );
268
-
269
- return;
270
268
  }
271
269
  }
272
270
  },
@@ -726,6 +726,7 @@ export async function generateText<
726
726
  toolsContext,
727
727
  runtimeContext,
728
728
  toolApprovalSecret: experimental_toolApprovalSecret,
729
+ refineToolInput,
729
730
  });
730
731
 
731
732
  const deniedToolApprovals = [