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,262 @@
1
+ ---
2
+ title: render (Removed)
3
+ description: Reference for the render function from the AI SDK RSC
4
+ ---
5
+
6
+ # `render` (Removed)
7
+
8
+ <Note type="warning">"render" has been removed in AI SDK 4.0.</Note>
9
+
10
+ <Note type="warning">
11
+ AI SDK RSC is currently experimental. We recommend using [AI SDK
12
+ UI](/docs/ai-sdk-ui/overview) for production. For guidance on migrating from
13
+ RSC to UI, see our [migration guide](/docs/ai-sdk-rsc/migrating-to-ui).
14
+ </Note>
15
+
16
+ A helper function to create a streamable UI from LLM providers. This function is similar to AI SDK Core APIs and supports the same model interfaces.
17
+
18
+ > **Note**: `render` has been deprecated in favor of [`streamUI`](/docs/reference/ai-sdk-rsc/stream-ui). During migration, please ensure that the `messages` parameter follows the updated [specification](/docs/reference/ai-sdk-rsc/stream-ui#messages).
19
+
20
+ ## Import
21
+
22
+ <Snippet text={`import { render } from "@ai-sdk/rsc"`} prompt={false} />
23
+
24
+ ## API Signature
25
+
26
+ ### Parameters
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: 'model',
32
+ type: 'string',
33
+ description: 'Model identifier, must be OpenAI SDK compatible.',
34
+ },
35
+ {
36
+ name: 'provider',
37
+ type: 'provider client',
38
+ description:
39
+ 'Currently the only provider available is OpenAI. This needs to match the model name.',
40
+ },
41
+ {
42
+ name: 'initial',
43
+ isOptional: true,
44
+ type: 'ReactNode',
45
+ description: 'The initial UI to render.',
46
+ },
47
+ {
48
+ name: 'messages',
49
+ type: 'Array<SystemMessage | UserMessage | AssistantMessage | ToolMessage>',
50
+ description: 'A list of messages that represent a conversation.',
51
+ properties: [
52
+ {
53
+ type: 'SystemMessage',
54
+ parameters: [
55
+ {
56
+ name: 'role',
57
+ type: "'system'",
58
+ description: 'The role for the system message.',
59
+ },
60
+ {
61
+ name: 'content',
62
+ type: 'string',
63
+ description: 'The content of the message.',
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ type: 'UserMessage',
69
+ parameters: [
70
+ {
71
+ name: 'role',
72
+ type: "'user'",
73
+ description: 'The role for the user message.',
74
+ },
75
+ {
76
+ name: 'content',
77
+ type: 'string',
78
+ description: 'The content of the message.',
79
+ },
80
+ ],
81
+ },
82
+ {
83
+ type: 'AssistantMessage',
84
+ parameters: [
85
+ {
86
+ name: 'role',
87
+ type: "'assistant'",
88
+ description: 'The role for the assistant message.',
89
+ },
90
+ {
91
+ name: 'content',
92
+ type: 'string',
93
+ description: 'The content of the message.',
94
+ },
95
+ {
96
+ name: 'tool_calls',
97
+ type: 'ToolCall[]',
98
+ description: 'A list of tool calls made by the model.',
99
+ properties: [
100
+ {
101
+ type: 'ToolCall',
102
+ parameters: [
103
+ {
104
+ name: 'id',
105
+ type: 'string',
106
+ description: 'The id of the tool call.',
107
+ },
108
+ {
109
+ name: 'type',
110
+ type: "'function'",
111
+ description: 'The type of the tool call.',
112
+ },
113
+ {
114
+ name: 'function',
115
+ type: 'Function',
116
+ description: 'The function to call.',
117
+ properties: [
118
+ {
119
+ type: 'Function',
120
+ parameters: [
121
+ {
122
+ name: 'name',
123
+ type: 'string',
124
+ description: 'The name of the function.',
125
+ },
126
+ {
127
+ name: 'arguments',
128
+ type: 'string',
129
+ description: 'The arguments of the function.',
130
+ },
131
+ ],
132
+ },
133
+ ],
134
+ },
135
+ ],
136
+ },
137
+ ],
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ type: 'ToolMessage',
143
+ parameters: [
144
+ {
145
+ name: 'role',
146
+ type: "'tool'",
147
+ description: 'The role for the tool message.',
148
+ },
149
+ {
150
+ name: 'content',
151
+ type: 'string',
152
+ description: 'The content of the message.',
153
+ },
154
+ {
155
+ name: 'toolCallId',
156
+ type: 'string',
157
+ description: 'The id of the tool call.',
158
+ },
159
+ ],
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ name: 'functions',
165
+ type: 'ToolSet',
166
+ isOptional: true,
167
+ description:
168
+ 'Tools that are accessible to and can be called by the model.',
169
+ properties: [
170
+ {
171
+ type: 'Tool',
172
+ parameters: [
173
+ {
174
+ name: 'description',
175
+ isOptional: true,
176
+ type: 'string',
177
+ description:
178
+ 'Information about the purpose of the tool including details on how and when it can be used by the model.',
179
+ },
180
+ {
181
+ name: 'parameters',
182
+ type: 'zod schema',
183
+ description:
184
+ 'The typed schema that describes the parameters of the tool that can also be used to validation and error handling.',
185
+ },
186
+ {
187
+ name: 'render',
188
+ isOptional: true,
189
+ type: 'async (parameters) => any',
190
+ description:
191
+ 'An async function that is called with the arguments from the tool call and produces a result.',
192
+ },
193
+ ],
194
+ },
195
+ ],
196
+ },
197
+ {
198
+ name: 'tools',
199
+ type: 'ToolSet',
200
+ isOptional: true,
201
+ description:
202
+ 'Tools that are accessible to and can be called by the model.',
203
+ properties: [
204
+ {
205
+ type: 'Tool',
206
+ parameters: [
207
+ {
208
+ name: 'description',
209
+ isOptional: true,
210
+ type: 'string',
211
+ description:
212
+ 'Information about the purpose of the tool including details on how and when it can be used by the model.',
213
+ },
214
+ {
215
+ name: 'parameters',
216
+ type: 'zod schema',
217
+ description:
218
+ 'The typed schema that describes the parameters of the tool that can also be used to validation and error handling.',
219
+ },
220
+ {
221
+ name: 'render',
222
+ isOptional: true,
223
+ type: 'async (parameters) => any',
224
+ description:
225
+ 'An async function that is called with the arguments from the tool call and produces a result.',
226
+ },
227
+ ],
228
+ },
229
+ ],
230
+ },
231
+ {
232
+ name: 'text',
233
+ isOptional: true,
234
+ type: '(Text) => ReactNode',
235
+ description: 'Callback to handle the generated tokens from the model.',
236
+ properties: [
237
+ {
238
+ type: 'Text',
239
+ parameters: [
240
+ {
241
+ name: 'content',
242
+ type: 'string',
243
+ description: 'The full content of the completion.',
244
+ },
245
+ { name: 'delta', type: 'string', description: 'The delta.' },
246
+ { name: 'done', type: 'boolean', description: 'Is it done?' },
247
+ ],
248
+ },
249
+ ],
250
+ },
251
+ {
252
+ name: 'temperature',
253
+ isOptional: true,
254
+ type: 'number',
255
+ description: 'The temperature to use for the model.',
256
+ },
257
+ ]}
258
+ />
259
+
260
+ ### Returns
261
+
262
+ It can return any valid ReactNode.
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: AI SDK RSC
3
+ description: Reference documentation for the AI SDK UI
4
+ collapsed: true
5
+ ---
6
+
7
+ # AI SDK RSC
8
+
9
+ <Note type="warning">
10
+ AI SDK RSC is currently experimental. We recommend using [AI SDK
11
+ UI](/docs/ai-sdk-ui/overview) for production. For guidance on migrating from
12
+ RSC to UI, see our [migration guide](/docs/ai-sdk-rsc/migrating-to-ui).
13
+ </Note>
14
+
15
+ <IndexCards
16
+ cards={[
17
+ {
18
+ title: 'streamUI',
19
+ description:
20
+ 'Use a helper function that streams React Server Components on tool execution.',
21
+ href: '/docs/reference/ai-sdk-rsc/stream-ui',
22
+ },
23
+ {
24
+ title: 'createAI',
25
+ description:
26
+ 'Create a context provider that wraps your application and shares state between the client and language model on the server.',
27
+ href: '/docs/reference/ai-sdk-rsc/create-ai',
28
+ },
29
+ {
30
+ title: 'createStreamableUI',
31
+ description:
32
+ 'Create a streamable UI component that can be rendered on the server and streamed to the client.',
33
+ href: '/docs/reference/ai-sdk-rsc/create-streamable-ui',
34
+ },
35
+ {
36
+ title: 'createStreamableValue',
37
+ description:
38
+ 'Create a streamable value that can be rendered on the server and streamed to the client.',
39
+ href: '/docs/reference/ai-sdk-rsc/create-streamable-value',
40
+ },
41
+ {
42
+ title: 'getAIState',
43
+ description: 'Read the AI state on the server.',
44
+ href: '/docs/reference/ai-sdk-rsc/get-ai-state',
45
+ },
46
+ {
47
+ title: 'getMutableAIState',
48
+ description: 'Read and update the AI state on the server.',
49
+ href: '/docs/reference/ai-sdk-rsc/get-mutable-ai-state',
50
+ },
51
+ {
52
+ title: 'useAIState',
53
+ description: 'Get the AI state on the client from the context provider.',
54
+ href: '/docs/reference/ai-sdk-rsc/use-ai-state',
55
+ },
56
+ {
57
+ title: 'useUIState',
58
+ description: 'Get the UI state on the client from the context provider.',
59
+ href: '/docs/reference/ai-sdk-rsc/use-ui-state',
60
+ },
61
+ {
62
+ title: 'useActions',
63
+ description: 'Call server actions from the client.',
64
+ href: '/docs/reference/ai-sdk-rsc/use-actions',
65
+ },
66
+ ]}
67
+ />
@@ -0,0 +1,89 @@
1
+ ---
2
+ title: AIStream
3
+ description: Learn to use AIStream helper function in your application.
4
+ ---
5
+
6
+ # `AIStream`
7
+
8
+ <Note type="warning">
9
+ AIStream has been removed in AI SDK 4.0. Use
10
+ `streamText.toDataStreamResponse()` instead.
11
+ </Note>
12
+
13
+ Creates a readable stream for AI responses. This is based on the responses returned
14
+ by fetch and serves as the basis for the OpenAIStream and AnthropicStream. It allows
15
+ you to handle AI response streams in a controlled and customized manner that will
16
+ work with useChat and useCompletion.
17
+
18
+ AIStream will throw an error if response doesn't have a 2xx status code. This is to ensure that the stream is only created for successful responses.
19
+
20
+ ## Import
21
+
22
+ ### React
23
+
24
+ <Snippet text={`import { AIStream } from "ai"`} prompt={false} />
25
+
26
+ ## API Signature
27
+
28
+ <PropertiesTable
29
+ content={[
30
+ {
31
+ name: 'response',
32
+ type: 'Response',
33
+ description:
34
+ "This is the response object returned by fetch. It's used as the source of the readable stream.",
35
+ },
36
+ {
37
+ name: 'customParser',
38
+ type: '(AIStreamParser) => void',
39
+ description:
40
+ 'This is a function that is used to parse the events in the stream. It should return a function that receives a stringified chunk from the LLM and extracts the message content. The function is expected to return nothing (void) or a string.',
41
+ properties: [
42
+ {
43
+ type: 'AIStreamParser',
44
+ parameters: [
45
+ {
46
+ name: '',
47
+ type: '(data: string) => string | void',
48
+ },
49
+ ],
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ name: 'callbacks',
55
+ type: 'AIStreamCallbacksAndOptions',
56
+ properties: [
57
+ {
58
+ type: 'AIStreamCallbacksAndOptions',
59
+ parameters: [
60
+ {
61
+ name: 'onStart',
62
+ type: '() => Promise<void>',
63
+ description:
64
+ 'An optional function that is called at the start of the stream processing.',
65
+ },
66
+ {
67
+ name: 'onCompletion',
68
+ type: '(completion: string) => Promise<void>',
69
+ description:
70
+ "An optional function that is called for every completion. It's passed the completion as a string.",
71
+ },
72
+ {
73
+ name: 'onFinal',
74
+ type: '(completion: string) => Promise<void>',
75
+ description:
76
+ 'An optional function that is called once when the stream is closed with the final completion message.',
77
+ },
78
+ {
79
+ name: 'onToken',
80
+ type: '(token: string) => Promise<void>',
81
+ description:
82
+ "An optional function that is called for each token in the stream. It's passed the token as a string.",
83
+ },
84
+ ],
85
+ },
86
+ ],
87
+ },
88
+ ]}
89
+ />
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: StreamingTextResponse
3
+ description: Learn to use StreamingTextResponse helper function in your application.
4
+ ---
5
+
6
+ # `StreamingTextResponse`
7
+
8
+ <Note type="warning">
9
+ `StreamingTextResponse` has been removed in AI SDK 4.0. Use
10
+ [`streamText.toDataStreamResponse()`](/docs/reference/ai-sdk-core/stream-text)
11
+ instead.
12
+ </Note>
13
+
14
+ It is a utility class that simplifies the process of returning a ReadableStream of text in HTTP responses.
15
+ It is a lightweight wrapper around the native Response class, automatically setting the status code to 200 and the Content-Type header to 'text/plain; charset=utf-8'.
16
+
17
+ ## Import
18
+
19
+ <Snippet text={`import { StreamingTextResponse } from "ai"`} prompt={false} />
20
+
21
+ ## API Signature
22
+
23
+ ## Parameters
24
+
25
+ <PropertiesTable
26
+ content={[
27
+ {
28
+ name: 'stream',
29
+ type: 'ReadableStream',
30
+ description: 'The stream of content which represents the HTTP response.',
31
+ },
32
+ {
33
+ name: 'init',
34
+ isOptional: true,
35
+ type: 'ResponseInit',
36
+ description:
37
+ 'It can be used to customize the properties of the HTTP response. It is an object that corresponds to the ResponseInit object used in the Response constructor.',
38
+ properties: [
39
+ {
40
+ type: 'ResponseInit',
41
+ parameters: [
42
+ {
43
+ name: 'status',
44
+ type: 'number',
45
+ isOptional: true,
46
+ description:
47
+ 'The status code for the response. StreamingTextResponse will overwrite this value with 200.',
48
+ },
49
+ {
50
+ name: 'statusText',
51
+ type: 'string',
52
+ isOptional: true,
53
+ description:
54
+ 'The status message associated with the status code.',
55
+ },
56
+ {
57
+ name: 'headers',
58
+ type: 'HeadersInit',
59
+ isOptional: true,
60
+ description:
61
+ "Any headers you want to add to your response. StreamingTextResponse will add 'Content-Type': 'text/plain; charset=utf-8' to these headers.",
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ name: 'data',
69
+ isOptional: true,
70
+ type: 'StreamData',
71
+ description:
72
+ 'StreamData object that you are using to generate additional data for the response.',
73
+ },
74
+ ]}
75
+ />
76
+
77
+ ### Returns
78
+
79
+ An instance of Response with the provided ReadableStream as the body, the status set to 200, and the Content-Type header set to 'text/plain; charset=utf-8'. Additional headers and properties can be added using the init parameter
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: streamToResponse
3
+ description: Learn to use streamToResponse helper function in your application.
4
+ ---
5
+
6
+ # `streamToResponse`
7
+
8
+ <Note type="warning">
9
+ `streamToResponse` has been removed in AI SDK 4.0. Use
10
+ `pipeDataStreamToResponse` from
11
+ [streamText](/docs/reference/ai-sdk-core/stream-text) instead.
12
+ </Note>
13
+
14
+ `streamToResponse` pipes a data stream to a Node.js `ServerResponse` object and sets the status code and headers.
15
+
16
+ This is useful to create data stream responses in environments that use `ServerResponse` objects, such as Node.js HTTP servers.
17
+
18
+ The status code and headers can be configured using the `options` parameter.
19
+ By default, the status code is set to 200 and the Content-Type header is set to `text/plain; charset=utf-8`.
20
+
21
+ ## Import
22
+
23
+ <Snippet text={`import { streamToResponse } from "ai"`} prompt={false} />
24
+
25
+ ## Example
26
+
27
+ You can e.g. use `streamToResponse` to pipe a data stream to a Node.js HTTP server response:
28
+
29
+ ```ts
30
+ import { StreamData, streamText, streamToResponse } from 'ai';
31
+ __PROVIDER_IMPORT__;
32
+ import { createServer } from 'http';
33
+
34
+ createServer(async (req, res) => {
35
+ const result = streamText({
36
+ model: __MODEL__,
37
+ prompt: 'What is the weather in San Francisco?',
38
+ });
39
+
40
+ // use stream data
41
+ const data = new StreamData();
42
+
43
+ data.append('initialized call');
44
+
45
+ streamToResponse(
46
+ result.toAIStream({
47
+ onFinal() {
48
+ data.append('call completed');
49
+ data.close();
50
+ },
51
+ }),
52
+ res,
53
+ {},
54
+ data,
55
+ );
56
+ }).listen(8080);
57
+ ```
58
+
59
+ ## API Signature
60
+
61
+ ### Parameters
62
+
63
+ <PropertiesTable
64
+ content={[
65
+ {
66
+ name: 'stream',
67
+ type: 'ReadableStream',
68
+ description:
69
+ 'The Web Stream to pipe to the response. It can be the return value of OpenAIStream, HuggingFaceStream, AnthropicStream, or an AIStream instance.',
70
+ },
71
+ {
72
+ name: 'response',
73
+ type: 'ServerResponse',
74
+ description:
75
+ 'The Node.js ServerResponse object to pipe the stream to. This is usually the second argument of a Node.js HTTP request handler.',
76
+ },
77
+ {
78
+ name: 'options',
79
+ type: 'Options',
80
+ description: 'Configure the response',
81
+ properties: [
82
+ {
83
+ type: 'Options',
84
+ parameters: [
85
+ {
86
+ name: 'status',
87
+ type: 'number',
88
+ description:
89
+ 'The status code to set on the response. Defaults to `200`.',
90
+ },
91
+ {
92
+ name: 'headers',
93
+ type: 'Record<string, string>',
94
+ description:
95
+ "Additional headers to set on the response. Defaults to `{ 'Content-Type': 'text/plain; charset=utf-8' }`.",
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ name: 'data',
103
+ type: 'StreamData',
104
+ description:
105
+ 'StreamData object for forwarding additional data to the client.',
106
+ },
107
+ ]}
108
+ />
@@ -0,0 +1,77 @@
1
+ ---
2
+ title: OpenAIStream
3
+ description: Learn to use OpenAIStream helper function in your application.
4
+ ---
5
+
6
+ # `OpenAIStream`
7
+
8
+ <Note type="warning">OpenAIStream has been removed in AI SDK 4.0</Note>
9
+
10
+ <Note type="warning">
11
+ OpenAIStream is part of the legacy OpenAI integration. It is not compatible
12
+ with the AI SDK 3.1 functions. It is recommended to use the [AI SDK OpenAI
13
+ Provider](/providers/ai-sdk-providers/openai) instead.
14
+ </Note>
15
+
16
+ Transforms the response from OpenAI's language models into a ReadableStream.
17
+
18
+ Note: Prior to v4, the official OpenAI API SDK does not support the Edge Runtime and only works in serverless environments. The openai-edge package is based on fetch instead of axios (and thus works in the Edge Runtime) so we recommend using openai v4+ or openai-edge.
19
+
20
+ ## Import
21
+
22
+ ### React
23
+
24
+ <Snippet text={`import { OpenAIStream } from "ai"`} prompt={false} />
25
+
26
+ ## API Signature
27
+
28
+ ### Parameters
29
+
30
+ <PropertiesTable
31
+ content={[
32
+ {
33
+ name: 'response',
34
+ type: 'Response',
35
+ description:
36
+ 'The response object returned by a call made by the Provider SDK.',
37
+ },
38
+ {
39
+ name: 'callbacks',
40
+ type: 'AIStreamCallbacksAndOptions',
41
+ isOptional: true,
42
+ description:
43
+ 'An object containing callback functions to handle the start, each token, and completion of the AI response. In the absence of this parameter, default behavior is implemented.',
44
+ properties: [
45
+ {
46
+ type: 'AIStreamCallbacksAndOptions',
47
+ parameters: [
48
+ {
49
+ name: 'onStart',
50
+ type: '() => Promise<void>',
51
+ description:
52
+ 'An optional function that is called at the start of the stream processing.',
53
+ },
54
+ {
55
+ name: 'onCompletion',
56
+ type: '(completion: string) => Promise<void>',
57
+ description:
58
+ "An optional function that is called for every completion. It's passed the completion as a string.",
59
+ },
60
+ {
61
+ name: 'onFinal',
62
+ type: '(completion: string) => Promise<void>',
63
+ description:
64
+ 'An optional function that is called once when the stream is closed with the final completion message.',
65
+ },
66
+ {
67
+ name: 'onToken',
68
+ type: '(token: string) => Promise<void>',
69
+ description:
70
+ "An optional function that is called for each token in the stream. It's passed the token as a string.",
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ },
76
+ ]}
77
+ />