Skip to main content
Learn how to handle streaming responses from the V3 LLM endpoint using Server-Sent Events (SSE).

Overview

When streaming is enabled in V3, LLM responses are delivered via Server-Sent Events (SSE), providing real-time token-by-token output. Benefits:
  • Immediate response feedback
  • Better user experience with progressive display
  • Lower perceived latency

Server-Sent Events Format

SSE responses follow this pattern:
Each line starts with data: followed by JSON or the [DONE] marker.

Python with OpenAI SDK

JavaScript with Fetch API

Chunk Structure

Each JSON chunk follows OpenAI’s format:

Key Fields

Finish Reasons

Next Steps

Plans & Pricing

Understand how streaming usage is billed