Skip to main content

Streaming CLI

Control streaming behavior when running agents from the command line.

Overview

By default, agent responses stream to the terminal in real-time. You can control this behavior with CLI flags.

Commands

Enable Streaming (Default)

praisonai-ts agent chat "Tell me a story" --stream

Disable Streaming

praisonai-ts agent chat "Tell me a story" --no-stream

Options

OptionDescriptionDefault
--streamEnable streaming outputtrue
--no-streamDisable streaming, wait for complete responsefalse
--verbose, -vShow streaming output in terminaltrue
--quiet, -qSuppress streaming outputfalse

Examples

Interactive Streaming

# Stream response as it's generated
praisonai-ts agent chat "Explain quantum computing in detail" --stream

Batch Processing

# Get complete response (better for scripting)
praisonai-ts agent chat "Summarize this text" --no-stream --json

Silent Mode

# No streaming output, just final result
praisonai-ts agent chat "Hello" --quiet

Verbose Streaming

# Full streaming with debug info
praisonai-ts agent chat "Hello" --stream --verbose

Scripting Examples

Capture Streamed Output

#!/bin/bash

# Stream to file
praisonai-ts agent chat "Write a long story" --stream > story.txt

# Stream and display
praisonai-ts agent chat "Explain AI" --stream | tee output.txt

JSON Output (No Streaming)

# For API-like usage, disable streaming
RESULT=$(praisonai-ts agent chat "Hello" --no-stream --json)
echo $RESULT | jq '.data.response'

Pipeline Usage

# Pipe between commands (streaming disabled automatically)
echo "Summarize this" | praisonai-ts agent chat --stdin --no-stream

Environment Variables

# Default streaming behavior
export PRAISON_STREAM=true

# Default verbose behavior
export PRAISON_VERBOSE=true

Use Cases

Interactive Chat

# Best experience for interactive use
praisonai-ts agent chat "Let's have a conversation" --stream --verbose

Automation Scripts

# Best for scripts and automation
praisonai-ts agent chat "Process this data" --no-stream --json

Long-Form Generation

# Stream long content to see progress
praisonai-ts agent run \
  --instructions "You are a writer" \
  --task "Write a 2000-word essay" \
  --stream

See Also