Skip to main content

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 a text/event-stream response with Server-Sent Events (SSE). Tokens are delivered incrementally as they are generated.

Chat Completions streaming

Uses OpenAI-compatible SSE format:
The terminal choice chunk always reports why generation ended through 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: and data: fields separately
  • Accumulate text deltas for the full response
  • Inspect finish_reason; length means the configured output-token limit was reached
  • Handle connection drops gracefully with retry logic
  • Handle response.failed and structured stream errors before closing the stream
  • The final event contains usage and cost information