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
Additional parameters
Session ID for context
Response Format
Server-Sent Events stream with the following event types:Event Types
start
Sent when streaming beginschunk
Content chunks as they’re generatederror
Error during streamingdone
Stream completion with metadataExamples
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
Performance Tips
- Use compression when available
- Process chunks as they arrive
- Implement backpressure handling
- Consider chunking large responses
See Also
- Invoke Endpoint - Synchronous invocation
- WebSockets - Alternative streaming method
- Error Handling - Stream error codes