ai 6.0.31 → 6.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/00-introduction/index.mdx +76 -0
- package/docs/02-foundations/01-overview.mdx +43 -0
- package/docs/02-foundations/02-providers-and-models.mdx +163 -0
- package/docs/02-foundations/03-prompts.mdx +620 -0
- package/docs/02-foundations/04-tools.mdx +160 -0
- package/docs/02-foundations/05-streaming.mdx +62 -0
- package/docs/02-foundations/index.mdx +43 -0
- package/docs/02-getting-started/00-choosing-a-provider.mdx +110 -0
- package/docs/02-getting-started/01-navigating-the-library.mdx +85 -0
- package/docs/02-getting-started/02-nextjs-app-router.mdx +556 -0
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +542 -0
- package/docs/02-getting-started/04-svelte.mdx +627 -0
- package/docs/02-getting-started/05-nuxt.mdx +566 -0
- package/docs/02-getting-started/06-nodejs.mdx +512 -0
- package/docs/02-getting-started/07-expo.mdx +766 -0
- package/docs/02-getting-started/08-tanstack-start.mdx +583 -0
- package/docs/02-getting-started/index.mdx +44 -0
- package/docs/03-agents/01-overview.mdx +96 -0
- package/docs/03-agents/02-building-agents.mdx +367 -0
- package/docs/03-agents/03-workflows.mdx +370 -0
- package/docs/03-agents/04-loop-control.mdx +350 -0
- package/docs/03-agents/05-configuring-call-options.mdx +286 -0
- package/docs/03-agents/index.mdx +40 -0
- package/docs/03-ai-sdk-core/01-overview.mdx +33 -0
- package/docs/03-ai-sdk-core/05-generating-text.mdx +600 -0
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +662 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +1102 -0
- package/docs/03-ai-sdk-core/16-mcp-tools.mdx +375 -0
- package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +144 -0
- package/docs/03-ai-sdk-core/25-settings.mdx +198 -0
- package/docs/03-ai-sdk-core/30-embeddings.mdx +247 -0
- package/docs/03-ai-sdk-core/31-reranking.mdx +218 -0
- package/docs/03-ai-sdk-core/35-image-generation.mdx +341 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +173 -0
- package/docs/03-ai-sdk-core/37-speech.mdx +167 -0
- package/docs/03-ai-sdk-core/40-middleware.mdx +480 -0
- package/docs/03-ai-sdk-core/45-provider-management.mdx +349 -0
- package/docs/03-ai-sdk-core/50-error-handling.mdx +149 -0
- package/docs/03-ai-sdk-core/55-testing.mdx +218 -0
- package/docs/03-ai-sdk-core/60-telemetry.mdx +313 -0
- package/docs/03-ai-sdk-core/65-devtools.mdx +107 -0
- package/docs/03-ai-sdk-core/index.mdx +88 -0
- package/docs/04-ai-sdk-ui/01-overview.mdx +44 -0
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +1313 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +535 -0
- package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +263 -0
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +682 -0
- package/docs/04-ai-sdk-ui/04-generative-user-interfaces.mdx +389 -0
- package/docs/04-ai-sdk-ui/05-completion.mdx +186 -0
- package/docs/04-ai-sdk-ui/08-object-generation.mdx +344 -0
- package/docs/04-ai-sdk-ui/20-streaming-data.mdx +397 -0
- package/docs/04-ai-sdk-ui/21-error-handling.mdx +190 -0
- package/docs/04-ai-sdk-ui/21-transport.mdx +174 -0
- package/docs/04-ai-sdk-ui/24-reading-ui-message-streams.mdx +104 -0
- package/docs/04-ai-sdk-ui/25-message-metadata.mdx +152 -0
- package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +477 -0
- package/docs/04-ai-sdk-ui/index.mdx +64 -0
- package/docs/05-ai-sdk-rsc/01-overview.mdx +45 -0
- package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +209 -0
- package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +279 -0
- package/docs/05-ai-sdk-rsc/03-saving-and-restoring-states.mdx +105 -0
- package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +282 -0
- package/docs/05-ai-sdk-rsc/05-streaming-values.mdx +158 -0
- package/docs/05-ai-sdk-rsc/06-loading-state.mdx +273 -0
- package/docs/05-ai-sdk-rsc/08-error-handling.mdx +96 -0
- package/docs/05-ai-sdk-rsc/09-authentication.mdx +42 -0
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +722 -0
- package/docs/05-ai-sdk-rsc/index.mdx +58 -0
- package/docs/06-advanced/01-prompt-engineering.mdx +96 -0
- package/docs/06-advanced/02-stopping-streams.mdx +184 -0
- package/docs/06-advanced/03-backpressure.mdx +173 -0
- package/docs/06-advanced/04-caching.mdx +169 -0
- package/docs/06-advanced/05-multiple-streamables.mdx +68 -0
- package/docs/06-advanced/06-rate-limiting.mdx +60 -0
- package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +213 -0
- package/docs/06-advanced/08-model-as-router.mdx +120 -0
- package/docs/06-advanced/09-multistep-interfaces.mdx +115 -0
- package/docs/06-advanced/09-sequential-generations.mdx +55 -0
- package/docs/06-advanced/10-vercel-deployment-guide.mdx +117 -0
- package/docs/06-advanced/index.mdx +11 -0
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +2142 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +3215 -0
- package/docs/07-reference/01-ai-sdk-core/03-generate-object.mdx +780 -0
- package/docs/07-reference/01-ai-sdk-core/04-stream-object.mdx +1140 -0
- package/docs/07-reference/01-ai-sdk-core/05-embed.mdx +190 -0
- package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +171 -0
- package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +309 -0
- package/docs/07-reference/01-ai-sdk-core/10-generate-image.mdx +227 -0
- package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +138 -0
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +214 -0
- package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +203 -0
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +449 -0
- package/docs/07-reference/01-ai-sdk-core/17-create-agent-ui-stream.mdx +148 -0
- package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +168 -0
- package/docs/07-reference/01-ai-sdk-core/18-pipe-agent-ui-stream-to-response.mdx +144 -0
- package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +196 -0
- package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +175 -0
- package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +410 -0
- package/docs/07-reference/01-ai-sdk-core/24-mcp-stdio-transport.mdx +68 -0
- package/docs/07-reference/01-ai-sdk-core/25-json-schema.mdx +94 -0
- package/docs/07-reference/01-ai-sdk-core/26-zod-schema.mdx +109 -0
- package/docs/07-reference/01-ai-sdk-core/27-valibot-schema.mdx +55 -0
- package/docs/07-reference/01-ai-sdk-core/28-output.mdx +342 -0
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +415 -0
- package/docs/07-reference/01-ai-sdk-core/31-ui-message.mdx +246 -0
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +101 -0
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +113 -0
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +182 -0
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +121 -0
- package/docs/07-reference/01-ai-sdk-core/50-cosine-similarity.mdx +52 -0
- package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +59 -0
- package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +64 -0
- package/docs/07-reference/01-ai-sdk-core/65-language-model-v2-middleware.mdx +46 -0
- package/docs/07-reference/01-ai-sdk-core/66-extract-reasoning-middleware.mdx +68 -0
- package/docs/07-reference/01-ai-sdk-core/67-simulate-streaming-middleware.mdx +71 -0
- package/docs/07-reference/01-ai-sdk-core/68-default-settings-middleware.mdx +80 -0
- package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +155 -0
- package/docs/07-reference/01-ai-sdk-core/70-extract-json-middleware.mdx +147 -0
- package/docs/07-reference/01-ai-sdk-core/70-step-count-is.mdx +84 -0
- package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +120 -0
- package/docs/07-reference/01-ai-sdk-core/75-simulate-readable-stream.mdx +94 -0
- package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +145 -0
- package/docs/07-reference/01-ai-sdk-core/90-generate-id.mdx +43 -0
- package/docs/07-reference/01-ai-sdk-core/91-create-id-generator.mdx +89 -0
- package/docs/07-reference/01-ai-sdk-core/index.mdx +159 -0
- package/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +446 -0
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +179 -0
- package/docs/07-reference/02-ai-sdk-ui/03-use-object.mdx +178 -0
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +230 -0
- package/docs/07-reference/02-ai-sdk-ui/32-prune-messages.mdx +108 -0
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +151 -0
- package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +113 -0
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +73 -0
- package/docs/07-reference/02-ai-sdk-ui/43-read-ui-message-stream.mdx +57 -0
- package/docs/07-reference/02-ai-sdk-ui/46-infer-ui-tools.mdx +99 -0
- package/docs/07-reference/02-ai-sdk-ui/47-infer-ui-tool.mdx +75 -0
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +333 -0
- package/docs/07-reference/02-ai-sdk-ui/index.mdx +89 -0
- package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +767 -0
- package/docs/07-reference/03-ai-sdk-rsc/02-create-ai.mdx +90 -0
- package/docs/07-reference/03-ai-sdk-rsc/03-create-streamable-ui.mdx +91 -0
- package/docs/07-reference/03-ai-sdk-rsc/04-create-streamable-value.mdx +48 -0
- package/docs/07-reference/03-ai-sdk-rsc/05-read-streamable-value.mdx +78 -0
- package/docs/07-reference/03-ai-sdk-rsc/06-get-ai-state.mdx +50 -0
- package/docs/07-reference/03-ai-sdk-rsc/07-get-mutable-ai-state.mdx +70 -0
- package/docs/07-reference/03-ai-sdk-rsc/08-use-ai-state.mdx +26 -0
- package/docs/07-reference/03-ai-sdk-rsc/09-use-actions.mdx +42 -0
- package/docs/07-reference/03-ai-sdk-rsc/10-use-ui-state.mdx +35 -0
- package/docs/07-reference/03-ai-sdk-rsc/11-use-streamable-value.mdx +46 -0
- package/docs/07-reference/03-ai-sdk-rsc/20-render.mdx +262 -0
- package/docs/07-reference/03-ai-sdk-rsc/index.mdx +67 -0
- package/docs/07-reference/04-stream-helpers/01-ai-stream.mdx +89 -0
- package/docs/07-reference/04-stream-helpers/02-streaming-text-response.mdx +79 -0
- package/docs/07-reference/04-stream-helpers/05-stream-to-response.mdx +108 -0
- package/docs/07-reference/04-stream-helpers/07-openai-stream.mdx +77 -0
- package/docs/07-reference/04-stream-helpers/08-anthropic-stream.mdx +79 -0
- package/docs/07-reference/04-stream-helpers/09-aws-bedrock-stream.mdx +91 -0
- package/docs/07-reference/04-stream-helpers/10-aws-bedrock-anthropic-stream.mdx +96 -0
- package/docs/07-reference/04-stream-helpers/10-aws-bedrock-messages-stream.mdx +96 -0
- package/docs/07-reference/04-stream-helpers/11-aws-bedrock-cohere-stream.mdx +93 -0
- package/docs/07-reference/04-stream-helpers/12-aws-bedrock-llama-2-stream.mdx +93 -0
- package/docs/07-reference/04-stream-helpers/13-cohere-stream.mdx +78 -0
- package/docs/07-reference/04-stream-helpers/14-google-generative-ai-stream.mdx +85 -0
- package/docs/07-reference/04-stream-helpers/15-hugging-face-stream.mdx +84 -0
- package/docs/07-reference/04-stream-helpers/16-langchain-adapter.mdx +98 -0
- package/docs/07-reference/04-stream-helpers/16-llamaindex-adapter.mdx +70 -0
- package/docs/07-reference/04-stream-helpers/17-mistral-stream.mdx +81 -0
- package/docs/07-reference/04-stream-helpers/18-replicate-stream.mdx +83 -0
- package/docs/07-reference/04-stream-helpers/19-inkeep-stream.mdx +80 -0
- package/docs/07-reference/04-stream-helpers/index.mdx +103 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-api-call-error.mdx +30 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-download-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-empty-response-body-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-argument-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-data-content.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-message-role-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-prompt-error.mdx +47 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-response-data-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-input-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-json-parse-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-load-api-key-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-load-setting-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-message-conversion-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-content-generated-error.mdx +24 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-image-generated-error.mdx +36 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-object-generated-error.mdx +43 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-speech-generated-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-model-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-provider-error.mdx +28 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-such-tool-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-no-transcript-generated-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-retry-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-too-many-embedding-values-for-call-error.mdx +27 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-not-found-for-approval-error.mdx +26 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-tool-call-repair-error.mdx +28 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-type-validation-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-unsupported-functionality-error.mdx +25 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +38 -0
- package/docs/07-reference/index.mdx +34 -0
- package/docs/08-migration-guides/00-versioning.mdx +46 -0
- package/docs/08-migration-guides/24-migration-guide-6-0.mdx +823 -0
- package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +882 -0
- package/docs/08-migration-guides/26-migration-guide-5-0.mdx +3427 -0
- package/docs/08-migration-guides/27-migration-guide-4-2.mdx +99 -0
- package/docs/08-migration-guides/28-migration-guide-4-1.mdx +14 -0
- package/docs/08-migration-guides/29-migration-guide-4-0.mdx +1157 -0
- package/docs/08-migration-guides/36-migration-guide-3-4.mdx +14 -0
- package/docs/08-migration-guides/37-migration-guide-3-3.mdx +64 -0
- package/docs/08-migration-guides/38-migration-guide-3-2.mdx +46 -0
- package/docs/08-migration-guides/39-migration-guide-3-1.mdx +168 -0
- package/docs/08-migration-guides/index.mdx +22 -0
- package/docs/09-troubleshooting/01-azure-stream-slow.mdx +33 -0
- package/docs/09-troubleshooting/02-client-side-function-calls-not-invoked.mdx +22 -0
- package/docs/09-troubleshooting/03-server-actions-in-client-components.mdx +40 -0
- package/docs/09-troubleshooting/04-strange-stream-output.mdx +36 -0
- package/docs/09-troubleshooting/05-streamable-ui-errors.mdx +16 -0
- package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +106 -0
- package/docs/09-troubleshooting/06-streaming-not-working-when-deployed.mdx +31 -0
- package/docs/09-troubleshooting/06-streaming-not-working-when-proxied.mdx +31 -0
- package/docs/09-troubleshooting/06-timeout-on-vercel.mdx +60 -0
- package/docs/09-troubleshooting/07-unclosed-streams.mdx +34 -0
- package/docs/09-troubleshooting/08-use-chat-failed-to-parse-stream.mdx +26 -0
- package/docs/09-troubleshooting/09-client-stream-error.mdx +25 -0
- package/docs/09-troubleshooting/10-use-chat-tools-no-response.mdx +32 -0
- package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +149 -0
- package/docs/09-troubleshooting/12-typescript-performance-zod.mdx +46 -0
- package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +59 -0
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +73 -0
- package/docs/09-troubleshooting/14-stream-abort-handling.mdx +73 -0
- package/docs/09-troubleshooting/14-tool-calling-with-structured-outputs.mdx +48 -0
- package/docs/09-troubleshooting/15-abort-breaks-resumable-streams.mdx +55 -0
- package/docs/09-troubleshooting/15-stream-text-not-working.mdx +33 -0
- package/docs/09-troubleshooting/16-streaming-status-delay.mdx +63 -0
- package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +141 -0
- package/docs/09-troubleshooting/18-ontoolcall-type-narrowing.mdx +66 -0
- package/docs/09-troubleshooting/19-unsupported-model-version.mdx +50 -0
- package/docs/09-troubleshooting/20-no-object-generated-content-filter.mdx +72 -0
- package/docs/09-troubleshooting/30-model-is-not-assignable-to-type.mdx +21 -0
- package/docs/09-troubleshooting/40-typescript-cannot-find-namespace-jsx.mdx +24 -0
- package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +39 -0
- package/docs/09-troubleshooting/60-jest-cannot-find-module-ai-rsc.mdx +22 -0
- package/docs/09-troubleshooting/index.mdx +11 -0
- package/package.json +8 -4
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: hasToolCall
|
|
3
|
+
description: API Reference for hasToolCall.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `hasToolCall()`
|
|
7
|
+
|
|
8
|
+
Creates a stop condition that stops when a specific tool is called.
|
|
9
|
+
|
|
10
|
+
This function is used with `stopWhen` in `generateText` and `streamText` to control when a tool-calling loop should stop based on whether a particular tool has been invoked.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { generateText, hasToolCall } from 'ai';
|
|
14
|
+
__PROVIDER_IMPORT__;
|
|
15
|
+
|
|
16
|
+
const result = await generateText({
|
|
17
|
+
model: __MODEL__,
|
|
18
|
+
tools: {
|
|
19
|
+
weather: weatherTool,
|
|
20
|
+
finalAnswer: finalAnswerTool,
|
|
21
|
+
},
|
|
22
|
+
// Stop when the finalAnswer tool is called
|
|
23
|
+
stopWhen: hasToolCall('finalAnswer'),
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Import
|
|
28
|
+
|
|
29
|
+
<Snippet text={`import { hasToolCall } from "ai"`} prompt={false} />
|
|
30
|
+
|
|
31
|
+
## API Signature
|
|
32
|
+
|
|
33
|
+
### Parameters
|
|
34
|
+
|
|
35
|
+
<PropertiesTable
|
|
36
|
+
content={[
|
|
37
|
+
{
|
|
38
|
+
name: 'toolName',
|
|
39
|
+
type: 'string',
|
|
40
|
+
description:
|
|
41
|
+
'The name of the tool that should trigger the stop condition when called.',
|
|
42
|
+
},
|
|
43
|
+
]}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
### Returns
|
|
47
|
+
|
|
48
|
+
A `StopCondition` function that returns `true` when the specified tool is called in the current step. The function can be used with the `stopWhen` parameter in `generateText` and `streamText`.
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Basic Usage
|
|
53
|
+
|
|
54
|
+
Stop when a specific tool is called:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { generateText, hasToolCall } from 'ai';
|
|
58
|
+
|
|
59
|
+
const result = await generateText({
|
|
60
|
+
model: yourModel,
|
|
61
|
+
tools: {
|
|
62
|
+
submitAnswer: submitAnswerTool,
|
|
63
|
+
search: searchTool,
|
|
64
|
+
},
|
|
65
|
+
stopWhen: hasToolCall('submitAnswer'),
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Combining with Other Conditions
|
|
70
|
+
|
|
71
|
+
You can combine multiple stop conditions in an array:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { generateText, hasToolCall, stepCountIs } from 'ai';
|
|
75
|
+
|
|
76
|
+
const result = await generateText({
|
|
77
|
+
model: yourModel,
|
|
78
|
+
tools: {
|
|
79
|
+
weather: weatherTool,
|
|
80
|
+
search: searchTool,
|
|
81
|
+
finalAnswer: finalAnswerTool,
|
|
82
|
+
},
|
|
83
|
+
// Stop when weather tool is called OR finalAnswer is called OR after 5 steps
|
|
84
|
+
stopWhen: [
|
|
85
|
+
hasToolCall('weather'),
|
|
86
|
+
hasToolCall('finalAnswer'),
|
|
87
|
+
stepCountIs(5),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Agent Pattern
|
|
93
|
+
|
|
94
|
+
Common pattern for agents that run until they provide a final answer:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { generateText, hasToolCall } from 'ai';
|
|
98
|
+
|
|
99
|
+
const result = await generateText({
|
|
100
|
+
model: yourModel,
|
|
101
|
+
tools: {
|
|
102
|
+
search: searchTool,
|
|
103
|
+
calculate: calculateTool,
|
|
104
|
+
finalAnswer: {
|
|
105
|
+
description: 'Provide the final answer to the user',
|
|
106
|
+
parameters: z.object({
|
|
107
|
+
answer: z.string(),
|
|
108
|
+
}),
|
|
109
|
+
execute: async ({ answer }) => answer,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
stopWhen: hasToolCall('finalAnswer'),
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## See also
|
|
117
|
+
|
|
118
|
+
- [`stepCountIs()`](/docs/reference/ai-sdk-core/step-count-is)
|
|
119
|
+
- [`generateText()`](/docs/reference/ai-sdk-core/generate-text)
|
|
120
|
+
- [`streamText()`](/docs/reference/ai-sdk-core/stream-text)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: simulateReadableStream
|
|
3
|
+
description: Create a ReadableStream that emits values with configurable delays
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `simulateReadableStream()`
|
|
7
|
+
|
|
8
|
+
`simulateReadableStream` is a utility function that creates a ReadableStream which emits provided values sequentially with configurable delays. This is particularly useful for testing streaming functionality or simulating time-delayed data streams.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { simulateReadableStream } from 'ai';
|
|
12
|
+
|
|
13
|
+
const stream = simulateReadableStream({
|
|
14
|
+
chunks: ['Hello', ' ', 'World'],
|
|
15
|
+
initialDelayInMs: 100,
|
|
16
|
+
chunkDelayInMs: 50,
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Import
|
|
21
|
+
|
|
22
|
+
<Snippet text={`import { simulateReadableStream } from "ai"`} prompt={false} />
|
|
23
|
+
|
|
24
|
+
## API Signature
|
|
25
|
+
|
|
26
|
+
### Parameters
|
|
27
|
+
|
|
28
|
+
<PropertiesTable
|
|
29
|
+
content={[
|
|
30
|
+
{
|
|
31
|
+
name: 'chunks',
|
|
32
|
+
type: 'T[]',
|
|
33
|
+
isOptional: false,
|
|
34
|
+
description: 'Array of values to be emitted by the stream',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'initialDelayInMs',
|
|
38
|
+
type: 'number | null',
|
|
39
|
+
isOptional: true,
|
|
40
|
+
description:
|
|
41
|
+
'Initial delay in milliseconds before emitting the first value. Defaults to 0. Set to null to skip the initial delay entirely.',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'chunkDelayInMs',
|
|
45
|
+
type: 'number | null',
|
|
46
|
+
isOptional: true,
|
|
47
|
+
description:
|
|
48
|
+
'Delay in milliseconds between emitting each value. Defaults to 0. Set to null to skip delays between chunks.',
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
### Returns
|
|
54
|
+
|
|
55
|
+
Returns a `ReadableStream<T>` that:
|
|
56
|
+
|
|
57
|
+
- Emits each value from the provided `chunks` array sequentially
|
|
58
|
+
- Waits for `initialDelayInMs` before emitting the first value (if not `null`)
|
|
59
|
+
- Waits for `chunkDelayInMs` between emitting subsequent values (if not `null`)
|
|
60
|
+
- Closes automatically after all chunks have been emitted
|
|
61
|
+
|
|
62
|
+
### Type Parameters
|
|
63
|
+
|
|
64
|
+
- `T`: The type of values contained in the chunks array and emitted by the stream
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
### Basic Usage
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const stream = simulateReadableStream({
|
|
72
|
+
chunks: ['Hello', ' ', 'World'],
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### With Delays
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const stream = simulateReadableStream({
|
|
80
|
+
chunks: ['Hello', ' ', 'World'],
|
|
81
|
+
initialDelayInMs: 1000, // Wait 1 second before first chunk
|
|
82
|
+
chunkDelayInMs: 500, // Wait 0.5 seconds between chunks
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Without Delays
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const stream = simulateReadableStream({
|
|
90
|
+
chunks: ['Hello', ' ', 'World'],
|
|
91
|
+
initialDelayInMs: null, // No initial delay
|
|
92
|
+
chunkDelayInMs: null, // No delay between chunks
|
|
93
|
+
});
|
|
94
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: smoothStream
|
|
3
|
+
description: Stream transformer for smoothing text and reasoning output
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `smoothStream()`
|
|
7
|
+
|
|
8
|
+
`smoothStream` is a utility function that creates a TransformStream
|
|
9
|
+
for the `streamText` `transform` option
|
|
10
|
+
to smooth out text and reasoning streaming by buffering and releasing complete chunks with configurable delays.
|
|
11
|
+
This creates a more natural reading experience when streaming text and reasoning responses.
|
|
12
|
+
|
|
13
|
+
```ts highlight={"6-9"}
|
|
14
|
+
import { smoothStream, streamText } from 'ai';
|
|
15
|
+
|
|
16
|
+
const result = streamText({
|
|
17
|
+
model,
|
|
18
|
+
prompt,
|
|
19
|
+
experimental_transform: smoothStream({
|
|
20
|
+
delayInMs: 20, // optional: defaults to 10ms
|
|
21
|
+
chunking: 'line', // optional: defaults to 'word'
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Import
|
|
27
|
+
|
|
28
|
+
<Snippet text={`import { smoothStream } from "ai"`} prompt={false} />
|
|
29
|
+
|
|
30
|
+
## API Signature
|
|
31
|
+
|
|
32
|
+
### Parameters
|
|
33
|
+
|
|
34
|
+
<PropertiesTable
|
|
35
|
+
content={[
|
|
36
|
+
{
|
|
37
|
+
name: 'delayInMs',
|
|
38
|
+
type: 'number | null',
|
|
39
|
+
isOptional: true,
|
|
40
|
+
description:
|
|
41
|
+
'The delay in milliseconds between outputting each chunk. Defaults to 10ms. Set to `null` to disable delays.',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'chunking',
|
|
45
|
+
type: '"word" | "line" | RegExp | Intl.Segmenter | (buffer: string) => string | undefined | null',
|
|
46
|
+
isOptional: true,
|
|
47
|
+
description:
|
|
48
|
+
'Controls how text and reasoning content is chunked for streaming. Use "word" to stream word by word (default), "line" to stream line by line, an Intl.Segmenter for locale-aware word segmentation (recommended for CJK languages), or provide a custom callback or RegExp pattern for custom chunking.',
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
#### Word chunking caveats with non-latin languages
|
|
54
|
+
|
|
55
|
+
The word based chunking **does not work well** with the following languages that do not delimit words with spaces:
|
|
56
|
+
|
|
57
|
+
- Chinese
|
|
58
|
+
- Japanese
|
|
59
|
+
- Korean
|
|
60
|
+
- Vietnamese
|
|
61
|
+
- Thai
|
|
62
|
+
|
|
63
|
+
#### Using Intl.Segmenter (recommended)
|
|
64
|
+
|
|
65
|
+
For these languages, we recommend using `Intl.Segmenter` for proper locale-aware word segmentation.
|
|
66
|
+
This is the preferred approach as it provides accurate word boundaries for CJK and other languages.
|
|
67
|
+
|
|
68
|
+
<Note>
|
|
69
|
+
`Intl.Segmenter` is available in Node.js 16+ and all modern browsers (Chrome
|
|
70
|
+
87+, Firefox 125+, Safari 14.1+).
|
|
71
|
+
</Note>
|
|
72
|
+
|
|
73
|
+
```tsx filename="Japanese example with Intl.Segmenter"
|
|
74
|
+
import { smoothStream, streamText } from 'ai';
|
|
75
|
+
__PROVIDER_IMPORT__;
|
|
76
|
+
|
|
77
|
+
const segmenter = new Intl.Segmenter('ja', { granularity: 'word' });
|
|
78
|
+
|
|
79
|
+
const result = streamText({
|
|
80
|
+
model: __MODEL__,
|
|
81
|
+
prompt: 'Your prompt here',
|
|
82
|
+
experimental_transform: smoothStream({
|
|
83
|
+
chunking: segmenter,
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```tsx filename="Chinese example with Intl.Segmenter"
|
|
89
|
+
import { smoothStream, streamText } from 'ai';
|
|
90
|
+
__PROVIDER_IMPORT__;
|
|
91
|
+
|
|
92
|
+
const segmenter = new Intl.Segmenter('zh', { granularity: 'word' });
|
|
93
|
+
|
|
94
|
+
const result = streamText({
|
|
95
|
+
model: __MODEL__,
|
|
96
|
+
prompt: 'Your prompt here',
|
|
97
|
+
experimental_transform: smoothStream({
|
|
98
|
+
chunking: segmenter,
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Regex based chunking
|
|
104
|
+
|
|
105
|
+
To use regex based chunking, pass a `RegExp` to the `chunking` option.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// To split on underscores:
|
|
109
|
+
smoothStream({
|
|
110
|
+
chunking: /_+/,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Also can do it like this, same behavior
|
|
114
|
+
smoothStream({
|
|
115
|
+
chunking: /[^_]*_/,
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Custom callback chunking
|
|
120
|
+
|
|
121
|
+
To use a custom callback for chunking, pass a function to the `chunking` option.
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
smoothStream({
|
|
125
|
+
chunking: text => {
|
|
126
|
+
const findString = 'some string';
|
|
127
|
+
const index = text.indexOf(findString);
|
|
128
|
+
|
|
129
|
+
if (index === -1) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return text.slice(0, index) + findString;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Returns
|
|
139
|
+
|
|
140
|
+
Returns a `TransformStream` that:
|
|
141
|
+
|
|
142
|
+
- Buffers incoming text and reasoning chunks
|
|
143
|
+
- Releases content when the chunking pattern is encountered
|
|
144
|
+
- Adds configurable delays between chunks for smooth output
|
|
145
|
+
- Passes through non-text/reasoning chunks (like tool calls, step-finish events) immediately
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: generateId
|
|
3
|
+
description: Generate a unique identifier (API Reference)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `generateId()`
|
|
7
|
+
|
|
8
|
+
Generates a unique identifier. You can optionally provide the length of the ID.
|
|
9
|
+
|
|
10
|
+
This is the same id generator used by the AI SDK.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { generateId } from 'ai';
|
|
14
|
+
|
|
15
|
+
const id = generateId();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Import
|
|
19
|
+
|
|
20
|
+
<Snippet text={`import { generateId } from "ai"`} prompt={false} />
|
|
21
|
+
|
|
22
|
+
## API Signature
|
|
23
|
+
|
|
24
|
+
### Parameters
|
|
25
|
+
|
|
26
|
+
<PropertiesTable
|
|
27
|
+
content={[
|
|
28
|
+
{
|
|
29
|
+
name: 'size',
|
|
30
|
+
type: 'number',
|
|
31
|
+
description:
|
|
32
|
+
'The length of the generated ID. It defaults to 16. This parameter is deprecated and will be removed in the next major version.',
|
|
33
|
+
},
|
|
34
|
+
]}
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
### Returns
|
|
38
|
+
|
|
39
|
+
A string representing the generated ID.
|
|
40
|
+
|
|
41
|
+
## See also
|
|
42
|
+
|
|
43
|
+
- [`createIdGenerator()`](/docs/reference/ai-sdk-core/create-id-generator)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: createIdGenerator
|
|
3
|
+
description: Create a customizable unique identifier generator (API Reference)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `createIdGenerator()`
|
|
7
|
+
|
|
8
|
+
Creates a customizable ID generator function. You can configure the alphabet, prefix, separator, and default size of the generated IDs.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createIdGenerator } from 'ai';
|
|
12
|
+
|
|
13
|
+
const generateCustomId = createIdGenerator({
|
|
14
|
+
prefix: 'user',
|
|
15
|
+
separator: '_',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const id = generateCustomId(); // Example: "user_1a2b3c4d5e6f7g8h"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Import
|
|
22
|
+
|
|
23
|
+
<Snippet text={`import { createIdGenerator } from "ai"`} prompt={false} />
|
|
24
|
+
|
|
25
|
+
## API Signature
|
|
26
|
+
|
|
27
|
+
### Parameters
|
|
28
|
+
|
|
29
|
+
<PropertiesTable
|
|
30
|
+
content={[
|
|
31
|
+
{
|
|
32
|
+
name: 'options',
|
|
33
|
+
type: 'object',
|
|
34
|
+
description:
|
|
35
|
+
'Optional configuration object with the following properties:',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'options.alphabet',
|
|
39
|
+
type: 'string',
|
|
40
|
+
description:
|
|
41
|
+
'The characters to use for generating the random part of the ID. Defaults to alphanumeric characters (0-9, A-Z, a-z).',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'options.prefix',
|
|
45
|
+
type: 'string',
|
|
46
|
+
description:
|
|
47
|
+
'A string to prepend to all generated IDs. Defaults to none.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'options.separator',
|
|
51
|
+
type: 'string',
|
|
52
|
+
description:
|
|
53
|
+
'The character(s) to use between the prefix and the random part. Defaults to "-".',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'options.size',
|
|
57
|
+
type: 'number',
|
|
58
|
+
description:
|
|
59
|
+
'The default length of the random part of the ID. Defaults to 16.',
|
|
60
|
+
},
|
|
61
|
+
]}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
### Returns
|
|
65
|
+
|
|
66
|
+
Returns a function that generates IDs based on the configured options.
|
|
67
|
+
|
|
68
|
+
### Notes
|
|
69
|
+
|
|
70
|
+
- The generator uses non-secure random generation and should not be used for security-critical purposes.
|
|
71
|
+
- The separator character must not be part of the alphabet to ensure reliable prefix checking.
|
|
72
|
+
|
|
73
|
+
## Example
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// Create a custom ID generator for user IDs
|
|
77
|
+
const generateUserId = createIdGenerator({
|
|
78
|
+
prefix: 'user',
|
|
79
|
+
separator: '_',
|
|
80
|
+
size: 8,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Generate IDs
|
|
84
|
+
const id1 = generateUserId(); // e.g., "user_1a2b3c4d"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## See also
|
|
88
|
+
|
|
89
|
+
- [`generateId()`](/docs/reference/ai-sdk-core/generate-id)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI SDK Core
|
|
3
|
+
description: Reference documentation for the AI SDK Core
|
|
4
|
+
collapsed: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AI SDK Core
|
|
8
|
+
|
|
9
|
+
[AI SDK Core](/docs/ai-sdk-core) is a set of functions that allow you to interact with language models and other AI models.
|
|
10
|
+
These functions are designed to be easy-to-use and flexible, allowing you to generate text, structured data,
|
|
11
|
+
and embeddings from language models and other AI models.
|
|
12
|
+
|
|
13
|
+
AI SDK Core contains the following main functions:
|
|
14
|
+
|
|
15
|
+
<IndexCards
|
|
16
|
+
cards={[
|
|
17
|
+
{
|
|
18
|
+
title: 'generateText()',
|
|
19
|
+
description: 'Generate text and call tools from a language model.',
|
|
20
|
+
href: '/docs/reference/ai-sdk-core/generate-text',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
title: 'streamText()',
|
|
24
|
+
description: 'Stream text and call tools from a language model.',
|
|
25
|
+
href: '/docs/reference/ai-sdk-core/stream-text',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: 'generateObject()',
|
|
29
|
+
description: 'Generate structured data from a language model.',
|
|
30
|
+
href: '/docs/reference/ai-sdk-core/generate-object',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
title: 'streamObject()',
|
|
34
|
+
description: 'Stream structured data from a language model.',
|
|
35
|
+
href: '/docs/reference/ai-sdk-core/stream-object',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'embed()',
|
|
39
|
+
description:
|
|
40
|
+
'Generate an embedding for a single value using an embedding model.',
|
|
41
|
+
href: '/docs/reference/ai-sdk-core/embed',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'embedMany()',
|
|
45
|
+
description:
|
|
46
|
+
'Generate embeddings for several values using an embedding model (batch embedding).',
|
|
47
|
+
href: '/docs/reference/ai-sdk-core/embed-many',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: 'generateImage()',
|
|
51
|
+
description:
|
|
52
|
+
'Generate images based on a given prompt using an image model.',
|
|
53
|
+
href: '/docs/reference/ai-sdk-core/generate-image',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'experimental_transcribe()',
|
|
57
|
+
description: 'Generate a transcript from an audio file.',
|
|
58
|
+
href: '/docs/reference/ai-sdk-core/transcribe',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: 'experimental_generateSpeech()',
|
|
62
|
+
description: 'Generate speech audio from text.',
|
|
63
|
+
href: '/docs/reference/ai-sdk-core/generate-speech',
|
|
64
|
+
},
|
|
65
|
+
]}
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
It also contains the following helper functions:
|
|
69
|
+
|
|
70
|
+
<IndexCards
|
|
71
|
+
cards={[
|
|
72
|
+
{
|
|
73
|
+
title: 'tool()',
|
|
74
|
+
description: 'Type inference helper function for tools.',
|
|
75
|
+
href: '/docs/reference/ai-sdk-core/tool',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: 'createMCPClient()',
|
|
79
|
+
description: 'Creates a client for connecting to MCP servers.',
|
|
80
|
+
href: '/docs/reference/ai-sdk-core/create-mcp-client',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: 'jsonSchema()',
|
|
84
|
+
description: 'Creates AI SDK compatible JSON schema objects.',
|
|
85
|
+
href: '/docs/reference/ai-sdk-core/json-schema',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
title: 'zodSchema()',
|
|
89
|
+
description: 'Creates AI SDK compatible Zod schema objects.',
|
|
90
|
+
href: '/docs/reference/ai-sdk-core/zod-schema',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
title: 'createProviderRegistry()',
|
|
94
|
+
description:
|
|
95
|
+
'Creates a registry for using models from multiple providers.',
|
|
96
|
+
href: '/docs/reference/ai-sdk-core/provider-registry',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: 'cosineSimilarity()',
|
|
100
|
+
description:
|
|
101
|
+
'Calculates the cosine similarity between two vectors, e.g. embeddings.',
|
|
102
|
+
href: '/docs/reference/ai-sdk-core/cosine-similarity',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
title: 'simulateReadableStream()',
|
|
106
|
+
description:
|
|
107
|
+
'Creates a ReadableStream that emits values with configurable delays.',
|
|
108
|
+
href: '/docs/reference/ai-sdk-core/simulate-readable-stream',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
title: 'wrapLanguageModel()',
|
|
112
|
+
description: 'Wraps a language model with middleware.',
|
|
113
|
+
href: '/docs/reference/ai-sdk-core/wrap-language-model',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: 'wrapImageModel()',
|
|
117
|
+
description: 'Wraps an image model with middleware.',
|
|
118
|
+
href: '/docs/reference/ai-sdk-core/wrap-image-model',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
title: 'extractReasoningMiddleware()',
|
|
122
|
+
description:
|
|
123
|
+
'Extracts reasoning from the generated text and exposes it as a `reasoning` property on the result.',
|
|
124
|
+
href: '/docs/reference/ai-sdk-core/extract-reasoning-middleware',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
title: 'extractJsonMiddleware()',
|
|
128
|
+
description:
|
|
129
|
+
'Extracts JSON from text content by stripping markdown code fences.',
|
|
130
|
+
href: '/docs/reference/ai-sdk-core/extract-json-middleware',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
title: 'simulateStreamingMiddleware()',
|
|
134
|
+
description:
|
|
135
|
+
'Simulates streaming behavior with responses from non-streaming language models.',
|
|
136
|
+
href: '/docs/reference/ai-sdk-core/simulate-streaming-middleware',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
title: 'defaultSettingsMiddleware()',
|
|
140
|
+
description: 'Applies default settings to a language model.',
|
|
141
|
+
href: '/docs/reference/ai-sdk-core/default-settings-middleware',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
title: 'smoothStream()',
|
|
145
|
+
description: 'Smooths text and reasoning streaming output.',
|
|
146
|
+
href: '/docs/reference/ai-sdk-core/smooth-stream',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
title: 'generateId()',
|
|
150
|
+
description: 'Helper function for generating unique IDs',
|
|
151
|
+
href: '/docs/reference/ai-sdk-core/generate-id',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: 'createIdGenerator()',
|
|
155
|
+
description: 'Creates an ID generator',
|
|
156
|
+
href: '/docs/reference/ai-sdk-core/create-id-generator',
|
|
157
|
+
},
|
|
158
|
+
]}
|
|
159
|
+
/>
|