Skip to content

Commit 3c5fafa

Browse files
authored
chore (ai/core): move streamText toolCallStreaming option to stable (#4493)
1 parent 6f4d063 commit 3c5fafa

File tree

10 files changed

+25
-16
lines changed

10 files changed

+25
-16
lines changed

.changeset/lucky-garlics-jog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
chore (ai/core): move streamText toolCallStreaming option to stable

content/docs/03-ai-sdk-core/05-generating-text.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ It receives the following chunk types:
104104
- `reasoning`
105105
- `tool-call`
106106
- `tool-result`
107-
- `tool-call-streaming-start` (when `experimental_toolCallStreaming` is enabled)
108-
- `tool-call-delta` (when `experimental_toolCallStreaming` is enabled)
107+
- `tool-call-streaming-start` (when `toolCallStreaming` is enabled)
108+
- `tool-call-delta` (when `toolCallStreaming` is enabled)
109109

110110
```tsx highlight="6-11"
111111
import { streamText } from 'ai';

content/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,15 @@ export default function Chat() {
192192

193193
## Tool call streaming
194194

195-
<Note type="warning">This feature is experimental.</Note>
196-
197195
You can stream tool calls while they are being generated by enabling the
198-
`experimental_toolCallStreaming` option in `streamText`.
196+
`toolCallStreaming` option in `streamText`.
199197

200198
```tsx filename='app/api/chat/route.ts' highlight="5"
201199
export async function POST(req: Request) {
202200
// ...
203201

204202
const result = streamText({
205-
experimental_toolCallStreaming: true,
203+
toolCallStreaming: true,
206204
// ...
207205
});
208206

content/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ To see `streamText` in action, check out [these examples](#examples).
470470
],
471471
},
472472
{
473-
name: 'experimental_toolCallStreaming',
473+
name: 'toolCallStreaming',
474474
type: 'boolean',
475475
isOptional: true,
476476
description:

examples/ai-core/src/stream-text/openai-on-chunk-tool-call-streaming.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function main() {
1313
parameters: z.object({ city: z.string() }),
1414
},
1515
},
16-
experimental_toolCallStreaming: true,
16+
toolCallStreaming: true,
1717
onChunk(chunk) {
1818
console.log('onChunk', chunk);
1919
},

examples/next-openai/app/api/use-chat-streaming-tool-calls/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function POST(req: Request) {
1111
const result = streamText({
1212
model: openai('gpt-4-turbo'),
1313
messages,
14-
experimental_toolCallStreaming: true,
14+
toolCallStreaming: true,
1515
system:
1616
'You are a helpful assistant that answers questions about the weather in a given city.' +
1717
'You use the showWeatherInformation tool to show the weather information to the user instead of talking about it.',

examples/next-openai/app/api/use-chat-tools/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function POST(req: Request) {
1111
const result = streamText({
1212
model: openai('gpt-4o'),
1313
messages,
14-
experimental_toolCallStreaming: true,
14+
toolCallStreaming: true,
1515
maxSteps: 5, // multi-steps for server-side tools
1616
tools: {
1717
// server-side tool with execute function:

examples/nuxt-openai/server/api/use-chat-tools.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default defineLazyEventHandler(async () => {
1313
const result = streamText({
1414
model: openai('gpt-4-turbo'),
1515
messages,
16-
experimental_toolCallStreaming: true,
16+
toolCallStreaming: true,
1717
maxSteps: 5, // multi-steps for server-side tools
1818
tools: {
1919
// server-side tool with execute function:

packages/ai/core/generate-text/stream-text.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ describe('streamText', () => {
526526

527527
it('should send tool call deltas when toolCallStreaming is enabled', async () => {
528528
const result = streamText({
529-
experimental_toolCallStreaming: true,
529+
toolCallStreaming: true,
530530
model: createTestModel({
531531
stream: convertArrayToReadableStream([
532532
{
@@ -1108,7 +1108,7 @@ describe('streamText', () => {
11081108
},
11091109
},
11101110
prompt: 'test-input',
1111-
experimental_toolCallStreaming: true,
1111+
toolCallStreaming: true,
11121112
experimental_generateMessageId: mockId({ prefix: 'msg' }),
11131113
});
11141114

@@ -1826,7 +1826,7 @@ describe('streamText', () => {
18261826
},
18271827
},
18281828
prompt: 'test-input',
1829-
experimental_toolCallStreaming: true,
1829+
toolCallStreaming: true,
18301830
onChunk(event) {
18311831
result.push(event.chunk);
18321832
},
@@ -3800,7 +3800,7 @@ describe('streamText', () => {
38003800
},
38013801
},
38023802
prompt: 'test-input',
3803-
experimental_toolCallStreaming: true,
3803+
toolCallStreaming: true,
38043804
onChunk(event) {
38053805
result.push(event.chunk);
38063806
},

packages/ai/core/generate-text/stream-text.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export function streamText<
145145
experimental_continueSteps: continueSteps = false,
146146
experimental_telemetry: telemetry,
147147
experimental_providerMetadata: providerMetadata,
148-
experimental_toolCallStreaming: toolCallStreaming = false,
148+
experimental_toolCallStreaming = false,
149+
toolCallStreaming = experimental_toolCallStreaming,
149150
experimental_activeTools: activeTools,
150151
experimental_repairToolCall: repairToolCall,
151152
experimental_transform: transform,
@@ -227,6 +228,11 @@ A function that attempts to repair a tool call that failed to parse.
227228
/**
228229
Enable streaming of tool call deltas as they are generated. Disabled by default.
229230
*/
231+
toolCallStreaming?: boolean;
232+
233+
/**
234+
@deprecated Use `toolCallStreaming` instead.
235+
*/
230236
experimental_toolCallStreaming?: boolean;
231237

232238
/**

0 commit comments

Comments
 (0)