ai 7.0.119 → 7.0.122

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 (44) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/index.d.ts +30 -3
  3. package/dist/index.js +132 -36
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.js +1 -1
  6. package/docs/02-foundations/02-providers-and-models.mdx +1 -0
  7. package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
  8. package/docs/02-getting-started/02-nextjs-app-router.mdx +2 -2
  9. package/docs/02-getting-started/03-nextjs-pages-router.mdx +2 -2
  10. package/docs/02-getting-started/04-svelte.mdx +6 -6
  11. package/docs/02-getting-started/05-nuxt.mdx +6 -6
  12. package/docs/02-getting-started/06-nodejs.mdx +2 -2
  13. package/docs/02-getting-started/07-expo.mdx +2 -2
  14. package/docs/02-getting-started/08-tanstack-start.mdx +2 -2
  15. package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
  16. package/docs/03-agents/07-workflow-agent.mdx +10 -10
  17. package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
  18. package/docs/03-ai-sdk-core/26-reasoning.mdx +1 -1
  19. package/docs/03-ai-sdk-core/45-provider-management.mdx +4 -4
  20. package/docs/04-ai-sdk-ui/02-chatbot.mdx +10 -1
  21. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +8 -0
  22. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +10 -3
  23. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +10 -1
  24. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
  25. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +1 -1
  26. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
  27. package/docs/08-migration-guides/29-migration-guide-4-0.mdx +5 -5
  28. package/docs/08-migration-guides/37-migration-guide-3-3.mdx +1 -1
  29. package/package.json +11 -11
  30. package/src/embed/embed-many.ts +5 -3
  31. package/src/generate-image/generate-image.ts +8 -3
  32. package/src/generate-text/smooth-stream.ts +24 -9
  33. package/src/generate-text/stream-text-result.ts +5 -0
  34. package/src/generate-video/generate-video.ts +6 -4
  35. package/src/registry/provider-registry.ts +1 -1
  36. package/src/ui/chat.ts +45 -7
  37. package/src/ui/http-chat-transport.ts +19 -3
  38. package/src/ui/last-assistant-message-is-complete-with-tool-calls.ts +15 -3
  39. package/src/ui/process-ui-message-stream.ts +59 -18
  40. package/src/ui/ui-messages.ts +14 -0
  41. package/src/ui/validate-ui-messages.ts +2 -0
  42. package/src/ui-message-stream/to-ui-message-chunk.ts +9 -1
  43. package/src/ui-message-stream/to-ui-message-stream.ts +1 -1
  44. package/src/util/set-own.ts +16 -0
@@ -90,7 +90,7 @@ import {
90
90
  } from "@ai-sdk/provider-utils";
91
91
 
92
92
  // src/version.ts
93
- var VERSION = true ? "7.0.119" : "0.0.0-test";
93
+ var VERSION = true ? "7.0.122" : "0.0.0-test";
94
94
 
95
95
  // src/util/download/download.ts
