ai 7.0.28 → 7.0.29
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 +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +5 -2
- package/docs/02-foundations/04-tools.mdx +1 -1
- package/docs/02-getting-started/02-nextjs-app-router.mdx +1 -1
- package/docs/02-getting-started/03-nextjs-pages-router.mdx +1 -1
- package/docs/02-getting-started/06-nodejs.mdx +1 -1
- package/docs/03-agents/08-terminal-ui.mdx +28 -7
- package/docs/03-ai-sdk-core/01-overview.mdx +1 -1
- package/docs/03-ai-sdk-core/05-generating-text.mdx +5 -5
- package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +3 -3
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +10 -10
- package/docs/03-ai-sdk-core/25-settings.mdx +1 -1
- package/docs/03-ai-sdk-core/30-embeddings.mdx +1 -1
- package/docs/03-ai-sdk-core/31-reranking.mdx +4 -4
- package/docs/03-ai-sdk-core/35-image-generation.mdx +1 -1
- package/docs/03-ai-sdk-core/36-transcription.mdx +9 -4
- package/docs/03-ai-sdk-core/37-speech.mdx +1 -0
- package/docs/03-ai-sdk-core/38-video-generation.mdx +5 -5
- package/docs/03-ai-sdk-core/50-error-handling.mdx +5 -5
- package/docs/03-ai-sdk-core/55-testing.mdx +1 -1
- package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +5 -5
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +2 -2
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
- package/docs/04-ai-sdk-ui/20-streaming-data.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +1 -1
- package/docs/06-advanced/04-caching.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/index.mdx +0 -5
- package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +29 -8
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +1 -1
- package/docs/08-migration-guides/29-migration-guide-4-0.mdx +1 -1
- package/docs/08-migration-guides/37-migration-guide-3-3.mdx +1 -1
- package/docs/08-migration-guides/39-migration-guide-3-1.mdx +1 -1
- package/docs/09-troubleshooting/14-tool-calling-with-structured-outputs.mdx +1 -1
- package/docs/09-troubleshooting/15-stream-text-not-working.mdx +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,7 @@ import {
|
|
|
1089
1089
|
} from "@ai-sdk/provider-utils";
|
|
1090
1090
|
|
|
1091
1091
|
// src/version.ts
|
|
1092
|
-
var VERSION = true ? "7.0.
|
|
1092
|
+
var VERSION = true ? "7.0.29" : "0.0.0-test";
|
|
1093
1093
|
|
|
1094
1094
|
// src/util/download/download.ts
|
|
1095
1095
|
var download = async ({
|
package/dist/internal/index.js
CHANGED
|
@@ -14,10 +14,13 @@ To solve these challenges, AI SDK Core offers a standardized approach to interac
|
|
|
14
14
|
Here is an overview of the AI SDK Provider Architecture:
|
|
15
15
|
|
|
16
16
|
<MDXImage
|
|
17
|
+
alt="Diagram showing the AI SDK Core API, provider specifications, and provider implementations"
|
|
17
18
|
srcLight="/images/ai-sdk-diagram.png"
|
|
18
19
|
srcDark="/images/ai-sdk-diagram-dark.png"
|
|
19
|
-
width={
|
|
20
|
-
height={
|
|
20
|
+
width={1694}
|
|
21
|
+
height={1206}
|
|
22
|
+
widthDark={2541}
|
|
23
|
+
heightDark={1884}
|
|
21
24
|
/>
|
|
22
25
|
|
|
23
26
|
## AI SDK Providers
|
|
@@ -37,7 +37,7 @@ Tools with an `execute` function are run automatically when these calls are gene
|
|
|
37
37
|
The output of the tool calls are returned using tool result objects.
|
|
38
38
|
|
|
39
39
|
You can automatically pass tool results back to the LLM
|
|
40
|
-
using [multi-step calls](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls) with `streamText` and `generateText`.
|
|
40
|
+
using [multi-step calls](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls-using-stopwhen) with `streamText` and `generateText`.
|
|
41
41
|
|
|
42
42
|
## Types of Tools
|
|
43
43
|
|
|
@@ -417,7 +417,7 @@ By setting `stopWhen: isStepCount(5)`, you're allowing the model to use up to 5
|
|
|
417
417
|
|
|
418
418
|
Update your `app/api/chat/route.ts` file to add a new tool to convert the temperature from Fahrenheit to Celsius:
|
|
419
419
|
|
|
420
|
-
```tsx filename="app/api/chat/route.ts" highlight="
|
|
420
|
+
```tsx filename="app/api/chat/route.ts" highlight="34-47"
|
|
421
421
|
import {
|
|
422
422
|
streamText,
|
|
423
423
|
UIMessage,
|
|
@@ -402,7 +402,7 @@ By setting `stopWhen: isStepCount(5)`, you're allowing the model to use up to 5
|
|
|
402
402
|
|
|
403
403
|
Update your `app/api/chat/route.ts` file to add a new tool to convert the temperature from Fahrenheit to Celsius:
|
|
404
404
|
|
|
405
|
-
```tsx filename="app/api/chat/route.ts" highlight="
|
|
405
|
+
```tsx filename="app/api/chat/route.ts" highlight="34-47"
|
|
406
406
|
import {
|
|
407
407
|
streamText,
|
|
408
408
|
UIMessage,
|
|
@@ -250,7 +250,7 @@ Try asking something like "What's the weather in New York?" and see how the agen
|
|
|
250
250
|
|
|
251
251
|
Notice the blank "assistant" response? This is because instead of generating a text response, the agent generated a tool call. You can access the tool call and subsequent tool result in the `toolCall` and `toolResult` keys of the result object.
|
|
252
252
|
|
|
253
|
-
```typescript highlight="
|
|
253
|
+
```typescript highlight="50-51"
|
|
254
254
|
import { ModelMessage, streamText, tool } from 'ai';
|
|
255
255
|
__PROVIDER_IMPORT__;
|
|
256
256
|
import 'dotenv/config';
|
|
@@ -5,10 +5,10 @@ description: Run AI SDK agents in an interactive terminal UI.
|
|
|
5
5
|
|
|
6
6
|
# Terminal UI
|
|
7
7
|
|
|
8
|
-
The `@ai-sdk/tui` package lets you run a `ToolLoopAgent`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
custom UI.
|
|
8
|
+
The `@ai-sdk/tui` package lets you run a local `ToolLoopAgent` or connect to a
|
|
9
|
+
remote agent through a `ChatTransport` in an interactive terminal interface.
|
|
10
|
+
It is useful for local development, demos, and internal tools where a terminal
|
|
11
|
+
experience is enough and you do not want to build a custom UI.
|
|
12
12
|
|
|
13
13
|
The terminal UI handles prompt input, streamed assistant responses, markdown
|
|
14
14
|
rendering, tool cards, reasoning sections, scrolling, and tool approval prompts.
|
|
@@ -55,6 +55,27 @@ await runAgentTUI({
|
|
|
55
55
|
|
|
56
56
|
`runAgentTUI` runs until the user exits with `Esc` or `Ctrl+C`.
|
|
57
57
|
|
|
58
|
+
## Connecting to a Remote Agent
|
|
59
|
+
|
|
60
|
+
Pass a `ChatTransport` instead of an `agent` to connect the terminal UI to a
|
|
61
|
+
remote AI SDK UI message endpoint:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { runAgentTUI } from '@ai-sdk/tui';
|
|
65
|
+
import { DefaultChatTransport } from 'ai';
|
|
66
|
+
|
|
67
|
+
await runAgentTUI({
|
|
68
|
+
title: 'Remote Agent',
|
|
69
|
+
transport: new DefaultChatTransport({
|
|
70
|
+
api: 'https://example.com/api/chat',
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The transport controls the endpoint, authentication, request body, and other
|
|
76
|
+
remote communication behavior. The terminal UI keeps its internal chat id and
|
|
77
|
+
message history private to the transport contract.
|
|
78
|
+
|
|
58
79
|
## Sandbox
|
|
59
80
|
|
|
60
81
|
Pass a sandbox session with the `sandbox` option when your agent tools need an
|
|
@@ -134,10 +155,10 @@ await runAgentTUI({ title: 'Weather Agent', agent });
|
|
|
134
155
|
|
|
135
156
|
## Compatibility
|
|
136
157
|
|
|
137
|
-
`
|
|
138
|
-
input.
|
|
158
|
+
When using the `agent` option, the agent must be runnable directly from terminal
|
|
159
|
+
user input. It must not require per-call options and must not use structured
|
|
139
160
|
output, because the terminal UI cannot infer those values from a free-form
|
|
140
|
-
prompt.
|
|
161
|
+
prompt. Use a `transport` for remote agents that need custom request handling.
|
|
141
162
|
|
|
142
163
|
Use `agent.generate()` or `agent.stream()` directly for examples or apps that
|
|
143
164
|
need fixed prompts, call options, structured output, custom result inspection, or
|
|
@@ -17,7 +17,7 @@ For example, here’s how you can generate text with various models using the AI
|
|
|
17
17
|
## AI SDK Core Functions
|
|
18
18
|
|
|
19
19
|
AI SDK Core has various functions designed for [text generation](./generating-text), [structured data generation](./generating-structured-data), and [tool usage](./tools-and-tool-calling).
|
|
20
|
-
These functions take a standardized approach to setting up [prompts](
|
|
20
|
+
These functions take a standardized approach to setting up [prompts](/docs/foundations/prompts) and [settings](./settings), making it easier to work with different models.
|
|
21
21
|
|
|
22
22
|
- [`generateText`](/docs/ai-sdk-core/generating-text): Generates text and [tool calls](./tools-and-tool-calling).
|
|
23
23
|
This function is ideal for non-interactive use cases such as automation tasks where you need to write text (e.g. drafting email or summarizing web pages) and for agents that use tools.
|
|
@@ -29,7 +29,7 @@ const { text } = await generateText({
|
|
|
29
29
|
});
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
You can use more [advanced prompts](
|
|
32
|
+
You can use more [advanced prompts](/docs/foundations/prompts) to generate text with more complex instructions and content:
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
35
|
import { generateText } from 'ai';
|
|
@@ -97,7 +97,7 @@ When using `generateText`, you can provide an `onEnd` callback that is triggered
|
|
|
97
97
|
).
|
|
98
98
|
It contains the text, usage information, finish reason, messages, steps, total usage, and more:
|
|
99
99
|
|
|
100
|
-
```tsx highlight="
|
|
100
|
+
```tsx highlight="7-10"
|
|
101
101
|
import { generateText } from 'ai';
|
|
102
102
|
__PROVIDER_IMPORT__;
|
|
103
103
|
|
|
@@ -262,7 +262,7 @@ Errors become part of the stream and are not thrown to prevent e.g. servers from
|
|
|
262
262
|
|
|
263
263
|
To log errors, you can provide an `onError` callback that is triggered when an error occurs.
|
|
264
264
|
|
|
265
|
-
```tsx highlight="
|
|
265
|
+
```tsx highlight="7-9"
|
|
266
266
|
import { streamText } from 'ai';
|
|
267
267
|
__PROVIDER_IMPORT__;
|
|
268
268
|
|
|
@@ -308,7 +308,7 @@ It receives all stream part types from `stream`, including:
|
|
|
308
308
|
- `error`
|
|
309
309
|
- `raw`
|
|
310
310
|
|
|
311
|
-
```tsx highlight="
|
|
311
|
+
```tsx highlight="7-12"
|
|
312
312
|
import { streamText } from 'ai';
|
|
313
313
|
__PROVIDER_IMPORT__;
|
|
314
314
|
|
|
@@ -331,7 +331,7 @@ When using `streamText`, you can provide an `onEnd` callback that is triggered w
|
|
|
331
331
|
).
|
|
332
332
|
It contains the text, usage information, finish reason, messages, steps, total usage, and more:
|
|
333
333
|
|
|
334
|
-
```tsx highlight="
|
|
334
|
+
```tsx highlight="7-10"
|
|
335
335
|
import { streamText } from 'ai';
|
|
336
336
|
__PROVIDER_IMPORT__;
|
|
337
337
|
|
|
@@ -114,7 +114,7 @@ You can consume the structured output on the client with the [`useObject`](/docs
|
|
|
114
114
|
|
|
115
115
|
To handle errors, provide an `onError` callback:
|
|
116
116
|
|
|
117
|
-
```tsx highlight="
|
|
117
|
+
```tsx highlight="6-8"
|
|
118
118
|
import { streamText, Output } from 'ai';
|
|
119
119
|
|
|
120
120
|
const result = streamText({
|
|
@@ -318,7 +318,7 @@ const { output } = await generateText({
|
|
|
318
318
|
|
|
319
319
|
You can add `.describe("...")` to individual schema properties to give the model hints about what each property is for. This helps improve the quality and accuracy of generated structured data:
|
|
320
320
|
|
|
321
|
-
```ts highlight="
|
|
321
|
+
```ts highlight="9,16,19-20"
|
|
322
322
|
import { generateText, Output } from 'ai';
|
|
323
323
|
__PROVIDER_IMPORT__;
|
|
324
324
|
import { z } from 'zod';
|
|
@@ -355,7 +355,7 @@ Property descriptions are particularly useful for:
|
|
|
355
355
|
|
|
356
356
|
You can optionally specify a `name` and `description` for the output. These are used by some providers for additional LLM guidance, e.g. via tool or schema name.
|
|
357
357
|
|
|
358
|
-
```ts highlight="
|
|
358
|
+
```ts highlight="8-9"
|
|
359
359
|
import { generateText, Output } from 'ai';
|
|
360
360
|
__PROVIDER_IMPORT__;
|
|
361
361
|
import { z } from 'zod';
|
|
@@ -20,7 +20,7 @@ Function tools and dynamic tools contain several core elements:
|
|
|
20
20
|
|
|
21
21
|
The `tools` parameter of `generateText` and `streamText` is an object that has the tool names as keys and the tools as values:
|
|
22
22
|
|
|
23
|
-
```ts highlight="
|
|
23
|
+
```ts highlight="7-18"
|
|
24
24
|
import { z } from 'zod';
|
|
25
25
|
import { generateText, tool, isStepCount } from 'ai';
|
|
26
26
|
__PROVIDER_IMPORT__;
|
|
@@ -63,7 +63,7 @@ model for each generation step. It receives the matching tool `context` from
|
|
|
63
63
|
`toolsContext` and the current `experimental_sandbox`, if one was provided. If `prepareStep`
|
|
64
64
|
updates `toolsContext` or `experimental_sandbox`, the next step uses those updated values.
|
|
65
65
|
|
|
66
|
-
```ts highlight="
|
|
66
|
+
```ts highlight="5-16,32-35"
|
|
67
67
|
import { generateText, tool } from 'ai';
|
|
68
68
|
import { z } from 'zod';
|
|
69
69
|
|
|
@@ -413,7 +413,7 @@ In the following example, there are two steps:
|
|
|
413
413
|
1. The tool result is sent to the model.
|
|
414
414
|
1. The model generates a response considering the tool result.
|
|
415
415
|
|
|
416
|
-
```ts highlight="
|
|
416
|
+
```ts highlight="19-20"
|
|
417
417
|
import { z } from 'zod';
|
|
418
418
|
import { generateText, tool, isStepCount } from 'ai';
|
|
419
419
|
__PROVIDER_IMPORT__;
|
|
@@ -447,7 +447,7 @@ It contains all the text, tool calls, tool results, per-step `performance`, and
|
|
|
447
447
|
|
|
448
448
|
#### Example: Extract tool results from all steps
|
|
449
449
|
|
|
450
|
-
```ts highlight="
|
|
450
|
+
```ts highlight="4,10-11"
|
|
451
451
|
import { generateText } from 'ai';
|
|
452
452
|
__PROVIDER_IMPORT__;
|
|
453
453
|
|
|
@@ -772,7 +772,7 @@ It supports the following settings:
|
|
|
772
772
|
- `none`: the model must not call tools
|
|
773
773
|
- `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
|
|
774
774
|
|
|
775
|
-
```ts highlight="
|
|
775
|
+
```ts highlight="19"
|
|
776
776
|
import { z } from 'zod';
|
|
777
777
|
import { generateText, tool } from 'ai';
|
|
778
778
|
__PROVIDER_IMPORT__;
|
|
@@ -877,7 +877,7 @@ const result = await generateText({
|
|
|
877
877
|
The abort signals from `generateText` and `streamText` are forwarded to the tool execution.
|
|
878
878
|
You can access them in the second parameter of the `execute` function and e.g. abort long-running computations or forward them to fetch calls inside tools.
|
|
879
879
|
|
|
880
|
-
```ts highlight="
|
|
880
|
+
```ts highlight="7,12,15"
|
|
881
881
|
import { z } from 'zod';
|
|
882
882
|
import { generateText, tool } from 'ai';
|
|
883
883
|
__PROVIDER_IMPORT__;
|
|
@@ -1047,7 +1047,7 @@ The following tool input lifecycle hooks are available:
|
|
|
1047
1047
|
|
|
1048
1048
|
### Example
|
|
1049
1049
|
|
|
1050
|
-
```ts highlight="
|
|
1050
|
+
```ts highlight="16-24"
|
|
1051
1051
|
import { streamText, tool } from 'ai';
|
|
1052
1052
|
__PROVIDER_IMPORT__;
|
|
1053
1053
|
import { z } from 'zod';
|
|
@@ -1334,7 +1334,7 @@ the AI SDK provides the `activeTools` property.
|
|
|
1334
1334
|
It is an array of tool names that are currently active.
|
|
1335
1335
|
By default, the value is `undefined` and all tools are active.
|
|
1336
1336
|
|
|
1337
|
-
```ts highlight="
|
|
1337
|
+
```ts highlight="8"
|
|
1338
1338
|
import { openai } from '@ai-sdk/openai';
|
|
1339
1339
|
import { generateText } from 'ai';
|
|
1340
1340
|
__PROVIDER_IMPORT__;
|
|
@@ -1357,7 +1357,7 @@ debugging. The list can be partial: tools listed in `toolOrder` are sent first
|
|
|
1357
1357
|
in that order, and any remaining tools are sent afterwards in alphabetical
|
|
1358
1358
|
order. Tool names are typed from your `tools` object.
|
|
1359
1359
|
|
|
1360
|
-
```ts highlight="
|
|
1360
|
+
```ts highlight="7"
|
|
1361
1361
|
import { generateText } from 'ai';
|
|
1362
1362
|
__PROVIDER_IMPORT__;
|
|
1363
1363
|
|
|
@@ -1397,7 +1397,7 @@ that converts the tool result into a content part.
|
|
|
1397
1397
|
|
|
1398
1398
|
Here is an example for converting a screenshot into a content part:
|
|
1399
1399
|
|
|
1400
|
-
```ts highlight="
|
|
1400
|
+
```ts highlight="23-38"
|
|
1401
1401
|
const result = await generateText({
|
|
1402
1402
|
model: __MODEL__,
|
|
1403
1403
|
tools: {
|
|
@@ -7,7 +7,7 @@ description: Learn how to configure the AI SDK.
|
|
|
7
7
|
|
|
8
8
|
Large language models (LLMs) typically provide settings to augment their output.
|
|
9
9
|
|
|
10
|
-
All AI SDK functions support the following common settings in addition to the model, the [prompt](
|
|
10
|
+
All AI SDK functions support the following common settings in addition to the model, the [prompt](/docs/foundations/prompts), and additional provider-specific settings:
|
|
11
11
|
|
|
12
12
|
```ts highlight="3-6"
|
|
13
13
|
const result = await generateText({
|
|
@@ -109,7 +109,7 @@ Google's `gemini-embedding-2` model (also available as `gemini-embedding-2-previ
|
|
|
109
109
|
|
|
110
110
|
The `embedMany` function now supports parallel processing with configurable `maxParallelCalls` to optimize performance:
|
|
111
111
|
|
|
112
|
-
```ts highlight={"
|
|
112
|
+
```ts highlight={"4"}
|
|
113
113
|
import { embedMany } from 'ai';
|
|
114
114
|
|
|
115
115
|
const { embeddings, usage } = await embedMany({
|
|
@@ -101,7 +101,7 @@ Each item in the `ranking` array contains:
|
|
|
101
101
|
|
|
102
102
|
Use `topN` to limit the number of results returned. This is useful for retrieving only the most relevant documents:
|
|
103
103
|
|
|
104
|
-
```ts highlight={"
|
|
104
|
+
```ts highlight={"8"}
|
|
105
105
|
import { cohere } from '@ai-sdk/cohere';
|
|
106
106
|
import { rerank } from 'ai';
|
|
107
107
|
|
|
@@ -139,7 +139,7 @@ The `rerank` function accepts an optional `maxRetries` parameter of type `number
|
|
|
139
139
|
that you can use to set the maximum number of retries for the reranking process.
|
|
140
140
|
It defaults to `2` retries (3 attempts in total). You can set it to `0` to disable retries.
|
|
141
141
|
|
|
142
|
-
```ts highlight={"
|
|
142
|
+
```ts highlight={"8"}
|
|
143
143
|
import { cohere } from '@ai-sdk/cohere';
|
|
144
144
|
import { rerank } from 'ai';
|
|
145
145
|
|
|
@@ -157,7 +157,7 @@ The `rerank` function accepts an optional `abortSignal` parameter of
|
|
|
157
157
|
type [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
|
158
158
|
that you can use to abort the reranking process or set a timeout.
|
|
159
159
|
|
|
160
|
-
```ts highlight={"
|
|
160
|
+
```ts highlight={"8"}
|
|
161
161
|
import { cohere } from '@ai-sdk/cohere';
|
|
162
162
|
import { rerank } from 'ai';
|
|
163
163
|
|
|
@@ -174,7 +174,7 @@ const { ranking } = await rerank({
|
|
|
174
174
|
The `rerank` function accepts an optional `headers` parameter of type `Record<string, string>`
|
|
175
175
|
that you can use to add custom headers to the reranking request.
|
|
176
176
|
|
|
177
|
-
```ts highlight={"
|
|
177
|
+
```ts highlight={"8"}
|
|
178
178
|
import { cohere } from '@ai-sdk/cohere';
|
|
179
179
|
import { rerank } from 'ai';
|
|
180
180
|
|
|
@@ -119,7 +119,7 @@ You can pass such settings to the `generateImage` function
|
|
|
119
119
|
using the `providerOptions` parameter. The options for the provider
|
|
120
120
|
(`openai` in the example below) become request body properties.
|
|
121
121
|
|
|
122
|
-
```tsx highlight={"
|
|
122
|
+
```tsx highlight={"8-13"}
|
|
123
123
|
import { generateImage } from 'ai';
|
|
124
124
|
import { openai, type OpenAIImageModelGenerationOptions } from '@ai-sdk/openai';
|
|
125
125
|
|
|
@@ -98,7 +98,11 @@ The `audio` stream must contain raw audio chunks. `Uint8Array` chunks are raw by
|
|
|
98
98
|
the provider.
|
|
99
99
|
</Note>
|
|
100
100
|
|
|
101
|
-
OpenAI streaming transcription uses `openai.transcription('gpt-realtime-whisper')`.
|
|
101
|
+
OpenAI streaming transcription uses `openai.transcription('gpt-realtime-whisper')`.
|
|
102
|
+
Cartesia uses `cartesia.transcription('ink-2')` for streaming-only Ink 2
|
|
103
|
+
transcription. xAI uses the same `xai.transcription()` model for request/response
|
|
104
|
+
and streaming transcription; `experimental_streamTranscribe` selects the
|
|
105
|
+
provider's WebSocket STT transport.
|
|
102
106
|
|
|
103
107
|
```ts
|
|
104
108
|
import { xai } from '@ai-sdk/xai';
|
|
@@ -150,7 +154,7 @@ const transcript = await transcribe({
|
|
|
150
154
|
When `audio` is a URL, the SDK downloads the file with a default **2 GiB** size limit.
|
|
151
155
|
You can customize this using `createDownload`:
|
|
152
156
|
|
|
153
|
-
```ts highlight="1,
|
|
157
|
+
```ts highlight="1,7"
|
|
154
158
|
import { transcribe, createDownload } from 'ai';
|
|
155
159
|
import { openai } from '@ai-sdk/openai';
|
|
156
160
|
|
|
@@ -163,7 +167,7 @@ const transcript = await transcribe({
|
|
|
163
167
|
|
|
164
168
|
You can also provide a fully custom download function:
|
|
165
169
|
|
|
166
|
-
```ts highlight="
|
|
170
|
+
```ts highlight="7-13"
|
|
167
171
|
import { transcribe } from 'ai';
|
|
168
172
|
import { openai } from '@ai-sdk/openai';
|
|
169
173
|
|
|
@@ -206,7 +210,7 @@ that you can use to abort the transcription process or set a timeout.
|
|
|
206
210
|
|
|
207
211
|
This is particularly useful when combined with URL downloads to prevent long-running requests:
|
|
208
212
|
|
|
209
|
-
```ts highlight="
|
|
213
|
+
```ts highlight="7"
|
|
210
214
|
import { openai } from '@ai-sdk/openai';
|
|
211
215
|
import { transcribe } from 'ai';
|
|
212
216
|
|
|
@@ -316,5 +320,6 @@ try {
|
|
|
316
320
|
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models) | `telephony` |
|
|
317
321
|
| [xAI](/providers/ai-sdk-providers/xai#transcription-models) | `default` |
|
|
318
322
|
| [Cartesia](/providers/ai-sdk-providers/cartesia#transcription-models) | `ink-whisper` |
|
|
323
|
+
| [Cartesia](/providers/ai-sdk-providers/cartesia#streaming-transcription-models) | `ink-2` |
|
|
319
324
|
|
|
320
325
|
Above are a small subset of the transcription models supported by the AI SDK providers. For more, see the respective provider documentation.
|
|
@@ -151,6 +151,7 @@ try {
|
|
|
151
151
|
| [OpenAI](/providers/ai-sdk-providers/openai#speech-models) | `tts-1` |
|
|
152
152
|
| [OpenAI](/providers/ai-sdk-providers/openai#speech-models) | `tts-1-hd` |
|
|
153
153
|
| [OpenAI](/providers/ai-sdk-providers/openai#speech-models) | `gpt-4o-mini-tts` |
|
|
154
|
+
| [Mistral](/providers/ai-sdk-providers/mistral#speech-models) | `voxtral-mini-tts-2603` |
|
|
154
155
|
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#speech-models) | `eleven_v3` |
|
|
155
156
|
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#speech-models) | `eleven_multilingual_v2` |
|
|
156
157
|
| [ElevenLabs](/providers/ai-sdk-providers/elevenlabs#speech-models) | `eleven_flash_v2_5` |
|
|
@@ -146,7 +146,7 @@ const { videos } = await generateVideo({
|
|
|
146
146
|
|
|
147
147
|
Some video models support generating videos from an input image. You can provide an image using the prompt object:
|
|
148
148
|
|
|
149
|
-
```tsx highlight={"
|
|
149
|
+
```tsx highlight={"6-9"}
|
|
150
150
|
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
151
151
|
__PROVIDER_IMPORT__;
|
|
152
152
|
|
|
@@ -177,7 +177,7 @@ Some video models support first-last-frame generation, where you provide the
|
|
|
177
177
|
starting and/or ending frames of the video. Use the `frameImages` option to pass
|
|
178
178
|
role-tagged images in a provider-agnostic way:
|
|
179
179
|
|
|
180
|
-
```tsx highlight={"
|
|
180
|
+
```tsx highlight={"4-13"}
|
|
181
181
|
const { video } = await generateVideo({
|
|
182
182
|
model: __VIDEO_MODEL__,
|
|
183
183
|
prompt: 'The cat walks across the scene and transforms into a dog by the end',
|
|
@@ -200,7 +200,7 @@ Some video models support reference-to-video generation, where you provide one o
|
|
|
200
200
|
more reference images or videos that the model incorporates into the generated video. Use the `inputReferences` option to pass
|
|
201
201
|
these inputs in a provider-agnostic way:
|
|
202
202
|
|
|
203
|
-
```tsx highlight={"
|
|
203
|
+
```tsx highlight={"4-7"}
|
|
204
204
|
const { video } = await generateVideo({
|
|
205
205
|
model: __VIDEO_MODEL__,
|
|
206
206
|
prompt: 'The two characters meet in a bustling market',
|
|
@@ -213,7 +213,7 @@ const { video } = await generateVideo({
|
|
|
213
213
|
|
|
214
214
|
For URL-based video references, use the object form with an explicit `mediaType`:
|
|
215
215
|
|
|
216
|
-
```tsx highlight={"
|
|
216
|
+
```tsx highlight={"4-9"}
|
|
217
217
|
const { video } = await generateVideo({
|
|
218
218
|
model: __VIDEO_MODEL__,
|
|
219
219
|
prompt: 'Match the motion in the reference clip',
|
|
@@ -295,7 +295,7 @@ Video generation is an asynchronous process that can take several minutes to com
|
|
|
295
295
|
|
|
296
296
|
You can configure the polling timeout using provider-specific options. Each provider exports a type for its options that you can use with `satisfies` for type safety:
|
|
297
297
|
|
|
298
|
-
```tsx highlight={"
|
|
298
|
+
```tsx highlight={"8-12"}
|
|
299
299
|
import { experimental_generateVideo as generateVideo } from 'ai';
|
|
300
300
|
import { fal, type FalVideoModelOptions } from '@ai-sdk/fal';
|
|
301
301
|
|
|
@@ -9,7 +9,7 @@ description: Learn how to handle errors in the AI SDK Core
|
|
|
9
9
|
|
|
10
10
|
Regular errors are thrown and can be handled using the `try/catch` block.
|
|
11
11
|
|
|
12
|
-
```ts highlight="
|
|
12
|
+
```ts highlight="4,9-11"
|
|
13
13
|
import { generateText } from 'ai';
|
|
14
14
|
__PROVIDER_IMPORT__;
|
|
15
15
|
|
|
@@ -31,7 +31,7 @@ When errors occur during streams that do not support error chunks,
|
|
|
31
31
|
the error is thrown as a regular error.
|
|
32
32
|
You can handle these errors using the `try/catch` block.
|
|
33
33
|
|
|
34
|
-
```ts highlight="
|
|
34
|
+
```ts highlight="4,13-15"
|
|
35
35
|
import { streamText } from 'ai';
|
|
36
36
|
__PROVIDER_IMPORT__;
|
|
37
37
|
|
|
@@ -56,7 +56,7 @@ You can handle those parts similar to other parts.
|
|
|
56
56
|
It is recommended to also add a try-catch block for errors that
|
|
57
57
|
happen outside of the streaming.
|
|
58
58
|
|
|
59
|
-
```ts highlight="
|
|
59
|
+
```ts highlight="14-22"
|
|
60
60
|
import { streamText } from 'ai';
|
|
61
61
|
__PROVIDER_IMPORT__;
|
|
62
62
|
|
|
@@ -99,7 +99,7 @@ When streams are aborted (e.g., via chat stop button), you may want to perform c
|
|
|
99
99
|
|
|
100
100
|
The `onAbort` callback is called when a stream is aborted via `AbortSignal`, but `onEnd` is not called. This ensures you can still update your UI state appropriately.
|
|
101
101
|
|
|
102
|
-
```ts highlight="
|
|
102
|
+
```ts highlight="6-10"
|
|
103
103
|
import { streamText } from 'ai';
|
|
104
104
|
__PROVIDER_IMPORT__;
|
|
105
105
|
|
|
@@ -127,7 +127,7 @@ The `onAbort` callback receives:
|
|
|
127
127
|
|
|
128
128
|
You can also handle abort events directly in the stream:
|
|
129
129
|
|
|
130
|
-
```ts highlight="
|
|
130
|
+
```ts highlight="11-14"
|
|
131
131
|
import { streamText } from 'ai';
|
|
132
132
|
__PROVIDER_IMPORT__;
|
|
133
133
|
|
|
@@ -181,7 +181,7 @@ const result = streamText({
|
|
|
181
181
|
|
|
182
182
|
### Simulate UI Message Stream Responses
|
|
183
183
|
|
|
184
|
-
You can also simulate [UI Message Stream](/docs/ai-sdk-ui/stream-protocol#ui-message-stream) responses for testing,
|
|
184
|
+
You can also simulate [UI Message Stream](/docs/ai-sdk-ui/stream-protocol#ui-message-stream-example) responses for testing,
|
|
185
185
|
debugging, or demonstration purposes.
|
|
186
186
|
|
|
187
187
|
Here is a Next example:
|
|
@@ -55,7 +55,7 @@ Because callbacks run as part of the lifecycle, keep them fast or enqueue expens
|
|
|
55
55
|
Use `onStart` and `onEnd` to record one application log for the beginning and end of a call.
|
|
56
56
|
The `callId` is available across lifecycle events, so you can correlate logs from the same request.
|
|
57
57
|
|
|
58
|
-
```tsx highlight="8-
|
|
58
|
+
```tsx highlight="8-23"
|
|
59
59
|
import { generateText } from 'ai';
|
|
60
60
|
__PROVIDER_IMPORT__;
|
|
61
61
|
|
|
@@ -124,7 +124,7 @@ Use step events when you want timing that includes SDK-managed work such as loca
|
|
|
124
124
|
When you use tools with `generateText` or `streamText`, a single user request can involve multiple model calls.
|
|
125
125
|
Each model call is a step. The model may call a tool in one step, receive the tool result, and then produce a final answer in the next step.
|
|
126
126
|
|
|
127
|
-
```tsx highlight="
|
|
127
|
+
```tsx highlight="17-31"
|
|
128
128
|
import { generateText, isStepCount, tool } from 'ai';
|
|
129
129
|
import { z } from 'zod';
|
|
130
130
|
__PROVIDER_IMPORT__;
|
|
@@ -171,7 +171,7 @@ This helps answer questions such as:
|
|
|
171
171
|
Tool execution callbacks run around the tool's `execute` function.
|
|
172
172
|
Use them to record tool usage, latency, successful results, and tool errors.
|
|
173
173
|
|
|
174
|
-
```tsx highlight="
|
|
174
|
+
```tsx highlight="19-36"
|
|
175
175
|
import { generateText, tool } from 'ai';
|
|
176
176
|
import { z } from 'zod';
|
|
177
177
|
__PROVIDER_IMPORT__;
|
|
@@ -218,7 +218,7 @@ const result = await generateText({
|
|
|
218
218
|
Embedding and reranking callbacks are simpler: they expose `onStart` and `onEnd` around the operation.
|
|
219
219
|
This is useful for retrieval pipelines where you want to understand how often you are embedding, how many values you embed, and how reranking changes result sets.
|
|
220
220
|
|
|
221
|
-
```tsx highlight="10-
|
|
221
|
+
```tsx highlight="10-24,32-37"
|
|
222
222
|
import { embedMany, rerank } from 'ai';
|
|
223
223
|
import { cohere } from '@ai-sdk/cohere';
|
|
224
224
|
|
|
@@ -293,7 +293,7 @@ This distinction matters when the step includes local tool execution: the step d
|
|
|
293
293
|
Lifecycle callbacks receive the full `runtimeContext` and `toolsContext` values that flow through the call.
|
|
294
294
|
This makes callbacks useful for attaching application context without changing prompts or tool inputs.
|
|
295
295
|
|
|
296
|
-
```tsx highlight="8-
|
|
296
|
+
```tsx highlight="8-24,26-39"
|
|
297
297
|
import { generateText, tool } from 'ai';
|
|
298
298
|
import { z } from 'zod';
|
|
299
299
|
__PROVIDER_IMPORT__;
|
|
@@ -1092,8 +1092,8 @@ By using `FileList`, you can send multiple files as attachments along with a mes
|
|
|
1092
1092
|
<Note>
|
|
1093
1093
|
Currently, only `image/*` and `text/*` content types get automatically
|
|
1094
1094
|
converted into [multi-modal content
|
|
1095
|
-
parts](/docs/foundations/prompts#
|
|
1096
|
-
|
|
1095
|
+
parts](/docs/foundations/prompts#file-parts). You will need to handle other
|
|
1096
|
+
content types manually.
|
|
1097
1097
|
</Note>
|
|
1098
1098
|
|
|
1099
1099
|
```tsx filename="app/page.tsx"
|
|
@@ -96,7 +96,7 @@ When processing messages on the server that contain tool calls, custom metadata,
|
|
|
96
96
|
|
|
97
97
|
When your messages include tool calls, validate them against your tool definitions:
|
|
98
98
|
|
|
99
|
-
```tsx filename="app/api/chat/route.ts" highlight="
|
|
99
|
+
```tsx filename="app/api/chat/route.ts" highlight="7-8,14-27,35-45"
|
|
100
100
|
import {
|
|
101
101
|
convertToModelMessages,
|
|
102
102
|
createUIMessageStreamResponse,
|
|
@@ -286,7 +286,7 @@ export default function Chat({
|
|
|
286
286
|
|
|
287
287
|
When loading messages from storage that contain tools, metadata, or custom data
|
|
288
288
|
parts, validate them using `validateUIMessages` before processing (see the
|
|
289
|
-
[validation section](#validating-messages-
|
|
289
|
+
[validation section](#validating-messages-on-the-server) above).
|
|
290
290
|
|
|
291
291
|
</Note>
|
|
292
292
|
|
|
@@ -416,7 +416,7 @@ export async function POST(req: Request) {
|
|
|
416
416
|
|
|
417
417
|
Alternatively, you can use `createUIMessageStream` to control the message ID by writing a start message part:
|
|
418
418
|
|
|
419
|
-
```tsx filename="app/api/chat/route.ts" highlight="
|
|
419
|
+
```tsx filename="app/api/chat/route.ts" highlight="14-18,25-27"
|
|
420
420
|
import {
|
|
421
421
|
generateId,
|
|
422
422
|
streamText,
|
|
@@ -124,7 +124,7 @@ export async function POST(req: Request) {
|
|
|
124
124
|
<Note>
|
|
125
125
|
You can also send stream data from custom backends, e.g. Python / FastAPI,
|
|
126
126
|
using the [UI Message Stream
|
|
127
|
-
Protocol](/docs/ai-sdk-ui/stream-protocol#
|
|
127
|
+
Protocol](/docs/ai-sdk-ui/stream-protocol#data-stream-protocol).
|
|
128
128
|
</Note>
|
|
129
129
|
|
|
130
130
|
## Types of Streamable Data
|
|
@@ -25,7 +25,7 @@ Due to these limitations, AI SDK RSC is marked as experimental, and we do not re
|
|
|
25
25
|
|
|
26
26
|
As a result, we strongly recommend migrating to AI SDK UI, which has undergone extensive development to provide a more stable and production grade experience.
|
|
27
27
|
|
|
28
|
-
In building [v0](https://v0.dev), we have invested considerable time exploring how to create the best chat experience on the web. AI SDK UI ships with many of these best practices and commonly used patterns like [language model middleware](/docs/ai-sdk-core/middleware), [multi-step tool calls](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls), [attachments](/docs/ai-sdk-ui/chatbot#attachments
|
|
28
|
+
In building [v0](https://v0.dev), we have invested considerable time exploring how to create the best chat experience on the web. AI SDK UI ships with many of these best practices and commonly used patterns like [language model middleware](/docs/ai-sdk-core/middleware), [multi-step tool calls](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls-using-stopwhen), [attachments](/docs/ai-sdk-ui/chatbot#attachments), [telemetry](/docs/ai-sdk-core/telemetry), [provider registry](/docs/ai-sdk-core/provider-management#provider-registry), and many more. These features have been considerately designed into a neat abstraction that you can use to reliably integrate AI into your applications.
|
|
29
29
|
|
|
30
30
|
## Streaming Chat Completions
|
|
31
31
|
|
|
@@ -112,7 +112,7 @@ export const cacheMiddleware: LanguageModelV4Middleware = {
|
|
|
112
112
|
|
|
113
113
|
`LanguageModelV4Middleware` has two methods: `wrapGenerate` and `wrapStream`. `wrapGenerate` is called when using [`generateText`](/docs/reference/ai-sdk-core/generate-text), while `wrapStream` is called when using [`streamText`](/docs/reference/ai-sdk-core/stream-text).
|
|
114
114
|
|
|
115
|
-
For `wrapGenerate`, you can cache the response directly. Instead, for `wrapStream`, you cache an array of the stream parts, which can then be used with [`simulateReadableStream`](/docs/ai-sdk-core/testing#simulate-
|
|
115
|
+
For `wrapGenerate`, you can cache the response directly. Instead, for `wrapStream`, you cache an array of the stream parts, which can then be used with [`simulateReadableStream`](/docs/ai-sdk-core/testing#simulate-ui-message-stream-responses) function to create a simulated `ReadableStream` that returns the cached response. In this way, the cached response is returned chunk-by-chunk as if it were being generated by the model. You can control the initial delay and delay between chunks by adjusting the `initialDelayInMs` and `chunkDelayInMs` parameters of `simulateReadableStream`.
|
|
116
116
|
|
|
117
117
|
You can see a full example of caching with Redis in a Next.js application in our [Caching Middleware Recipe](/cookbook/next/caching-middleware).
|
|
118
118
|
|
|
@@ -14,7 +14,7 @@ The `dynamicTool` function creates tools where the input and output types are no
|
|
|
14
14
|
|
|
15
15
|
Unlike the regular `tool` function, `dynamicTool` accepts and returns `unknown` types, allowing you to work with tools that have runtime-determined schemas.
|
|
16
16
|
|
|
17
|
-
```ts highlight={"1,4,9,
|
|
17
|
+
```ts highlight={"1,4,9,11"}
|
|
18
18
|
import { dynamicTool } from 'ai';
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
|
|
@@ -5,7 +5,7 @@ description: API Reference for safeValidateUIMessages
|
|
|
5
5
|
|
|
6
6
|
# `safeValidateUIMessages`
|
|
7
7
|
|
|
8
|
-
`safeValidateUIMessages` is an async function that validates UI messages like [`validateUIMessages`](
|
|
8
|
+
`safeValidateUIMessages` is an async function that validates UI messages like [`validateUIMessages`](/docs/reference/ai-sdk-core/validate-ui-messages), but instead of throwing it returns an object with a `success` key and either `data` or `error`.
|
|
9
9
|
|
|
10
10
|
## Basic Usage
|
|
11
11
|
|
|
@@ -111,11 +111,6 @@ It also contains the following helper functions:
|
|
|
111
111
|
description: 'Creates a client for connecting to MCP servers.',
|
|
112
112
|
href: '/docs/reference/ai-sdk-core/create-mcp-client',
|
|
113
113
|
},
|
|
114
|
-
{
|
|
115
|
-
title: 'validateJSONRPCMessage()',
|
|
116
|
-
description: 'Validates unknown values as MCP JSON-RPC messages.',
|
|
117
|
-
href: '/docs/reference/ai-sdk-core/validate-json-rpc-message',
|
|
118
|
-
},
|
|
119
114
|
{
|
|
120
115
|
title: 'MCP Apps',
|
|
121
116
|
description:
|
|
@@ -5,9 +5,9 @@ description: API Reference for the runAgentTUI function.
|
|
|
5
5
|
|
|
6
6
|
# `runAgentTUI()`
|
|
7
7
|
|
|
8
|
-
Runs a
|
|
9
|
-
prompts, streams assistant responses, renders markdown,
|
|
10
|
-
reasoning sections, and handles manual tool approvals.
|
|
8
|
+
Runs a local agent or chat transport in an interactive terminal UI. The
|
|
9
|
+
terminal UI reads user prompts, streams assistant responses, renders markdown,
|
|
10
|
+
displays tool and reasoning sections, and handles manual tool approvals.
|
|
11
11
|
|
|
12
12
|
`runAgentTUI` runs until the user exits with `Esc` or `Ctrl+C`.
|
|
13
13
|
|
|
@@ -49,9 +49,16 @@ await runAgentTUI({
|
|
|
49
49
|
{
|
|
50
50
|
name: 'agent',
|
|
51
51
|
type: 'AgentTUIAgent',
|
|
52
|
-
|
|
52
|
+
isOptional: true,
|
|
53
|
+
description:
|
|
54
|
+
'The agent to run. Provide exactly one of `agent` or `transport`. The agent must not require per-call options and must not use structured output.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'transport',
|
|
58
|
+
type: 'ChatTransport<UIMessage>',
|
|
59
|
+
isOptional: true,
|
|
53
60
|
description:
|
|
54
|
-
'The
|
|
61
|
+
'The transport used to communicate with a remote agent. Provide exactly one of `agent` or `transport`.',
|
|
55
62
|
},
|
|
56
63
|
{
|
|
57
64
|
name: 'title',
|
|
@@ -168,6 +175,19 @@ await runAgentTUI({
|
|
|
168
175
|
});
|
|
169
176
|
```
|
|
170
177
|
|
|
178
|
+
## Example with a Chat Transport
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import { DefaultChatTransport } from 'ai';
|
|
182
|
+
|
|
183
|
+
await runAgentTUI({
|
|
184
|
+
title: 'Remote Assistant',
|
|
185
|
+
transport: new DefaultChatTransport({
|
|
186
|
+
api: 'https://example.com/api/chat',
|
|
187
|
+
}),
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
171
191
|
## Example with Sandbox
|
|
172
192
|
|
|
173
193
|
```ts
|
|
@@ -192,8 +212,9 @@ working directory or exposed ports.
|
|
|
192
212
|
|
|
193
213
|
## Compatibility
|
|
194
214
|
|
|
195
|
-
Use `
|
|
196
|
-
Use `
|
|
215
|
+
Use the `agent` option for agents that can run directly from free-form user
|
|
216
|
+
input. Use the `transport` option to communicate with a remote agent. Use
|
|
217
|
+
`agent.generate()` or `agent.stream()` directly when you need fixed prompts,
|
|
197
218
|
per-call options, structured output, custom result inspection, or custom stream
|
|
198
219
|
processing.
|
|
199
220
|
|
|
@@ -201,4 +222,4 @@ processing.
|
|
|
201
222
|
|
|
202
223
|
- [Terminal UI guide](/docs/agents/terminal-ui)
|
|
203
224
|
- [Building Agents](/docs/agents/building-agents)
|
|
204
|
-
- [ToolLoopAgent guide](/docs/agents/overview#
|
|
225
|
+
- [ToolLoopAgent guide](/docs/agents/overview#toolloopagent-class)
|
|
@@ -817,7 +817,7 @@ The following options have been removed from the `useChat` hook:
|
|
|
817
817
|
- `maxAutomaticRoundtrips`
|
|
818
818
|
- `maxToolRoundtrips`
|
|
819
819
|
|
|
820
|
-
Please use the [`maxSteps`](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls) option instead.
|
|
820
|
+
Please use the [`maxSteps`](/docs/ai-sdk-core/tools-and-tool-calling#multi-step-calls-using-stopwhen) option instead.
|
|
821
821
|
The value of `maxSteps` is equal to roundtrips + 1.
|
|
822
822
|
|
|
823
823
|
```ts filename="AI SDK 3.4"
|
|
@@ -20,7 +20,7 @@ introducing significant improvements and new features across the AI SDK and its
|
|
|
20
20
|
|
|
21
21
|
### Open Telemetry Support
|
|
22
22
|
|
|
23
|
-
- Added experimental [OpenTelemetry support](/docs/ai-sdk-core/telemetry
|
|
23
|
+
- Added experimental [OpenTelemetry support](/docs/ai-sdk-core/telemetry) for all [AI SDK Core functions](/docs/ai-sdk-core/overview#ai-sdk-core-functions), enabling better observability and tracing capabilities.
|
|
24
24
|
|
|
25
25
|
### AI SDK UI Improvements
|
|
26
26
|
|
|
@@ -129,7 +129,7 @@ async function submitMessage(userInput = 'What is the weather in SF?') {
|
|
|
129
129
|
}
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
With the new [`streamUI`](/docs/reference/ai-sdk-rsc/stream-ui) function, you can now use any compatible AI SDK provider. In this example, you import the AI SDK OpenAI provider. Then, you pass it to the [`model`](/docs/reference/ai-sdk-rsc/stream-ui#model) key of the new [`streamUI`](/docs/reference/ai-sdk-rsc/stream-ui) function. Finally, you declare a tool and return a React Server Component, defined in the [`generate`](/docs/reference/ai-sdk-rsc/stream-ui#tools
|
|
132
|
+
With the new [`streamUI`](/docs/reference/ai-sdk-rsc/stream-ui) function, you can now use any compatible AI SDK provider. In this example, you import the AI SDK OpenAI provider. Then, you pass it to the [`model`](/docs/reference/ai-sdk-rsc/stream-ui#model) key of the new [`streamUI`](/docs/reference/ai-sdk-rsc/stream-ui) function. Finally, you declare a tool and return a React Server Component, defined in the [`generate`](/docs/reference/ai-sdk-rsc/stream-ui#tools.tool.generate) key of the tool.
|
|
133
133
|
|
|
134
134
|
```tsx
|
|
135
135
|
import { streamUI } from '@ai-sdk/rsc';
|
|
@@ -45,4 +45,4 @@ const result = await generateText({
|
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
For more information about using structured outputs with `generateText` and `streamText` see [Generating Structured Data](/docs/ai-sdk-core/generating-structured-data#structured-outputs
|
|
48
|
+
For more information about using structured outputs with `generateText` and `streamText` see [Generating Structured Data](/docs/ai-sdk-core/generating-structured-data#generating-structured-outputs).
|
|
@@ -19,7 +19,7 @@ Errors become part of the stream and are not thrown to prevent e.g. servers from
|
|
|
19
19
|
|
|
20
20
|
To log errors, you can provide an `onError` callback that is triggered when an error occurs.
|
|
21
21
|
|
|
22
|
-
```tsx highlight="
|
|
22
|
+
```tsx highlight="7-9"
|
|
23
23
|
import { streamText } from 'ai';
|
|
24
24
|
__PROVIDER_IMPORT__;
|
|
25
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.21",
|
|
46
46
|
"@ai-sdk/provider": "4.0.3",
|
|
47
47
|
"@ai-sdk/provider-utils": "5.0.10"
|
|
48
48
|
},
|