Skip to main content

Streaming

Overview

RAGLight supports token-by-token streaming on all LLM providers via generate_streaming(). The method returns a Python generator — your application receives each chunk as soon as the model produces it, without waiting for the full response. Streaming and non-streaming are fully interchangeable. The same pipeline, the same config, the same providers — just a different method call.

Usage

With RAGPipeline

With the Builder API


Supported providers

Streaming is available on all LLM providers:

Streaming with Langfuse

Langfuse tracing works identically for streaming. The trace is emitted when the stream ends — no extra configuration needed.

REST API streaming

The raglight serve REST API exposes streaming via a Server-Sent Events endpoint:
The response is a stream of data: {...} events, terminated by data: [DONE].

Summary

  • Use generate_streaming() instead of generate() — no other changes needed
  • Returns a generator — iterate it to receive chunks
  • All providers supported
  • Langfuse tracing works transparently on streaming calls