96
96
  var download = async ({
@@ -149,6 +149,7 @@ Here are the capabilities of popular models:
149
149
  | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5-codex` | <Check /> | <Check /> | <Check /> | <Check /> |
150
150
  | [OpenAI](/providers/ai-sdk-providers/openai) | `gpt-5-chat-latest` | <Check /> | <Check /> | <Check /> | <Check /> |
151
151
  | [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-opus-5-5` | <Check /> | <Check /> | <Check /> | <Check /> |
152
+ | [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-sonnet-5-5` | <Check /> | <Check /> | <Check /> | <Check /> |
152
153
  | [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-sonnet-5` | <Check /> | <Check /> | <Check /> | <Check /> |
153
154
  | [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-fable-5-1` | <Check /> | <Check /> | <Check /> | <Check /> |
154
155
  | [Anthropic](/providers/ai-sdk-providers/anthropic) | `claude-fable-5` | <Check /> | <Check /> | <Check /> | <Check /> |
@@ -45,7 +45,7 @@ The AI Gateway is the default [global provider](/docs/ai-sdk-core/provider-manag
45
45
  import { generateText } from 'ai';
46
46
 
47
47
  const { text } = await generateText({
48
- model: 'anthropic/claude-sonnet-5',
48
+ model: 'anthropic/claude-sonnet-5.5',
49
49
  prompt: 'What is love?',
50
50
  });
51
51
  ```
@@ -55,11 +55,11 @@ You can also explicitly import and use the gateway provider:
55
55
  ```ts
56
56
  // Option 1: Import from 'ai' package (included by default)
57
57
  import { gateway } from 'ai';
58
- model: gateway('anthropic/claude-sonnet-5');
58
+ model: gateway('anthropic/claude-sonnet-5.5');
59
59
 
60
60
  // Option 2: Install and import from '@ai-sdk/gateway' package
61
61
  import { gateway } from '@ai-sdk/gateway';
62
- model: gateway('anthropic/claude-sonnet-5');
62
+ model: gateway('anthropic/claude-sonnet-5.5');
63
63
  ```
64
64
 
65
65
  ## Using Dedicated Providers
@@ -71,7 +71,7 @@ You can also use [first-party](/providers/ai-sdk-providers), [OpenAI-compatible]
71
71
  ```ts
72
72
  import { anthropic } from '@ai-sdk/anthropic';
73
73
 
74
- model: anthropic('claude-sonnet-5');
74
+ model: anthropic('claude-sonnet-5-5');
75
75
  ```
76
76
 
77
77
  You can change the default global provider so string model references use your preferred provider everywhere in your application. Learn more about [provider management](/docs/ai-sdk-core/provider-management#global-provider-configuration).
@@ -122,11 +122,11 @@ You can also explicitly import and use the gateway provider in two other equival
122
122
  ```ts
123
123
  // Option 1: Import from 'ai' package (included by default)
124
124
  import { gateway } from 'ai';
125
- model: gateway('anthropic/claude-sonnet-5');
125
+ model: gateway('anthropic/claude-sonnet-5.5');
126
126
 
127
127
  // Option 2: Install and import from '@ai-sdk/gateway' package
128
128
  import { gateway } from '@ai-sdk/gateway';
129
- model: gateway('anthropic/claude-sonnet-5');
129
+ model: gateway('anthropic/claude-sonnet-5.5');
130
130
  ```
131
131
 
132
132
  ### Using other providers
@@ -126,11 +126,11 @@ You can also explicitly import and use the gateway provider in two other equival
126
126
  ```ts
127
127
  // Option 1: Import from 'ai' package (included by default)
128
128
  import { gateway } from 'ai';
129
- model: gateway('anthropic/claude-sonnet-5');
129
+ model: gateway('anthropic/claude-sonnet-5.5');
130
130
 
131
131
  // Option 2: Install and import from '@ai-sdk/gateway' package
132
132
  import { gateway } from '@ai-sdk/gateway';
133
- model: gateway('anthropic/claude-sonnet-5');
133
+ model: gateway('anthropic/claude-sonnet-5.5');
134
134
  ```
135
135
 
136
136
  ### Using other providers
@@ -87,7 +87,7 @@ export async function POST({ request }) {
87
87
  const { messages }: { messages: UIMessage[] } = await request.json();
88
88
 
89
89
  const result = streamText({
90
- model: gateway('anthropic/claude-sonnet-5'),
90
+ model: gateway('anthropic/claude-sonnet-5.5'),
91
91
  messages: await convertToModelMessages(messages),
92
92
  });
93
93
 
@@ -125,11 +125,11 @@ You can also explicitly import and use the gateway provider in two other equival
125
125
  ```ts
126
126
  // Option 1: Import from 'ai' package (included by default)
127
127
  import { gateway } from 'ai';
128
- model: gateway('anthropic/claude-sonnet-5');
128
+ model: gateway('anthropic/claude-sonnet-5.5');
129
129
 
130
130
  // Option 2: Install and import from '@ai-sdk/gateway' package
131
131
  import { gateway } from '@ai-sdk/gateway';
132
- model: gateway('anthropic/claude-sonnet-5');
132
+ model: gateway('anthropic/claude-sonnet-5.5');
133
133
  ```
134
134
 
135
135
  ### Using other providers
@@ -247,7 +247,7 @@ export async function POST({ request }) {
247
247
  const { messages }: { messages: UIMessage[] } = await request.json();
248
248
 
249
249
  const result = streamText({
250
- model: gateway('anthropic/claude-sonnet-5'),
250
+ model: gateway('anthropic/claude-sonnet-5.5'),
251
251
  messages: await convertToModelMessages(messages),
252
252
  tools: {
253
253
  weather: tool({
@@ -371,7 +371,7 @@ export async function POST({ request }) {
371
371
  const { messages }: { messages: UIMessage[] } = await request.json();
372
372
 
373
373
  const result = streamText({
374
- model: gateway('anthropic/claude-sonnet-5'),
374
+ model: gateway('anthropic/claude-sonnet-5.5'),
375
375
  messages: await convertToModelMessages(messages),
376
376
  stopWhen: isStepCount(5),
377
377
  tools: {
@@ -428,7 +428,7 @@ export async function POST({ request }) {
428
428
  const { messages }: { messages: UIMessage[] } = await request.json();
429
429
 
430
430
  const result = streamText({
431
- model: gateway('anthropic/claude-sonnet-5'),
431
+ model: gateway('anthropic/claude-sonnet-5.5'),
432
432
  messages: await convertToModelMessages(messages),
433
433
  stopWhen: isStepCount(5),
434
434
  tools: {
@@ -99,7 +99,7 @@ export default defineLazyEventHandler(async () => {
99
99
  const { messages }: { messages: UIMessage[] } = await readBody(event);
100
100
 
101
101
  const result = streamText({
102
- model: gateway('anthropic/claude-sonnet-5'),
102
+ model: gateway('anthropic/claude-sonnet-5.5'),
103
103
  messages: await convertToModelMessages(messages),
104
104
  });
105
105
 
@@ -133,11 +133,11 @@ You can also explicitly import and use the gateway provider in two other equival
133
133
  ```ts
134
134
  // Option 1: Import from 'ai' package (included by default)
135
135
  import { gateway } from 'ai';
136
- model: gateway('anthropic/claude-sonnet-5');
136
+ model: gateway('anthropic/claude-sonnet-5.5');
137
137
 
138
138
  // Option 2: Install and import from '@ai-sdk/gateway' package
139
139
  import { gateway } from '@ai-sdk/gateway';
140
- model: gateway('anthropic/claude-sonnet-5');
140
+ model: gateway('anthropic/claude-sonnet-5.5');
141
141
  ```
142
142
 
143
143
  ### Using other providers
@@ -251,7 +251,7 @@ export default defineLazyEventHandler(async () => {
251
251
  const { messages }: { messages: UIMessage[] } = await readBody(event);
252
252
 
253
253
  const result = streamText({
254
- model: gateway('anthropic/claude-sonnet-5'),
254
+ model: gateway('anthropic/claude-sonnet-5.5'),
255
255
  messages: await convertToModelMessages(messages),
256
256
  tools: {
257
257
  weather: tool({
@@ -376,7 +376,7 @@ export default defineLazyEventHandler(async () => {
376
376
  const { messages }: { messages: UIMessage[] } = await readBody(event);
377
377
 
378
378
  const result = streamText({
379
- model: gateway('anthropic/claude-sonnet-5'),
379
+ model: gateway('anthropic/claude-sonnet-5.5'),
380
380
  messages: await convertToModelMessages(messages),
381
381
  stopWhen: isStepCount(5),
382
382
  tools: {
@@ -437,7 +437,7 @@ export default defineLazyEventHandler(async () => {
437
437
  const { messages }: { messages: UIMessage[] } = await readBody(event);
438
438
 
439
439
  const result = streamText({
440
- model: gateway('anthropic/claude-sonnet-5'),
440
+ model: gateway('anthropic/claude-sonnet-5.5'),
441
441
  messages: await convertToModelMessages(messages),
442
442
  stopWhen: isStepCount(5),
443
443
  tools: {
@@ -146,11 +146,11 @@ You can also explicitly import and use the gateway provider in two other equival
146
146
  ```ts
147
147
  // Option 1: Import from 'ai' package (included by default)
148
148
  import { gateway } from 'ai';
149
- model: gateway('anthropic/claude-sonnet-5');
149
+ model: gateway('anthropic/claude-sonnet-5.5');
150
150
 
151
151
  // Option 2: Install and import from '@ai-sdk/gateway' package
152
152
  import { gateway } from '@ai-sdk/gateway';
153
- model: gateway('anthropic/claude-sonnet-5');
153
+ model: gateway('anthropic/claude-sonnet-5.5');
154
154
  ```
155
155
 
156
156
  ### Using other providers
@@ -125,11 +125,11 @@ You can also explicitly import and use the gateway provider in two other equival
125
125
  ```ts
126
126
  // Option 1: Import from 'ai' package (included by default)
127
127
  import { gateway } from 'ai';
128
- model: gateway('anthropic/claude-sonnet-5');
128
+ model: gateway('anthropic/claude-sonnet-5.5');
129
129
 
130
130
  // Option 2: Install and import from '@ai-sdk/gateway' package
131
131
  import { gateway } from '@ai-sdk/gateway';
132
- model: gateway('anthropic/claude-sonnet-5');
132
+ model: gateway('anthropic/claude-sonnet-5.5');
133
133
  ```
134
134
 
135
135
  ### Using other providers
@@ -121,11 +121,11 @@ You can also explicitly import and use the gateway provider in two other equival
121
121
  ```ts
122
122
  // Option 1: Import from 'ai' package (included by default)
123
123
  import { gateway } from 'ai';
124
- model: gateway('anthropic/claude-sonnet-5');
124
+ model: gateway('anthropic/claude-sonnet-5.5');
125
125
 
126
126
  // Option 2: Install and import from '@ai-sdk/gateway' package
127
127
  import { gateway } from '@ai-sdk/gateway';
128
- model: gateway('anthropic/claude-sonnet-5');
128
+ model: gateway('anthropic/claude-sonnet-5.5');
129
129
  ```
130
130
 
131
131
  ### Using other providers
@@ -80,7 +80,7 @@ const toolApproval = opaPolicy({
80
80
 
81
81
  // 3. Pass it to generateText (or streamText / ToolLoopAgent). Everything else is normal.
82
82
  const result = await generateText({
83
- model: anthropic('claude-sonnet-5'),
83
+ model: anthropic('claude-sonnet-5-5'),
84
84
  tools: { git, bash, queryLogs },
85
85
  toolApproval,
86
86
  prompt: 'find the failing test and push the fix',
@@ -291,7 +291,7 @@ import { wasmPolicyClient, opaCapabilityMiddleware } from '@ai-sdk/policy-opa';
291
291
  const client = await wasmPolicyClient({ wasm });
292
292
 
293
293
  const wrappedModel = wrapLanguageModel({
294
- model: anthropic('claude-sonnet-5'),
294
+ model: anthropic('claude-sonnet-5-5'),
295
295
  middleware: opaCapabilityMiddleware({ client, path: 'agent/tools/allowed' }),
296
296
  });
297
297
  ```
@@ -51,7 +51,7 @@ import { tool } from 'ai';
51
51
  import { z } from 'zod';
52
52
 
53
53
  const agent = new WorkflowAgent({
54
- model: 'anthropic/claude-sonnet-5',
54
+ model: 'anthropic/claude-sonnet-5.5',
55
55
  instructions: 'You are a helpful assistant.',
56
56
  tools: {
57
57
  weather: tool({
@@ -74,7 +74,7 @@ The `model` parameter accepts two forms:
74
74
 
75
75
  ```ts
76
76
  // String — AI Gateway model ID
77
- new WorkflowAgent({ model: 'anthropic/claude-sonnet-5' });
77
+ new WorkflowAgent({ model: 'anthropic/claude-sonnet-5.5' });
78
78
 
79
79
  // Provider instance
80
80
  import { openai } from '@ai-sdk/openai';
@@ -103,7 +103,7 @@ export async function chat(messages: UIMessage[]) {
103
103
  const modelMessages = await convertToModelMessages(messages);
104
104
 
105
105
  const agent = new WorkflowAgent({
106
- model: 'anthropic/claude-sonnet-5',
106
+ model: 'anthropic/claude-sonnet-5.5',
107
107
  instructions: 'You are a flight booking assistant.',
108
108
  tools: {
109
109
  searchFlights: tool({
@@ -328,7 +328,7 @@ the writable stream. The workflow suspends until the user approves or denies:
328
328
 
329
329
  ```ts
330
330
  const agent = new WorkflowAgent({
331
- model: 'anthropic/claude-sonnet-5',
331
+ model: 'anthropic/claude-sonnet-5.5',
332
332
  tools: {
333
333
  bookFlight: tool({
334
334
  description: 'Book a flight',
@@ -362,7 +362,7 @@ workflow. For tools that perform sensitive operations, configure
362
362
 
363
363
  ```ts highlight="4"
364
364
  const agent = new WorkflowAgent({
365
- model: 'anthropic/claude-sonnet-5',
365
+ model: 'anthropic/claude-sonnet-5.5',
366
366
  experimental_toolApprovalSecret: {
367
367
  environmentVariable: 'TOOL_APPROVAL_SECRET',
368
368
  },
@@ -526,7 +526,7 @@ current step:
526
526
 
527
527
  ```ts
528
528
  const agent = new WorkflowAgent({
529
- model: 'anthropic/claude-sonnet-5',
529
+ model: 'anthropic/claude-sonnet-5.5',
530
530
  tools: {
531
531
  shell: tool({
532
532
  description: 'Run a shell command in the sandbox.',
@@ -561,7 +561,7 @@ Called once before the agent loop starts. Use it to transform model, instruction
561
561
 
562
562
  ```ts
563
563
  const agent = new WorkflowAgent({
564
- model: 'anthropic/claude-sonnet-5',
564
+ model: 'anthropic/claude-sonnet-5.5',
565
565
  prepareCall: async ({ model, tools, messages }) => {
566
566
  return {
567
567
  instructions: `Current time: ${new Date().toISOString()}`,
@@ -597,7 +597,7 @@ Agents provide lifecycle callbacks for logging, observability, and custom teleme
597
597
 
598
598
  ```ts
599
599
  const agent = new WorkflowAgent({
600
- model: 'anthropic/claude-sonnet-5',
600
+ model: 'anthropic/claude-sonnet-5.5',
601
601
 
602
602
  onStart({ messages }) {
603
603
  console.log(`Agent started with ${messages.length} messages`);
@@ -682,7 +682,7 @@ export type MyAgentUIMessage = InferWorkflowAgentUIMessage<typeof myAgent>;
682
682
 
683
683
  - const agent = new DurableAgent({
684
684
  + const agent = new WorkflowAgent({
685
- model: 'anthropic/claude-sonnet-5',
685
+ model: 'anthropic/claude-sonnet-5.5',
686
686
  instructions: 'You are a helpful assistant.',
687
687
  tools: { /* ... */ },
688
688
  });
@@ -795,7 +795,7 @@ For persistence, store `UIMessage[]` as your source of truth and call [`convertT
795
795
 
796
796
  ```diff
797
797
  const agent = new WorkflowAgent({
798
- model: 'anthropic/claude-sonnet-5',
798
+ model: 'anthropic/claude-sonnet-5.5',
799
799
  tools: { weather: weatherTool },
800
800
  - experimental_context: { tenantId: 'tenant_123', apiKey: 'sk-...' },
801
801
  + runtimeContext: { tenantId: 'tenant_123' },
@@ -13,7 +13,7 @@ When you create prompts that include tools, getting good results can be tricky a
13
13
 
14
14
  Here are a few tips to help you get the best results:
15
15
 
16
- 1. Use a model that is strong at tool calling, such as `gpt-6-astra` or `claude-sonnet-5`. Weaker models will often struggle to call tools effectively and flawlessly.
16
+ 1. Use a model that is strong at tool calling, such as `gpt-6-astra` or `claude-sonnet-5-5`. Weaker models will often struggle to call tools effectively and flawlessly.
17
17
  1. Keep the number of tools low, e.g. to 5 or less.
18
18
  1. Keep the complexity of the tool parameters low. Complex Zod schemas with many nested and optional elements, unions, etc. can be challenging for the model to work with.
19
19
  1. Use semantically meaningful names for your tools, parameters, parameter properties, etc. The more information you pass to the model, the better it can understand what you want.
@@ -13,7 +13,7 @@ Many language models support an internal "reasoning" phase (sometimes also calle
13
13
  import { generateText } from 'ai';
14
14
 
15
15
  const { text, reasoning, reasoningText } = await generateText({
16
- model: 'anthropic/claude-sonnet-5',
16
+ model: 'anthropic/claude-sonnet-5.5',
17
17
  reasoning: 'medium',
18
18
  prompt: 'How many people will live in the world in 2040?',
19
19
  });
@@ -79,7 +79,7 @@ import { customProvider, gateway } from 'ai';
79
79
  export const anthropic = customProvider({
80
80
  languageModels: {
81
81
  opus: gateway('anthropic/claude-opus-5.5'),
82
- sonnet: gateway('anthropic/claude-sonnet-5'),
82
+ sonnet: gateway('anthropic/claude-sonnet-5.5'),
83
83
  haiku: gateway('anthropic/claude-haiku-4.5'),
84
84
  },
85
85
  fallbackProvider: gateway,
@@ -100,7 +100,7 @@ import {
100
100
 
101
101
  export const myProvider = customProvider({
102
102
  languageModels: {
103
- 'text-medium': gateway('anthropic/claude-sonnet-5'),
103
+ 'text-medium': gateway('anthropic/claude-sonnet-5.5'),
104
104
  'text-small': gateway('openai/gpt-6-luna'),
105
105
  'reasoning-medium': wrapLanguageModel({
106
106
  model: gateway('openai/gpt-6-astra'),
@@ -154,7 +154,7 @@ const myOpenAI = customProvider({
154
154
  // custom provider with skills interface:
155
155
  const myAnthropic = customProvider({
156
156
  languageModels: {
157
- sonnet: anthropic('claude-sonnet-5'),
157
+ sonnet: anthropic('claude-sonnet-5-5'),
158
158
  },
159
159
  skills: anthropic.skills(),
160
160
  });
@@ -330,7 +330,7 @@ import { createProviderRegistry, customProvider, uploadSkill } from 'ai';
330
330
 
331
331
  const registry = createProviderRegistry({
332
332
  anthropic: customProvider({
333
- languageModels: { sonnet: anthropic('claude-sonnet-5') },
333
+ languageModels: { sonnet: anthropic('claude-sonnet-5-5') },
334
334
  skills: anthropic.skills(),
335
335
  }),
336
336
  });
@@ -758,6 +758,15 @@ With `streamText`, you can control how error messages and usage information are
758
758
 
759
759
  By default, the error message is masked for security reasons.
760
760
  The default error message is "An error occurred."
761
+
762
+ Tool execution errors marked `providerExecuted: true` are an exception. They
763
+ bypass the UI stream's `onError` callback: strings are forwarded unchanged, and
764
+ other error values are serialized with `JSON.stringify`. This preserves provider
765
+ error codes when chat history is converted back into model messages, as well as
766
+ error messages from harness runtimes. Stream errors and invalid tool calls still
767
+ use `onError`, even for provider-executed tools. Do not rely on this callback to
768
+ redact provider-executed tool execution errors before they reach the client.
769
+
761
770
  You can forward error messages or send your own error message by providing an `onError` function:
762
771
 
763
772
  ```ts filename="app/api/chat/route.ts" highlight="21-35"
@@ -947,7 +956,7 @@ Check out the [stream protocol guide](/docs/ai-sdk-ui/stream-protocol) for more
947
956
  ## Reasoning
948
957
 
949
958
  Some models such as DeepSeek `deepseek-r1`
950
- and Anthropic `claude-sonnet-5` support reasoning tokens.
959
+ and Anthropic `claude-sonnet-5-5` support reasoning tokens.
951
960
  These tokens are typically sent before the message content.
952
961
  You can forward them to the client with the `sendReasoning` option:
953
962
 
@@ -92,6 +92,14 @@ export async function loadChat(id: string): Promise<UIMessage[]> {
92
92
 
93
93
  When processing messages on the server that contain tool calls, custom metadata, or data parts, you should validate them using `validateUIMessages` before sending them to the model.
94
94
 
95
+ ### Persisting streaming tool input
96
+
97
+ An `input-streaming` tool part includes `rawInput` while tool arguments are
98
+ still arriving. Persist the complete UI message, including this field, so a
99
+ resumed stream can append later tool-input deltas to the exact text received
100
+ before the interruption. AI SDK updates `rawInput` as each delta arrives and
101
+ removes it when the tool input becomes available.
102
+
95
103
  ### Migrating deprecated tool `rawInput`
96
104
 
97
105
  Older persisted tool parts in the `output-error` state may contain `rawInput`.
@@ -90,6 +90,10 @@ export function Chat({
90
90
 
91
91
  When you enable `resume`, the `useChat` hook makes a `GET` request to `/api/chat/[id]/stream` on mount to check for and resume any active streams.
92
92
 
93
+ The default transport URL-encodes the chat ID as a single path segment. IDs equal
94
+ to `.` or `..` are rejected with an `InvalidArgumentError` because URL parsers
95
+ interpret them as path traversal segments.
96
+
93
97
  Let's start by creating the POST handler to create the resumable stream.
94
98
 
95
99
  ### 2. Create the POST handler
@@ -220,6 +224,9 @@ The diagram above shows the complete lifecycle of a resumable stream:
220
224
 
221
225
  By default, the `useChat` hook makes a GET request to `/api/chat/[id]/stream` when resuming. Customize this endpoint, credentials, and headers, using the `prepareReconnectToStreamRequest` option in `DefaultChatTransport`:
222
226
 
227
+ The callback receives the original, unencoded ID. Its returned `api` URL is used
228
+ verbatim, so encode and validate any ID you include in a custom URL yourself.
229
+
223
230
  ```tsx filename="app/chat/[chatId]/chat.tsx"
224
231
  import { useChat } from '@ai-sdk/react';
225
232
  import { DefaultChatTransport } from 'ai';
@@ -233,10 +240,10 @@ export function Chat({ chatData, resume }) {
233
240
  // Customize reconnect settings (optional)
234
241
  prepareReconnectToStreamRequest: ({ id }) => {
235
242
  return {
236
- api: `/api/chat/${id}/stream`, // Default pattern
243
+ api: `/api/chat/${encodeURIComponent(id)}/stream`,
237
244
  // Or use a different pattern:
238
- // api: `/api/streams/${id}/resume`,
239
- // api: `/api/resume-chat?id=${id}`,
245
+ // api: `/api/streams/${encodeURIComponent(id)}/resume`,
246
+ // api: `/api/resume-chat?id=${encodeURIComponent(id)}`,
240
247
  credentials: 'include', // Include cookies/auth
241
248
  headers: {
242
249
  Authorization: 'Bearer token',
@@ -780,7 +780,16 @@ export async function POST(req: Request) {
780
780
  Language models can make errors when calling tools.
781
781
  By default, these errors are masked for security reasons, and show up as "An error occurred" in the UI.
782
782
 
783
- To surface the errors, you can use the `onError` function when calling `toUIMessageResponse`.
783
+ Tool execution errors marked `providerExecuted: true` bypass this masking and the
784
+ UI stream's `onError` callback. String errors pass through unchanged; other error
785
+ values are serialized with `JSON.stringify`. The original error data is needed
786
+ when converting persisted UI messages back into model messages, for example to
787
+ preserve Anthropic tool error codes. Harness runtime tool errors also retain
788
+ their original messages. The callback still handles invalid tool calls and
789
+ stream errors, regardless of whether a tool is provider-executed.
790
+
791
+ To customize masked errors, pass `onError` to `toUIMessageStream`. This callback
792
+ does not redact provider-executed tool execution errors sent to the client.
784
793
 
785
794
  ```tsx
786
795
  export function errorHandler(error: unknown) {
@@ -219,7 +219,7 @@ This page pulls in the current UI State using the `useUIState` hook, which is th
219
219
 
220
220
  In this example, to call the next tool, the user must respond with plain text. **Given you are streaming a React component, you can add a button to trigger the next step in the conversation**.
221
221
 
222
- To add user interaction, you will have to convert the component into a client component and use the `useAction` hook to trigger the next step in the conversation.
222
+ To add user interaction, you will have to convert the component into a client component and use the `useActions` hook to trigger the next step in the conversation.
223
223
 
224
224
  ```tsx filename="components/flights.tsx"
225
225
  'use client';
@@ -4133,7 +4133,7 @@ To see `streamText` in action, check out [these examples](#examples).
4133
4133
  type: '(error: unknown) => string',
4134
4134
  isOptional: true,
4135
4135
  description:
4136
- 'Process an error, e.g. to log it. Returns error message to include in the data stream. Defaults to () => "An error occurred."',
4136
+ 'Process an error, e.g. to log it. Returns the error message to include in the data stream. Defaults to () => "An error occurred." Tool execution errors marked providerExecuted: true bypass this callback: strings pass through unchanged and other values are JSON-stringified to preserve provider error data for model-message round trips and harness runtime error messages. Stream errors and invalid tool calls still use this callback.',
4137
4137
  },
4138
4138
  {
4139
4139
  name: 'consumeSseStream',
@@ -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-5',
20
+ model: 'anthropic/claude-sonnet-5.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-5') or a provider instance (e.g., `openai('gpt-6-astra')`).",
74
+ "The language model to use. A string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-sonnet-5.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-5',
811
+ model: 'anthropic/claude-sonnet-5.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-5',
838
+ model: 'anthropic/claude-sonnet-5.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-5',
893
+ model: 'anthropic/claude-sonnet-5.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-5',
940
+ model: 'anthropic/claude-sonnet-5.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-5',
980
+ model: 'anthropic/claude-sonnet-5.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-5',
1012
+ model: 'anthropic/claude-sonnet-5.5',
1013
1013
  tools: { weather: weatherTool },
1014
1014
 
1015
1015
  // Agent-wide callbacks
@@ -27,8 +27,8 @@ description: Learn how to upgrade AI SDK 3.4 to 4.0.
27
27
  You need to update the following packages to the following versions in your `package.json` file(s):
28
28
 
29
29
  - `ai` package: `4.0.*`
30
- - `ai-sdk@provider-utils` package: `2.0.*`
31
- - `ai-sdk/*` packages: `1.0.*` (other `@ai-sdk` packages)
30
+ - `@ai-sdk/provider-utils` package: `2.0.*`
31
+ - `@ai-sdk/*` packages: `1.0.*` (other `@ai-sdk/*` packages)
32
32
 
33
33
  ## Codemods
34
34
 
@@ -518,7 +518,7 @@ import { Provider } from 'ai';
518
518
  providers](/docs/reference/ai-sdk-core/provider-registry#setup) instead.
519
519
  </Note>
520
520
 
521
- #### Removed `experimental_​createModelRegistry` function
521
+ #### Removed `experimental_createModelRegistry` function
522
522
 
523
523
  The `experimental_createModelRegistry` function has been removed.
524
524
  Please use the `experimental_createProviderRegistry` function instead.
@@ -621,7 +621,7 @@ const { text, response } = await generateText({
621
621
  const responseMessages = response.messages;
622
622
  ```
623
623
 
624
- ### Removed `experimental_​continuationSteps` option
624
+ ### Removed `experimental_continuationSteps` option
625
625
 
626
626
  The `experimental_continuationSteps` option has been removed from the `generateText` function.
627
627
  Please use the `experimental_continueSteps` option instead.
@@ -965,7 +965,7 @@ return AssistantResponse(
965
965
  );
966
966
  ```
967
967
 
968
- #### Removed `experimental_​AssistantResponse` export
968
+ #### Removed `experimental_AssistantResponse` export
969
969
 
970
970
  <Note type="warning">
971
971
  There is no codemod available for this change. Please review and update your
@@ -18,7 +18,7 @@ introducing significant improvements and new features across the AI SDK and its
18
18
 
19
19
  ## New Features
20
20
 
21
- ### Open Telemetry Support
21
+ ### OpenTelemetry Support
22
22
 
23
23
  - Added experimental [OpenTelemetry support](/docs/ai-sdk-core/telemetry) for all [AI SDK Core functions](/docs/ai-sdk-core/overview#ai-sdk-core-functions), enabling better observability and tracing capabilities.
24
24