Skip to main content
Display AI responses as they generate, creating a natural chat experience.

Quick Start

1

Enable Streaming

use praisonai::Agent;

let agent = Agent::new()
    .name("Assistant")
    .instructions("You are helpful")
    .stream(true)  // Enable streaming
    .build()?;

agent.chat("Tell me a story").await?;
// Response appears word by word
2

Disable Streaming

use praisonai::Agent;

let agent = Agent::new()
    .name("Assistant")
    .stream(false)  // Wait for complete response
    .build()?;

How It Works


Stream Events

Events emitted during streaming.
EventDescription
RequestStartAPI call initiated
HeadersReceivedHTTP headers arrived
FirstTokenFirst content (TTFT marker)
DeltaTextText content chunk
DeltaToolCallTool call in progress
ToolCallEndTool call complete
LastTokenFinal content chunk
StreamEndStream completed
ErrorError occurred

Configuration

OptionTypeDefaultDescription
streambooltrueEnable response streaming

Best Practices

Streaming provides immediate feedback, improving perceived performance.
When processing many requests, disable streaming for efficiency.