Streaming
VecTrade uses Server-Sent Events (SSE) for real-time streaming of AI analysis responses.AI Streaming
SSE Event Format
The stream sends events in standard SSE format:Stream Event Types
| Type | Description |
|---|---|
text | Content chunk to display |
citation | Source reference |
metadata | Model info, timing |
done | Stream complete with usage stats |
Async Streaming (Python)
Edge/Worker Streaming (TypeScript)
For Vercel Edge Functions or Cloudflare Workers, convert to a ReadableStream:Error Handling in Streams
Errors during streaming are delivered as error events before the connection closes:Connection Management
- Streams auto-close when the
[DONE]event is received - Use context managers for guaranteed cleanup: