You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core-concepts/streaming-output.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,11 @@ function ChatComponent() {
179
179
setIsComplete(false);
180
180
},
181
181
182
+
'.step_start': (data) => {
183
+
console.log('Step started:', data);
184
+
// A new generation cycle is beginning
185
+
},
186
+
182
187
'.text_start': (data) => {
183
188
console.log('Text start event received:', data);
184
189
setCurrentMessage('');
@@ -202,6 +207,11 @@ function ChatComponent() {
202
207
console.log('Tool result:', data.result);
203
208
},
204
209
210
+
'.step_finish': (data) => {
211
+
console.log('Step finished:', data);
212
+
// Generation cycle complete, may be followed by another step
213
+
},
214
+
205
215
'.stream_end': (data) => {
206
216
console.log('Stream ended:', data.finish_reason);
207
217
setIsComplete(true);
@@ -246,6 +256,7 @@ All streaming approaches emit the same core events with consistent data structur
246
256
### Available Events
247
257
248
258
-**`stream_start`** - Stream initialization with model and provider info
259
+
-**`step_start`** - Beginning of a generation step (emitted before each AI response cycle)
249
260
-**`text_start`** - Beginning of a text message
250
261
-**`text_delta`** - Incremental text chunks as they're generated
251
262
-**`text_complete`** - End of a complete text message
@@ -257,9 +268,13 @@ All streaming approaches emit the same core events with consistent data structur
257
268
-**`tool_call_delta`** - Incremental tool call params chunks as they're generated
258
269
-**`artifact`** - Binary artifacts produced by tools (images, audio, files)
259
270
-**`provider_tool_event`** - Provider-specific tool events (e.g., image generation, web search)
271
+
-**`step_finish`** - End of a generation step (emitted after tool calls or before stream end)
260
272
-**`error`** - Error handling with recovery information
261
273
-**`stream_end`** - Stream completion with usage statistics
262
274
275
+
> [!TIP]
276
+
> **Understanding Steps**: A "step" represents one cycle of AI generation. In a simple request without tools, there's typically one step. When using tools, each cycle of "AI generates → tools execute → AI continues" creates a new step. Use `step_start` and `step_finish` events to track these cycles in multi-turn tool interactions.
277
+
263
278
### Event Data Examples
264
279
265
280
Based on actual streaming output:
@@ -277,6 +292,12 @@ Based on actual streaming output:
277
292
}
278
293
}
279
294
295
+
// step_start event
296
+
{
297
+
"id":"anthropic_evt_abc123step",
298
+
"timestamp":1756412888
299
+
}
300
+
280
301
// text_start event
281
302
{
282
303
"id":"anthropic_evt_8YI9ULcftpFtHzh3",
@@ -338,6 +359,12 @@ Based on actual streaming output:
338
359
}
339
360
}
340
361
362
+
// step_finish event
363
+
{
364
+
"id":"anthropic_evt_def456step",
365
+
"timestamp":1756412895
366
+
}
367
+
341
368
// stream_end event
342
369
{
343
370
"id":"anthropic_evt_BZ3rqDYyprnywNyL",
@@ -673,12 +700,16 @@ The Vercel AI SDK format provides structured streaming data:
0 commit comments