C3 AI Documentation Home

Query Streaming

Overview

Streaming enables answers to appear in the UI as they are generated, eliminating the need to wait for full completion. By default, streaming is disabled.

There are two available streaming strategies, depending on your use case: NATIVE and DB. Some strategies are limited to specific query handlers or features, as detailed below.

Native Streaming

Native streaming uses a Stream of string to display responses immediately in the UI, achieving the fastest time to first token (TTFT). However, it has limited support:

To enable, run:

JavaScript
const streamConfig = Genai.Streaming.Config.make({ strategy: Genai.Streaming.Strategy.NATIVE });
Genai.App.ReadOnlyConfig.make().getConfig().setConfigValue('streamConfig', streamConfig);

DB Streaming

DB streaming generates LLM responses in the background using an AsyncAction, while the UI periodically fetches the stored responses. It offers slower TTFT than native streaming but is still faster than no streaming but more frequent database read and write operations.

To enable, run:

JavaScript
const streamConfig = Genai.Streaming.Config.make({ strategy: Genai.Streaming.Strategy.DB });
Genai.App.ReadOnlyConfig.make().getConfig().setConfigValue('streamConfig', streamConfig);

No Streaming

To disable streaming, run:

JavaScript
const streamConfig = Genai.Streaming.Config.make({ strategy: Genai.Streaming.Strategy.NONE });
Genai.App.ReadOnlyConfig.make().getConfig().setConfigValue('streamConfig', streamConfig);
Was this page helpful?