Overview
The StreamParser block parses streaming responses (Server-Sent Events) from AI APIs. It extracts text content and tool calls from streaming formats used by OpenAI, Vercel AI SDK, and other providers.Input Parameters
Required
Parameter | Type | Description |
---|---|---|
body | string | Raw SSE stream response body |
Optional
Parameter | Type | Default | Description |
---|---|---|---|
format | string | 'text' | Stream format (see supported formats below) |
Configuration
Parameter | Type | Default | Description |
---|---|---|---|
format | string | 'text' | Streaming format to parse |
Supported Formats
Format | Description |
---|---|
sse | Generic Server-Sent Events |
sse-openai | OpenAI streaming format (ChatGPT API) |
sse-vercel | Vercel AI SDK streaming format |
text | Plain text (no parsing) |
Output Fields
Field | Type | Description |
---|---|---|
text | string | Combined text content from all chunks |
toolCalls | array | Tool/function calls made by the AI |
chunks | array | Individual stream chunks (for debugging) |
metadata | object | Parse metadata (format, counts, errors) |
Tool Call Format
Examples
Parse OpenAI Streaming Response
Parse Vercel AI SDK Stream
Extract Tool Calls
Generic SSE Stream
Common Patterns
OpenAI Chat with Function Calling
Vercel AI SDK Stream
Multi-Turn Conversation
Stream Metadata
Themetadata
output includes useful information:
Chunks Array
Thechunks
array contains individual stream events:
Error Handling
If parsing fails, StreamParser returns empty data:Custom Parsers
You can register custom parsers programmatically:Full Example
Tips
Use Object Output Format
Use Object Output Format
Map outputs to descriptive names:Then access as
${aiMessage}
and ${tools}
.Choose the Right Format
Choose the Right Format
sse-openai
- For OpenAI, Azure OpenAIsse-vercel
- For Vercel AI SDK appssse
- For generic SSE streams
Always Validate Tool Calls
Always Validate Tool Calls
Combine with ValidateTools:
Debug with Chunks
Debug with Chunks
Output chunks for debugging stream issues:Then inspect
${debugChunks}
to see individual events.When to Use
Use StreamParser when:- Parsing streaming responses from AI APIs
- Extracting tool calls from function-calling models
- Testing real-time AI responses
- Working with Server-Sent Events (SSE)
- Response is regular JSON (use JsonParser)
- Non-streaming HTTP response
- Testing non-AI APIs