POST /v1/agents/{agent_id}/stream
Stream agent responses using Server-Sent Events (SSE) for real-time output.
Request
Path Parameters
The unique identifier of the agent
Request Body
Same as the invoke endpoint:
The input query for the agent
Server-Sent Events stream with the following event types:
Event Types
start
Sent when streaming begins
chunk
Content chunks as they’re generated
error
Error during streaming
done
Stream completion with metadata
Examples
JavaScript (Browser)
Python
Node.js
Handling Stream Interruptions
Client-Side Reconnection
Resume from Position
Stream Control
Abort Stream
Close the connection to stop streaming:
Rate Control
Control streaming speed with parameters:
Error Handling
Network Errors
Stream Errors
Best Practices
- Implement Reconnection Logic for network interruptions
- Handle Partial Responses gracefully
- Set Appropriate Timeouts for long-running streams
- Monitor Memory Usage when buffering responses
- Provide User Feedback during streaming
- Use compression when available
- Process chunks as they arrive
- Implement backpressure handling
- Consider chunking large responses
See Also