ai 6.0.31 → 6.0.33

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 (252) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.js +12 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +12 -2
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/internal/index.js +1 -1
  7. package/dist/internal/index.mjs +1 -1
  8. package/docs/00-introduction/index.mdx +76 -0
  9. package/docs/02-foundations/01-overview.mdx +43 -0
  10. package/docs/02-foundations/02-providers-and-models.mdx +163 -0
  11. package/docs/02-foundations/03-prompts.mdx +620 -0
  12. package/docs/02-foundations/04-tools.mdx +160 -0
  13. package/docs/02-foundations/05-streaming.mdx +62 -0
  14. package/docs/02-foundations/index.mdx +43 -0
  15. package/docs/02-getting-started/00-choosing-a-provider.mdx +110 -0
  16. package/docs/02-getting-started/01-navigating-the-library.mdx +85 -0
  17. package/docs/02-getting-started/02-nextjs-app-router.mdx +556 -0
  18. package/docs/02-getting-started/03-nextjs-pages-router.mdx +542 -0
  19. package/docs/02-getting-started/04-svelte.mdx +627 -0
  20. package/docs/02-getting-started/05-nuxt.mdx +566 -0
  21. package/docs/02-getting-started/06-nodejs.mdx +512 -0
  22. package/docs/02-getting-started/07-expo.mdx +766 -0
  23. package/docs/02-getting-started/08-tanstack-start.mdx +583 -0
  24. package/docs/02-getting-started/index.mdx +44 -0
  25. package/docs/03-agents/01-overview.mdx +96 -0
  26. package/docs/03-agents/02-building-agents.mdx +367 -0
  27. package/docs/03-agents/03-workflows.mdx +370 -0
  28. package/docs/03-agents/04-loop-control.mdx +350 -0
  29. package/docs/03-agents/05-configuring-call-options.mdx +286 -0
  30. package/docs/03-agents/index.mdx +40 -0
  31. package/docs/03-ai-sdk-core/01-overview.mdx +33 -0
  32. package/docs/03-ai-sdk-core/05-generating-text.mdx +600 -0
  33. package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +662 -0
  34. package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +1102 -0
  35. package/docs/03-ai-sdk-core/16-mcp-tools.mdx +375 -0
  36. package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +144 -0
  37. package/docs/03-ai-sdk-core/25-settings.mdx +198 -0
  38. package/docs/03-ai-sdk-core/30-embeddings.mdx +247 -0
  39. package/docs/03-ai-sdk-core/31-reranking.mdx +218 -0
  40. package/docs/03-ai-sdk-core/35-image-generation.mdx +341 -0
  41. package/docs/03-ai-sdk-core/36-transcription.mdx +173 -0
  42. package/docs/03-ai-sdk-core/37-speech.mdx +167 -0
  43. package/docs/03-ai-sdk-core/40-middleware.mdx +480 -0
  44. package/docs/03-ai-sdk-core/45-provider-management.mdx +349 -0
  45. package/docs/03-ai-sdk-core/50-error-handling.mdx +149 -0
  46. package/docs/03-ai-sdk-core/55-testing.mdx +218 -0
  47. package/docs/03-ai-sdk-core/60-telemetry.mdx +313 -0
  48. package/docs/03-ai-sdk-core/65-devtools.mdx +107 -0
  49. package/docs/03-ai-sdk-core/index.mdx +88 -0
  50. package/docs/04-ai-sdk-ui/01-overview.mdx +44 -0
  51. package/docs/04-ai-sdk-ui/02-chatbot.mdx +1313 -0
  52. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +535 -0
  53. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +263 -0
  54. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +682 -0
  55. package/docs/04-ai-sdk-ui/04-generative-user-interfaces.mdx +389 -0
  56. package/docs/04-ai-sdk-ui/05-completion.mdx +186 -0
  57. package/docs/04-ai-sdk-ui/08-object-generation.mdx +344 -0
  58. package/docs/04-ai-sdk-ui/20-streaming-data.mdx +397 -0
  59. package/docs/04-ai-sdk-ui/21-error-handling.mdx +190 -0
  60. package/docs/04-ai-sdk-ui/21-transport.mdx +174 -0
  61. package/docs/04-ai-sdk-ui/24-reading-ui-message-streams.mdx +104 -0
  62. package/docs/04-ai-sdk-ui/25-message-metadata.mdx +152 -0
  63. package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +477 -0
  64. package/docs/04-ai-sdk-ui/index.mdx +64 -0
  65. package/docs/05-ai-sdk-rsc/01-overview.mdx +45 -0
  66. package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +209 -0
  67. package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +279 -0
  68. package/docs/05-ai-sdk-rsc/03-saving-and-restoring-states.mdx +105 -0
  69. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +282 -0
  70. package/docs/05-ai-sdk-rsc/05-streaming-values.mdx +158 -0
  71. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +273 -0
  72. package/docs/05-ai-sdk-rsc/08-error-handling.mdx +96 -0
  73. package/docs/05-ai-sdk-rsc/09-authentication.mdx +42 -0
  74. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +722 -0
  75. package/docs/05-ai-sdk-rsc/index.mdx +58 -0
  76. package/docs/06-advanced/01-prompt-engineering.mdx +96 -0
  77. package/docs/06-advanced/02-stopping-streams.mdx +184 -0
  78. package/docs/06-advanced/03-backpressure.mdx +173 -0
  79. package/docs/06-advanced/04-caching.mdx +169 -0
  80. package/docs/06-advanced/05-multiple-streamables.mdx +68 -0
  81. package/docs/06-advanced/06-rate-limiting.mdx +60 -0
  82. package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +213 -0
  83. package/docs/06-advanced/08-model-as-router.mdx +120 -0
  84. package/docs/06-advanced/09-multistep-interfaces.mdx +115 -0
  85. package/docs/06-advanced/09-sequential-generations.mdx +55 -0
  86. package/docs/06-advanced/10-vercel-deployment-guide.mdx +117 -0
  87. package/docs/06-advanced/index.mdx +11 -0
  88. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +2142 -0
  89. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +3215 -0
  90. package/docs/07-reference/01-ai-sdk-core/03-generate-object.mdx +780 -0
  91. package/docs/07-reference/01-ai-sdk-core/04-stream-object.mdx +1140 -0
  92. package/docs/07-reference/01-ai-sdk-core/05-embed.mdx +190 -0
  93. package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +171 -0
  94. package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +309 -0
  95. package/docs/07-reference/01-ai-sdk-core/10-generate-image.mdx +227 -0
  96. package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +138 -0
  97. package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +214 -0
  98. package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +203 -0
  99. package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +449 -0
  100. package/docs/07-reference/01-ai-sdk-core/17-create-agent-ui-stream.mdx +148 -0
  101. package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +168 -0
  102. package/docs/07-reference/01-ai-sdk-core/18-pipe-agent-ui-stream-to-response.mdx +144 -0
  103. package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +196 -0
  104. package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +175 -0
  105. package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +410 -0
  106. package/docs/07-reference/01-ai-sdk-core/24-mcp-stdio-transport.mdx +68 -0
  107. package/docs/07-reference/01-ai-sdk-core/25-json-schema.mdx +94 -0
  108. package/docs/07-reference/01-ai-sdk-core/26-zod-schema.mdx +109 -0
  109. package/docs/07-reference/01-ai-sdk-core/27-valibot-schema.mdx +55 -0
  110. package/docs/07-reference/01-ai-sdk-core/28-output.mdx +342 -0
  111. package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +415 -0
  112. package/docs/07-reference/01-ai-sdk-core/31-ui-message.mdx +246 -0
  113. package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +101 -0
  114. package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +113 -0
  115. package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +182 -0
  116. package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +121 -0
  117. package/docs/07-reference/01-ai-sdk-core/50-cosine-similarity.mdx +52 -0
  118. package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +59 -0
  119. package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +64 -0
  120. package/docs/07-reference/01-ai-sdk-core/65-language-model-v2-middleware.mdx +46 -0
  121. package/docs/07-reference/01-ai-sdk-core/66-extract-reasoning-middleware.mdx +68 -0
  122. package/docs/07-reference/01-ai-sdk-core/67-simulate-streaming-middleware.mdx +71 -0
  123. package/docs/07-reference/01-ai-sdk-core/68-default-settings-middleware.mdx +80 -0
  124. package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +155 -0
  125. package/docs/07-reference/01-ai-sdk-core/70-extract-json-middleware.mdx +147 -0
  126. package/docs/07-reference/01-ai-sdk-core/70-step-count-is.mdx +84 -0
  127. package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +120 -0
  128. package/docs/07-reference/01-ai-sdk-core/75-simulate-readable-stream.mdx +94 -0
  129. package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +145 -0
  130. package/docs/07-reference/01-ai-sdk-core/90-generate-id.mdx +43 -0
  131. package/docs/07-reference/01-ai-sdk-core/91-create-id-generator.mdx +89 -0
  132. package/docs/07-reference/01-ai-sdk-core/index.mdx +159 -0
  133. package/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +446 -0
  134. package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +179 -0
  135. package/docs/07-reference/02-ai-sdk-ui/03-use-object.mdx +178 -0
  136. package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +230 -0
  137. package/docs/07-reference/02-ai-sdk-ui/32-prune-messages.mdx +108 -0
  138. package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +151 -0
  139. package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +113 -0
  140. package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +73 -0
  141. package/docs/07-reference/02-ai-sdk-ui/43-read-ui-message-stream.mdx +57 -0
  142. package/docs/07-reference/02-ai-sdk-ui/46-infer-ui-tools.mdx +99 -0
  143. package/docs/07-reference/02-ai-sdk-ui/47-infer-ui-tool.mdx +75 -0
  144. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +333 -0
  145. package/docs/07-reference/02-ai-sdk-ui/index.mdx +89 -0
  146. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +767 -0
  147. package/docs/07-reference/03-ai-sdk-rsc/02-create-ai.mdx +90 -0
  148. package/docs/07-reference/03-ai-sdk-rsc/03-create-streamable-ui.mdx +91 -0
  149. package/docs/07-reference/03-ai-sdk-rsc/04-create-streamable-value.mdx +48 -0
  150. package/docs/07-reference/03-ai-sdk-rsc/05-read-streamable-value.mdx +78 -0
  151. package/docs/07-reference/03-ai-sdk-rsc/06-get-ai-state.mdx +50 -0
  152. package/docs/07-reference/03-ai-sdk-rsc/07-get-mutable-ai-state.mdx +70 -0
  153. package/docs/07-reference/03-ai-sdk-rsc/08-use-ai-state.mdx +26 -0
  154. package/docs/07-reference/03-ai-sdk-rsc/09-use-actions.mdx +42 -0
  155. package/docs/07-reference/03-ai-sdk-rsc/10-use-ui-state.mdx +35 -0
  156. package/docs/07-reference/03-ai-sdk-rsc/11-use-streamable-value.mdx +46 -0
  157. package/docs/07-reference/03-ai-sdk-rsc/20-render.mdx +262 -0
  158. package/docs/07-reference/03-ai-sdk-rsc/index.mdx +67 -0
  159. package/docs/07-reference/04-stream-helpers/01-ai-stream.mdx +89 -0
  160. package/docs/07-reference/04-stream-helpers/02-streaming-text-response.mdx +79 -0
  161. package/docs/07-reference/04-stream-helpers/05-stream-to-response.mdx +108 -0
  162. package/docs/07-reference/04-stream-helpers/07-openai-stream.mdx +77 -0
  163. package/docs/07-reference/04-stream-helpers/08-anthropic-stream.mdx +79 -0
  164. package/docs/07-reference/04-stream-helpers/09-aws-bedrock-stream.mdx +91 -0
  165. package/docs/07-reference/04-stream-helpers/10-aws-bedrock-anthropic-stream.mdx +96 -0
  166. package/docs/07-reference/04-stream-helpers/10-aws-bedrock-messages-stream.mdx +96 -0
  167. package/docs/07-reference/04-stream-helpers/11-aws-bedrock-cohere-stream.mdx +93 -0
  168. package/docs/07-reference/04-stream-helpers/12-aws-bedrock-llama-2-stream.mdx +93 -0
  169. package/docs/07-reference/04-stream-helpers/13-cohere-stream.mdx +78 -0
  170. package/docs/07-reference/04-stream-helpers/14-google-generative-ai-stream.mdx +85 -0
  171. package/docs/07-reference/04-stream-helpers/15-hugging-face-stream.mdx +84 -0
  172. package/docs/07-reference/04-stream-helpers/16-langchain-adapter.mdx +98 -0
  173. package/docs/07-reference/04-stream-helpers/16-llamaindex-adapter.mdx +70 -0
  174. package/docs/07-reference/04-stream-helpers/17-mistral-stream.mdx +81 -0
  175. package/docs/07-reference/04-stream-helpers/18-replicate-stream.mdx +83 -0
  176. package/docs/07-reference/04-stream-helpers/19-inkeep-stream.mdx +80 -0
  177. package/docs/07-reference/04-stream-helpers/index.mdx +103 -0
  178. package/docs/07-reference/05-ai-sdk-errors/ai-api-call-error.mdx +30 -0
  179. package/docs/07-reference/05-ai-sdk-errors/ai-download-error.mdx +27 -0
  180. package/docs/07-reference/05-ai-sdk-errors/ai-empty-response-body-error.mdx +24 -0
  181. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-argument-error.mdx +26 -0
  182. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content-error.mdx +25 -0
  183. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content.mdx +26 -0
  184. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-message-role-error.mdx +25 -0
  185. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-prompt-error.mdx +47 -0
  186. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-response-data-error.mdx +25 -0
  187. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-error.mdx +25 -0
  188. package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-input-error.mdx +27 -0
  189. package/docs/07-reference/05-ai-sdk-errors/ai-json-parse-error.mdx +25 -0
  190. package/docs/07-reference/05-ai-sdk-errors/ai-load-api-key-error.mdx +24 -0
  191. package/docs/07-reference/05-ai-sdk-errors/ai-load-setting-error.mdx +24 -0
  192. package/docs/07-reference/05-ai-sdk-errors/ai-message-conversion-error.mdx +25 -0
  193. package/docs/07-reference/05-ai-sdk-errors/ai-no-content-generated-error.mdx +24 -0
  194. package/docs/07-reference/05-ai-sdk-errors/ai-no-image-generated-error.mdx +36 -0
  195. package/docs/07-reference/05-ai-sdk-errors/ai-no-object-generated-error.mdx +43 -0
  196. package/docs/07-reference/05-ai-sdk-errors/ai-no-speech-generated-error.mdx +25 -0
  197. package/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +26 -0
  198. package/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +28 -0
  199. package/docs/07-reference/05-ai-sdk-errors/ai-no-such-tool-error.mdx +26 -0
  200. package/docs/07-reference/05-ai-sdk-errors/ai-no-transcript-generated-error.mdx +25 -0
  201. package/docs/07-reference/05-ai-sdk-errors/ai-retry-error.mdx +27 -0
  202. package/docs/07-reference/05-ai-sdk-errors/ai-too-many-embedding-values-for-call-error.mdx +27 -0
  203. package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-not-found-for-approval-error.mdx +26 -0
  204. package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-repair-error.mdx +28 -0
  205. package/docs/07-reference/05-ai-sdk-errors/ai-type-validation-error.mdx +25 -0
  206. package/docs/07-reference/05-ai-sdk-errors/ai-unsupported-functionality-error.mdx +25 -0
  207. package/docs/07-reference/05-ai-sdk-errors/index.mdx +38 -0
  208. package/docs/07-reference/index.mdx +34 -0
  209. package/docs/08-migration-guides/00-versioning.mdx +46 -0
  210. package/docs/08-migration-guides/24-migration-guide-6-0.mdx +823 -0
  211. package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +882 -0
  212. package/docs/08-migration-guides/26-migration-guide-5-0.mdx +3427 -0
  213. package/docs/08-migration-guides/27-migration-guide-4-2.mdx +99 -0
  214. package/docs/08-migration-guides/28-migration-guide-4-1.mdx +14 -0
  215. package/docs/08-migration-guides/29-migration-guide-4-0.mdx +1157 -0
  216. package/docs/08-migration-guides/36-migration-guide-3-4.mdx +14 -0
  217. package/docs/08-migration-guides/37-migration-guide-3-3.mdx +64 -0
  218. package/docs/08-migration-guides/38-migration-guide-3-2.mdx +46 -0
  219. package/docs/08-migration-guides/39-migration-guide-3-1.mdx +168 -0
  220. package/docs/08-migration-guides/index.mdx +22 -0
  221. package/docs/09-troubleshooting/01-azure-stream-slow.mdx +33 -0
  222. package/docs/09-troubleshooting/02-client-side-function-calls-not-invoked.mdx +22 -0
  223. package/docs/09-troubleshooting/03-server-actions-in-client-components.mdx +40 -0
  224. package/docs/09-troubleshooting/04-strange-stream-output.mdx +36 -0
  225. package/docs/09-troubleshooting/05-streamable-ui-errors.mdx +16 -0
  226. package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +106 -0
  227. package/docs/09-troubleshooting/06-streaming-not-working-when-deployed.mdx +31 -0
  228. package/docs/09-troubleshooting/06-streaming-not-working-when-proxied.mdx +31 -0
  229. package/docs/09-troubleshooting/06-timeout-on-vercel.mdx +60 -0
  230. package/docs/09-troubleshooting/07-unclosed-streams.mdx +34 -0
  231. package/docs/09-troubleshooting/08-use-chat-failed-to-parse-stream.mdx +26 -0
  232. package/docs/09-troubleshooting/09-client-stream-error.mdx +25 -0
  233. package/docs/09-troubleshooting/10-use-chat-tools-no-response.mdx +32 -0
  234. package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +149 -0
  235. package/docs/09-troubleshooting/12-typescript-performance-zod.mdx +46 -0
  236. package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +59 -0
  237. package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +73 -0
  238. package/docs/09-troubleshooting/14-stream-abort-handling.mdx +73 -0
  239. package/docs/09-troubleshooting/14-tool-calling-with-structured-outputs.mdx +48 -0
  240. package/docs/09-troubleshooting/15-abort-breaks-resumable-streams.mdx +55 -0
  241. package/docs/09-troubleshooting/15-stream-text-not-working.mdx +33 -0
  242. package/docs/09-troubleshooting/16-streaming-status-delay.mdx +63 -0
  243. package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +141 -0
  244. package/docs/09-troubleshooting/18-ontoolcall-type-narrowing.mdx +66 -0
  245. package/docs/09-troubleshooting/19-unsupported-model-version.mdx +50 -0
  246. package/docs/09-troubleshooting/20-no-object-generated-content-filter.mdx +72 -0
  247. package/docs/09-troubleshooting/30-model-is-not-assignable-to-type.mdx +21 -0
  248. package/docs/09-troubleshooting/40-typescript-cannot-find-namespace-jsx.mdx +24 -0
  249. package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +39 -0
  250. package/docs/09-troubleshooting/60-jest-cannot-find-module-ai-rsc.mdx +22 -0
  251. package/docs/09-troubleshooting/index.mdx +11 -0
  252. package/package.json +8 -4
