Overview
AtlasFlux supports streaming for both/v1/responses and /v1/chat/completions. Enable streaming by setting "stream": true in your request body.
How streaming works
When streaming is enabled, the API returns atext/event-stream response with Server-Sent Events (SSE). Tokens are delivered incrementally as they are generated.
Chat Completions streaming
Uses OpenAI-compatible SSE format:finish_reason. The following usage chunk reports settled cost as a six-decimal MYR string and separates visible completion tokens from reasoning tokens.
If a chat stream fails after it has started, the stream emits a structured error before [DONE]:
Responses streaming
Uses AtlasFlux-specific event types:Implementation tips
- Parse SSE events line by line
- Handle
event:anddata:fields separately - Accumulate text deltas for the full response
- Inspect
finish_reason;lengthmeans the configured output-token limit was reached - Handle connection drops gracefully with retry logic
- Handle
response.failedand structured stream errors before closing the stream - The final event contains usage and cost information