@@ -0,0 +1,823 @@
1
+ ---
2
+ title: Migrate AI SDK 5.x to 6.0
3
+ description: Learn how to upgrade AI SDK 5.x to 6.0.
4
+ ---
5
+
6
+ # Migrate AI SDK 5.x to 6.0
7
+
8
+ ## Recommended Migration Process
9
+
10
+ 1. Backup your project. If you use a versioning control system, make sure all previous versions are committed.
11
+ 1. Upgrade to AI SDK 6.0.
12
+ 1. Follow the breaking changes guide below.
13
+ 1. Verify your project is working as expected.
14
+ 1. Commit your changes.
15
+
16
+ ## AI SDK 6.0 Package Versions
17
+
18
+ You need to update the following packages to the latest versions in your `package.json` file(s):
19
+
20
+ - `ai` package: `^6.0.0`
21
+ - `@ai-sdk/provider` package: `^3.0.0`
22
+ - `@ai-sdk/provider-utils` package: `^4.0.0`
23
+ - `@ai-sdk/*` packages: `^3.0.0`
24
+
25
+ An example upgrade command would be:
26
+
27
+ ```
28
+ pnpm install ai@latest @ai-sdk/react@latest @ai-sdk/openai@latest
29
+ ```
30
+
31
+ ## Codemods
32
+
33
+ The AI SDK provides Codemod transformations to help upgrade your codebase when a
34
+ feature is deprecated, removed, or otherwise changed.
35
+
36
+ Codemods are transformations that run on your codebase automatically. They
37
+ allow you to easily apply many changes without having to manually go through
38
+ every file.
39
+
40
+ You can run all v6 codemods (v5 → v6 migration) by running the following command
41
+ from the root of your project:
42
+
43
+ ```sh
44
+ npx @ai-sdk/codemod v6
45
+ ```
46
+
47
+ <Note>
48
+ There is also an `npx @ai-sdk/codemod upgrade` command, but it runs all
49
+ codemods from all versions (v4, v5, and v6). Use `v6` when upgrading from v5.
50
+ </Note>
51
+
52
+ Individual codemods can be run by specifying the name of the codemod:
53
+
54
+ ```sh
55
+ npx @ai-sdk/codemod <codemod-name> <path>
56
+ ```
57
+
58
+ For example, to run a specific v6 codemod:
59
+
60
+ ```sh
61
+ npx @ai-sdk/codemod v6/rename-text-embedding-to-embedding src/
62
+ ```
63
+
64
+ <Note>
65
+ Codemods are intended as a tool to help you with the upgrade process. They may
66
+ not cover all of the changes you need to make. You may need to make additional
67
+ changes manually.
68
+ </Note>
69
+
70
+ ## Codemod Table
71
+
72
+ | Codemod Name | Description |
73
+ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
74
+ | `rename-text-embedding-to-embedding` | Renames `textEmbeddingModel` to `embeddingModel` and `textEmbedding` to `embedding` on providers |
75
+ | `rename-mock-v2-to-v3` | Renames V2 mock classes from `ai/test` to V3 (e.g., `MockLanguageModelV2` → `MockLanguageModelV3`) |
76
+ | `rename-tool-call-options-to-tool-execution-options` | Renames the `ToolCallOptions` type to `ToolExecutionOptions` |
77
+ | `rename-core-message-to-model-message` | Renames the `CoreMessage` type to `ModelMessage` |
78
+ | `rename-converttocoremessages-to-converttomodelmessages` | Renames `convertToCoreMessages` function to `convertToModelMessages` |
79
+ | `rename-vertex-provider-metadata-key` | Renames `google` to `vertex` in `providerMetadata` and `providerOptions` for Google Vertex files |
80
+ | `wrap-tomodeloutput-parameter` | Wraps `toModelOutput` parameter in object destructuring (`output` → `{ output }`) |
81
+ | `add-await-converttomodelmessages` | Adds `await` to `convertToModelMessages` calls (now async in AI SDK 6) |
82
+
83
+ ## AI SDK Core
84
+
85
+ ### `Experimental_Agent` to `ToolLoopAgent` Class
86
+
87
+ The `Experimental_Agent` class has been replaced with the `ToolLoopAgent` class. Two key changes:
88
+
89
+ 1. The `system` parameter has been renamed to `instructions`
90
+ 2. The default `stopWhen` has changed from `stepCountIs(1)` to `stepCountIs(20)`
91
+
92
+ ```tsx filename="AI SDK 5"
93
+ import { Experimental_Agent as Agent, stepCountIs } from 'ai';
94
+ __PROVIDER_IMPORT__;
95
+
96
+ const agent = new Agent({
97
+ model: __MODEL__,
98
+ system: 'You are a helpful assistant.',
99
+ tools: {
100
+ // your tools here
101
+ },
102
+ stopWhen: stepCountIs(20), // Required for multi-step agent loops
103
+ });
104
+
105
+ const result = await agent.generate({
106
+ prompt: 'What is the weather in San Francisco?',
107
+ });
108
+ ```
109
+
110
+ ```tsx filename="AI SDK 6"
111
+ import { ToolLoopAgent } from 'ai';
112
+ __PROVIDER_IMPORT__;
113
+
114
+ const agent = new ToolLoopAgent({
115
+ model: __MODEL__,
116
+ instructions: 'You are a helpful assistant.',
117
+ tools: {
118
+ // your tools here
119
+ },
120
+ // stopWhen defaults to stepCountIs(20)
121
+ });
122
+
123
+ const result = await agent.generate({
124
+ prompt: 'What is the weather in San Francisco?',
125
+ });
126
+ ```
127
+
128
+ Learn more about [building agents](/docs/agents/building-agents).
129
+
130
+ ### `CoreMessage` Removal
131
+
132
+ The deprecated `CoreMessage` type and related functions have been removed ([PR #10710](https://github.com/vercel/ai/pull/10710)). Replace `convertToCoreMessages` with `convertToModelMessages`.
133
+
134
+ ```tsx filename="AI SDK 5"
135
+ import { convertToCoreMessages, type CoreMessage } from 'ai';
136
+
137
+ const coreMessages = convertToCoreMessages(messages); // CoreMessage[]
138
+ ```
139
+
140
+ ```tsx filename="AI SDK 6"
141
+ import { convertToModelMessages, type ModelMessage } from 'ai';
142
+
143
+ const modelMessages = await convertToModelMessages(messages); // ModelMessage[]
144
+ ```
145
+
146
+ <Note>
147
+ Use the `rename-core-message-to-model-message` and
148
+ `rename-converttocoremessages-to-converttomodelmessages` codemods to
149
+ automatically update your codebase.
150
+ </Note>
151
+
152
+ ### `generateObject` and `streamObject` Deprecation
153
+
154
+ `generateObject` and `streamObject` have been deprecated ([PR #10754](https://github.com/vercel/ai/pull/10754)).
155
+ They will be removed in a future version.
156
+ Use `generateText` and `streamText` with an `output` setting instead.
157
+
158
+ ```tsx filename="AI SDK 5"
159
+ import { generateObject } from 'ai';
160
+ __PROVIDER_IMPORT__;
161
+ import { z } from 'zod';
162
+
163
+ const { object } = await generateObject({
164
+ model: __MODEL__,
165
+ schema: z.object({
166
+ recipe: z.object({
167
+ name: z.string(),
168
+ ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
169
+ steps: z.array(z.string()),
170
+ }),
171
+ }),
172
+ prompt: 'Generate a lasagna recipe.',
173
+ });
174
+ ```
175
+
176
+ ```tsx filename="AI SDK 6"
177
+ import { generateText, Output } from 'ai';
178
+ __PROVIDER_IMPORT__;
179
+ import { z } from 'zod';
180
+
181
+ const { output } = await generateText({
182
+ model: __MODEL__,
183
+ output: Output.object({
184
+ schema: z.object({
185
+ recipe: z.object({
186
+ name: z.string(),
187
+ ingredients: z.array(
188
+ z.object({ name: z.string(), amount: z.string() }),
189
+ ),
190
+ steps: z.array(z.string()),
191
+ }),
192
+ }),
193
+ }),
194
+ prompt: 'Generate a lasagna recipe.',
195
+ });
196
+ ```
197
+
198
+ For streaming structured data, replace `streamObject` with `streamText`:
199
+
200
+ ```tsx filename="AI SDK 5"
201
+ import { streamObject } from 'ai';
202
+ __PROVIDER_IMPORT__;
203
+ import { z } from 'zod';
204
+
205
+ const { partialObjectStream } = streamObject({
206
+ model: __MODEL__,
207
+ schema: z.object({
208
+ recipe: z.object({
209
+ name: z.string(),
210
+ ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
211
+ steps: z.array(z.string()),
212
+ }),
213
+ }),
214
+ prompt: 'Generate a lasagna recipe.',
215
+ });
216
+
217
+ for await (const partialObject of partialObjectStream) {
218
+ console.log(partialObject);
219
+ }
220
+ ```
221
+
222
+ ```tsx filename="AI SDK 6"
223
+ import { streamText, Output } from 'ai';
224
+ __PROVIDER_IMPORT__;
225
+ import { z } from 'zod';
226
+
227
+ const { partialOutputStream } = streamText({
228
+ model: __MODEL__,
229
+ output: Output.object({
230
+ schema: z.object({
231
+ recipe: z.object({
232
+ name: z.string(),
233
+ ingredients: z.array(
234
+ z.object({ name: z.string(), amount: z.string() }),
235
+ ),
236
+ steps: z.array(z.string()),
237
+ }),
238
+ }),
239
+ }),
240
+ prompt: 'Generate a lasagna recipe.',
241
+ });
242
+
243
+ for await (const partialObject of partialOutputStream) {
244
+ console.log(partialObject);
245
+ }
246
+ ```
247
+
248
+ Learn more about [generating structured data](/docs/ai-sdk-core/generating-structured-data).
249
+
250
+ ### async `convertToModelMessages`
251
+
252
+ `convertToModelMessages()` is async in AI SDK 6 to support async `Tool.toModelOutput()`.
253
+
254
+ ```tsx filename="AI SDK 5"
255
+ import { convertToModelMessages } from 'ai';
256
+
257
+ const modelMessages = convertToModelMessages(uiMessages);
258
+ ```
259
+
260
+ ```tsx filename="AI SDK 6"
261
+ import { convertToModelMessages } from 'ai';
262
+
263
+ const modelMessages = await convertToModelMessages(uiMessages);
264
+ ```
265
+
266
+ <Note>
267
+ Use the `add-await-converttomodelmessages` codemod to automatically update
268
+ your codebase.
269
+ </Note>
270
+
271
+ ### `Tool.toModelOutput` changes
272
+
273
+ `toModelOutput()` receives a parameter object with an `output` property in AI SDK 6.
274
+
275
+ In AI SDK 5, the `output` was the arguments.
276
+
277
+ ```tsx filename="AI SDK 5"
278
+ import { tool } from 'ai';
279
+
280
+ const someTool = tool({
281
+ // ...
282
+ toModelOutput: output => {
283
+ // ...
284
+ },
285
+ });
286
+ ```
287
+
288
+ ```tsx filename="AI SDK 6"
289
+ import { tool } from 'ai';
290
+
291
+ const someTool = tool({
292
+ // ...
293
+ toModelOutput: ({ output }) => {
294
+ // ...
295
+ },
296
+ });
297
+ ```
298
+
299
+ <Note>
300
+ Use the `wrap-tomodeloutput-parameter` codemod to automatically update your
301
+ codebase.
302
+ </Note>
303
+
304
+ ### `cachedInputTokens` and `reasoningTokens` in `LanguageModelUsage` Deprecation
305
+
306
+ `cachedInputTokens` and `reasoningTokens` in `LanguageModelUsage` have been deprecated.
307
+
308
+ You can replace `cachedInputTokens` with `inputTokenDetails.cacheReadTokens`
309
+ and `reasoningTokens` with `outputTokenDetails.reasoningTokens`.
310
+
311
+ ### `ToolCallOptions` to `ToolExecutionOptions` Rename
312
+
313
+ The `ToolCallOptions` type has been renamed to `ToolExecutionOptions`
314
+ and is now deprecated.
315
+
316
+ <Note>
317
+ Use the `rename-tool-call-options-to-tool-execution-options` codemod to
318
+ automatically update your codebase.
319
+ </Note>
320
+
321
+ ### Per-Tool Strict Mode
322
+
323
+ Strict mode for tools is now controlled by setting `strict` on each tool ([PR #10817](https://github.com/vercel/ai/pull/10817)). This enables fine-grained control over strict tool calls, which is important since strict mode depends on the specific tool input schema.
324
+
325
+ ```tsx filename="AI SDK 5"
326
+ __PROVIDER_IMPORT__;
327
+ import { streamText, tool } from 'ai';
328
+ import { z } from 'zod';
329
+
330
+ // Tool strict mode was controlled by strictJsonSchema
331
+ const result = streamText({
332
+ model: __MODEL__,
333
+ tools: {
334
+ calculator: tool({
335
+ description: 'A simple calculator',
336
+ inputSchema: z.object({
337
+ expression: z.string(),
338
+ }),
339
+ execute: async ({ expression }) => {
340
+ const result = eval(expression);
341
+ return { result };
342
+ },
343
+ }),
344
+ },
345
+ providerOptions: {
346
+ openai: {
347
+ strictJsonSchema: true, // Applied to all tools
348
+ },
349
+ },
350
+ });
351
+ ```
352
+
353
+ ```tsx filename="AI SDK 6"
354
+ __PROVIDER_IMPORT__;
355
+ import { streamText, tool } from 'ai';
356
+ import { z } from 'zod';
357
+
358
+ const result = streamText({
359
+ model: __MODEL__,
360
+ tools: {
361
+ calculator: tool({
362
+ description: 'A simple calculator',
363
+ inputSchema: z.object({
364
+ expression: z.string(),
365
+ }),
366
+ execute: async ({ expression }) => {
367
+ const result = eval(expression);
368
+ return { result };
369
+ },
370
+ strict: true, // Control strict mode per tool
371
+ }),
372
+ },
373
+ });
374
+ ```
375
+
376
+ ### Flexible Tool Content
377
+
378
+ AI SDK 6 introduces more flexible tool output and result content support ([PR #9605](https://github.com/vercel/ai/pull/9605)), enabling richer tool interactions and better support for complex tool execution patterns.
379
+
380
+ ### `ToolCallRepairFunction` Signature
381
+
382
+ The `system` parameter in the `ToolCallRepairFunction` type now accepts `SystemModelMessage` in addition to `string` ([PR #10635](https://github.com/vercel/ai/pull/10635)). This allows for more flexible system message configuration, including provider-specific options like caching.
383
+
384
+ ```tsx filename="AI SDK 5"
385
+ import type { ToolCallRepairFunction } from 'ai';
386
+
387
+ const repairToolCall: ToolCallRepairFunction<MyTools> = async ({
388
+ system, // type: string | undefined
389
+ messages,
390
+ toolCall,
391
+ tools,
392
+ inputSchema,
393
+ error,
394
+ }) => {
395
+ // ...
396
+ };
397
+ ```
398
+
399
+ ```tsx filename="AI SDK 6"
400
+ import type { ToolCallRepairFunction, SystemModelMessage } from 'ai';
401
+
402
+ const repairToolCall: ToolCallRepairFunction<MyTools> = async ({
403
+ system, // type: string | SystemModelMessage | undefined
404
+ messages,
405
+ toolCall,
406
+ tools,
407
+ inputSchema,
408
+ error,
409
+ }) => {
410
+ // Handle both string and SystemModelMessage
411
+ const systemText = typeof system === 'string' ? system : system?.content;
412
+ // ...
413
+ };
414
+ ```
415
+
416
+ ### Embedding Model Method Rename
417
+
418
+ The `textEmbeddingModel` and `textEmbedding` methods on providers have been renamed to `embeddingModel` and `embedding` respectively. Additionally, generics have been removed from `EmbeddingModel`, `embed`, and `embedMany` ([PR #10592](https://github.com/vercel/ai/pull/10592)).
419
+
420
+ ```tsx filename="AI SDK 5"
421
+ import { openai } from '@ai-sdk/openai';
422
+ import { embed } from 'ai';
423
+
424
+ // Using the full method name
425
+ const model = openai.textEmbeddingModel('text-embedding-3-small');
426
+
427
+ // Using the shorthand
428
+ const model = openai.textEmbedding('text-embedding-3-small');
429
+
430
+ const { embedding } = await embed({
431
+ model: openai.textEmbedding('text-embedding-3-small'),
432
+ value: 'sunny day at the beach',
433
+ });
434
+ ```
435
+
436
+ ```tsx filename="AI SDK 6"
437
+ import { openai } from '@ai-sdk/openai';
438
+ import { embed } from 'ai';
439
+
440
+ // Using the full method name
441
+ const model = openai.embeddingModel('text-embedding-3-small');
442
+
443
+ // Using the shorthand
444
+ const model = openai.embedding('text-embedding-3-small');
445
+
446
+ const { embedding } = await embed({
447
+ model: openai.embedding('text-embedding-3-small'),
448
+ value: 'sunny day at the beach',
449
+ });
450
+ ```
451
+
452
+ <Note>
453
+ Use the `rename-text-embedding-to-embedding` codemod to automatically update
454
+ your codebase.
455
+ </Note>
456
+
457
+ ### Warning Logger
458
+
459
+ AI SDK 6 introduces a warning logger that outputs deprecation warnings and best practice recommendations ([PR #8343](https://github.com/vercel/ai/pull/8343)).
460
+
461
+ To disable warning logging, set the `AI_SDK_LOG_WARNINGS` environment variable to `false`:
462
+
463
+ ```bash
464
+ export AI_SDK_LOG_WARNINGS=false
465
+ ```
466
+
467
+ ### Warning Type Unification
468
+
469
+ Separate warning types for each generation function have been consolidated into a single `Warning` type exported from the `ai` package ([PR #10631](https://github.com/vercel/ai/pull/10631)).
470
+
471
+ ```tsx filename="AI SDK 5"
472
+ // Separate warning types for each generation function
473
+ import type {
474
+ CallWarning,
475
+ ImageModelCallWarning,
476
+ SpeechWarning,
477
+ TranscriptionWarning,
478
+ } from 'ai';
479
+ ```
480
+
481
+ ```tsx filename="AI SDK 6"
482
+ // Single Warning type for all generation functions
483
+ import type { Warning } from 'ai';
484
+ ```
485
+
486
+ ### Finish reason "unknown" merged into "other"
487
+
488
+ The `unknown` finish reason has been removed. It is now returned as `other`.
489
+
490
+ ## AI SDK UI
491
+
492
+ ### Tool UI Part Helper Functions Rename
493
+
494
+ The tool UI part helper functions have been renamed to better reflect their purpose and to accommodate both static and dynamic tool parts ([PR #XXXX](https://github.com/vercel/ai/pull/XXXX)).
495
+
496
+ #### `isToolUIPart` → `isStaticToolUIPart`
497
+
498
+ The `isToolUIPart` function has been renamed to `isStaticToolUIPart` to clarify that it checks for static tool parts only.
499
+
500
+ ```tsx filename="AI SDK 5"
501
+ import { isToolUIPart } from 'ai';
502
+
503
+ // Check if a part is a tool UI part
504
+ if (isToolUIPart(part)) {
505
+ console.log(part.toolName);
506
+ }
507
+ ```
508
+
509
+ ```tsx filename="AI SDK 6"
510
+ import { isStaticToolUIPart } from 'ai';
511
+
512
+ // Check if a part is a static tool UI part
513
+ if (isStaticToolUIPart(part)) {
514
+ console.log(part.toolName);
515
+ }
516
+ ```
517
+
518
+ #### `isToolOrDynamicToolUIPart` → `isToolUIPart`
519
+
520
+ The `isToolOrDynamicToolUIPart` function has been renamed to `isToolUIPart`. The old name is deprecated but still available.
521
+
522
+ ```tsx filename="AI SDK 5"
523
+ import { isToolOrDynamicToolUIPart } from 'ai';
524
+
525
+ // Check if a part is either a static or dynamic tool UI part
526
+ if (isToolOrDynamicToolUIPart(part)) {
527
+ console.log('Tool part found');
528
+ }
529
+ ```
530
+
531
+ ```tsx filename="AI SDK 6"
532
+ import { isToolUIPart } from 'ai';
533
+
534
+ // Check if a part is either a static or dynamic tool UI part
535
+ if (isToolUIPart(part)) {
536
+ console.log('Tool part found');
537
+ }
538
+ ```
539
+
540
+ #### `getToolName` → `getStaticToolName`
541
+
542
+ The `getToolName` function has been renamed to `getStaticToolName` to clarify that it returns the tool name from static tool parts only.
543
+
544
+ ```tsx filename="AI SDK 5"
545
+ import { getToolName } from 'ai';
546
+
547
+ // Get the tool name from a tool part
548
+ const name = getToolName(toolPart);
549
+ ```
550
+
551
+ ```tsx filename="AI SDK 6"
552
+ import { getStaticToolName } from 'ai';
553
+
554
+ // Get the tool name from a static tool part
555
+ const name = getStaticToolName(toolPart);
556
+ ```
557
+
558
+ #### `getToolOrDynamicToolName` → `getToolName`
559
+
560
+ The `getToolOrDynamicToolName` function has been renamed to `getToolName`. The old name is deprecated but still available.
561
+
562
+ ```tsx filename="AI SDK 5"
563
+ import { getToolOrDynamicToolName } from 'ai';
564
+
565
+ // Get the tool name from either a static or dynamic tool part
566
+ const name = getToolOrDynamicToolName(toolPart);
567
+ ```
568
+
569
+ ```tsx filename="AI SDK 6"
570
+ import { getToolName } from 'ai';
571
+
572
+ // Get the tool name from either a static or dynamic tool part
573
+ const name = getToolName(toolPart);
574
+ ```
575
+
576
+ ## Providers
577
+
578
+ ### OpenAI
579
+
580
+ #### `strictJsonSchema` Defaults to True
581
+
582
+ The `strictJsonSchema` setting for JSON outputs and tool calls is enabled by default ([PR #10752](https://github.com/vercel/ai/pull/10752)). This improves stability and ensures valid JSON output that matches your schema.
583
+
584
+ However, strict mode is stricter about schema requirements. If you receive schema rejection errors, adjust your schema (for example, use `null` instead of `undefined`) or disable strict mode.
585
+
586
+ ```tsx filename="AI SDK 5"
587
+ import { openai } from '@ai-sdk/openai';
588
+ import { generateObject } from 'ai';
589
+ import { z } from 'zod';
590
+
591
+ // strictJsonSchema was false by default
592
+ const result = await generateObject({
593
+ model: openai('gpt-5.1'),
594
+ schema: z.object({
595
+ name: z.string(),
596
+ }),
597
+ prompt: 'Generate a person',
598
+ });
599
+ ```
600
+
601
+ ```tsx filename="AI SDK 6"
602
+ import { openai } from '@ai-sdk/openai';
603
+ import { generateObject } from 'ai';
604
+ import { z } from 'zod';
605
+
606
+ // strictJsonSchema is true by default
607
+ const result = await generateObject({
608
+ model: openai('gpt-5.1'),
609
+ schema: z.object({
610
+ name: z.string(),
611
+ }),
612
+ prompt: 'Generate a person',
613
+ });
614
+
615
+ // Disable strict mode if needed
616
+ const resultNoStrict = await generateObject({
617
+ model: openai('gpt-5.1'),
618
+ schema: z.object({
619
+ name: z.string(),
620
+ }),
621
+ prompt: 'Generate a person',
622
+ providerOptions: {
623
+ openai: {
624
+ strictJsonSchema: false,
625
+ } satisfies OpenAIResponsesProviderOptions,
626
+ },
627
+ });
628
+ ```
629
+
630
+ #### `structuredOutputs` Option Removed from Chat Model
631
+
632
+ The `structuredOutputs` provider option has been removed from chat models ([PR #10752](https://github.com/vercel/ai/pull/10752)). Use `strictJsonSchema` instead.
633
+
634
+ ### Azure
635
+
636
+ #### Default Provider Uses Responses API
637
+
638
+ The `@ai-sdk/azure` provider now uses the Responses API by default when calling `azure()` ([PR #9868](https://github.com/vercel/ai/pull/9868)). To use the previous Chat Completions API behavior, use `azure.chat()` instead.
639
+
640
+ ```tsx filename="AI SDK 5"
641
+ import { azure } from '@ai-sdk/azure';
642
+
643
+ // Used Chat Completions API
644
+ const model = azure('gpt-4o');
645
+ ```
646
+
647
+ ```tsx filename="AI SDK 6"
648
+ import { azure } from '@ai-sdk/azure';
649
+
650
+ // Now uses Responses API by default
651
+ const model = azure('gpt-4o');
652
+
653
+ // Use azure.chat() for Chat Completions API
654
+ const chatModel = azure.chat('gpt-4o');
655
+
656
+ // Use azure.responses() explicitly for Responses API
657
+ const responsesModel = azure.responses('gpt-4o');
658
+ ```
659
+
660
+ <Note>
661
+ The Responses and Chat Completions APIs have different behavior and defaults.
662
+ If you depend on the Chat Completions API, switch your model instance to
663
+ `azure.chat()` and audit your configuration.
664
+ </Note>
665
+
666
+ #### Responses API `providerMetadata` and `providerOptions` Key
667
+
668
+ For the **Responses API**, the `@ai-sdk/azure` provider now uses `azure` as the key for `providerMetadata` and `providerOptions` instead of `openai`. The `openai` key is still supported for `providerOptions` input, but resulting `providerMetadata` output now uses `azure`.
669
+
670
+ ```tsx filename="AI SDK 5"
671
+ import { azure } from '@ai-sdk/azure';
672
+ import { generateText } from 'ai';
673
+
674
+ const result = await generateText({
675
+ model: azure.responses('gpt-5-mini'), // use your own deployment
676
+ prompt: 'Hello',
677
+ providerOptions: {
678
+ openai: {
679
+ // AI SDK 5: use `openai` key for Responses API options
680
+ reasoningSummary: 'auto',
681
+ },
682
+ },
683
+ });
684
+
685
+ // Accessed metadata via 'openai' key
686
+ console.log(result.providerMetadata?.openai?.responseId);
687
+ ```
688
+
689
+ ```tsx filename="AI SDK 6"
690
+ import { azure } from '@ai-sdk/azure';
691
+ import { generateText } from 'ai';
692
+
693
+ const result = await generateText({
694
+ // azure() now uses the Responses API by default
695
+ model: azure('gpt-5-mini'), // use your own deployment
696
+ prompt: 'Hello',
697
+ providerOptions: {
698
+ azure: {
699
+ // AI SDK 6: use `azure` key for Responses API options
700
+ reasoningSummary: 'auto',
701
+ },
702
+ },
703
+ });
704
+
705
+ // Access metadata via 'azure' key
706
+ console.log(result.providerMetadata?.azure?.responseId);
707
+ ```
708
+
709
+ ### Anthropic
710
+
711
+ #### Structured Outputs Mode
712
+
713
+ Anthropic has [ introduced native structured outputs for Claude Sonnet 4.5 and later models ](https://www.claude.com/blog/structured-outputs-on-the-claude-developer-platform). The `@ai-sdk/anthropic` provider now includes a `structuredOutputMode` option to control how structured outputs are generated ([PR #10502](https://github.com/vercel/ai/pull/10502)).
714
+
715
+ The available modes are:
716
+
717
+ - `'outputFormat'`: Use Anthropic's native `output_format` parameter
718
+ - `'jsonTool'`: Use a special JSON tool to specify the structured output format
719
+ - `'auto'` (default): Use `'outputFormat'` when supported by the model, otherwise fall back to `'jsonTool'`
720
+
721
+ ```tsx filename="AI SDK 6"
722
+ import { anthropic } from '@ai-sdk/anthropic';
723
+ import { generateObject } from 'ai';
724
+ import { z } from 'zod';
725
+
726
+ const result = await generateObject({
727
+ model: anthropic('claude-sonnet-4-5-20250929'),
728
+ schema: z.object({
729
+ name: z.string(),
730
+ age: z.number(),
731
+ }),
732
+ prompt: 'Generate a person',
733
+ providerOptions: {
734
+ anthropic: {
735
+ // Explicitly set the structured output mode (optional)
736
+ structuredOutputMode: 'outputFormat',
737
+ } satisfies AnthropicProviderOptions,
738
+ },
739
+ });
740
+ ```
741
+
742
+ ### Google Vertex
743
+
744
+ #### `providerMetadata` and `providerOptions` Key
745
+
746
+ The `@ai-sdk/google-vertex` provider now uses `vertex` as the key for `providerMetadata` and `providerOptions` instead of `google`. The `google` key is still supported for `providerOptions` input, but resulting `providerMetadata` output now uses `vertex`.
747
+
748
+ ```tsx filename="AI SDK 5"
749
+ import { vertex } from '@ai-sdk/google-vertex';
750
+ import { generateText } from 'ai';
751
+
752
+ const result = await generateText({
753
+ model: vertex('gemini-2.5-flash'),
754
+ providerOptions: {
755
+ google: {
756
+ safetySettings: [
757
+ /* ... */
758
+ ],
759
+ }, // Used 'google' key
760
+ },
761
+ prompt: 'Hello',
762
+ });
763
+
764
+ // Accessed metadata via 'google' key
765
+ console.log(result.providerMetadata?.google?.safetyRatings);
766
+ ```
767
+
768
+ ```tsx filename="AI SDK 6"
769
+ import { vertex } from '@ai-sdk/google-vertex';
770
+ import { generateText } from 'ai';
771
+
772
+ const result = await generateText({
773
+ model: vertex('gemini-2.5-flash'),
774
+ providerOptions: {
775
+ vertex: {
776
+ safetySettings: [
777
+ /* ... */
778
+ ],
779
+ }, // Now uses 'vertex' key
780
+ },
781
+ prompt: 'Hello',
782
+ });
783
+
784
+ // Access metadata via 'vertex' key
785
+ console.log(result.providerMetadata?.vertex?.safetyRatings);
786
+ ```
787
+
788
+ <Note>
789
+ Use the `rename-vertex-provider-metadata-key` codemod to automatically update
790
+ your codebase.
791
+ </Note>
792
+
793
+ ## `ai/test`
794
+
795
+ ### Mock Classes
796
+
797
+ V2 mock classes have been removed from the `ai/test` module. Use the new V3 mock classes instead for testing.
798
+
799
+ ```tsx filename="AI SDK 5"
800
+ import {
801
+ MockEmbeddingModelV2,
802
+ MockImageModelV2,
803
+ MockLanguageModelV2,
804
+ MockProviderV2,
805
+ MockSpeechModelV2,
806
+ MockTranscriptionModelV2,
807
+ } from 'ai/test';
808
+ ```
809
+
810
+ ```tsx filename="AI SDK 6"
811
+ import {
812
+ MockEmbeddingModelV3,
813
+ MockImageModelV3,
814
+ MockLanguageModelV3,
815
+ MockProviderV3,
816
+ MockSpeechModelV3,
817
+ MockTranscriptionModelV3,
818
+ } from 'ai/test';
819
+ ```
820
+
821
+ <Note>
822
+ Use the `rename-mock-v2-to-v3` codemod to automatically update your codebase.
823
+ </Note>