Introduction
CrewAI Flows support streaming output, allowing you to receive real-time updates as your flow executes. This feature enables you to build responsive applications that display results incrementally, provide live progress updates, and create better user experiences for long-running workflows.How Flow Streaming Works
When streaming is enabled on a Flow, CrewAI captures and streams output from any crews or LLM calls within the flow. The stream delivers structured chunks containing the content, task context, and agent information as execution progresses.Enabling Streaming
To enable streaming, set thestream attribute to True on your Flow class:
Code
Synchronous Streaming
When you callkickoff() on a flow with streaming enabled, it returns a FlowStreamingOutput object that you can iterate over:
Code
Stream Chunk Information
Each chunk provides context about where it originated in the flow:Code
Accessing Streaming Properties
TheFlowStreamingOutput object provides useful properties and methods:
Code
Asynchronous Streaming
For async applications, usekickoff_async() with async iteration:
Code
Streaming with Multi-Step Flows
Streaming works seamlessly across multiple flow steps, including flows that execute multiple crews:Code
Practical Example: Progress Dashboard
Here’s a complete example showing how to build a progress dashboard with streaming:Code
Streaming with State Management
Streaming works naturally with Flow state management:Code
Use Cases
Flow streaming is particularly valuable for:- Multi-Stage Workflows: Show progress across research, analysis, and synthesis phases
- Complex Pipelines: Provide visibility into long-running data processing flows
- Interactive Applications: Build responsive UIs that display intermediate results
- Monitoring and Debugging: Observe flow execution and crew interactions in real-time
- Progress Tracking: Show users which stage of the workflow is currently executing
- Live Dashboards: Create monitoring interfaces for production flows
Stream Chunk Types
Like crew streaming, flow chunks can be of different types:TEXT Chunks
Standard text content from LLM responses:Code
TOOL_CALL Chunks
Information about tool calls within the flow:Code
Error Handling
Handle errors gracefully during streaming:Code
Important Notes
- Streaming automatically enables LLM streaming for any crews used within the flow
- You must iterate through all chunks before accessing the
.resultproperty - Streaming works with both structured and unstructured flow state
- Flow streaming captures output from all crews and LLM calls in the flow
- Each chunk includes context about which agent and task generated it
- Streaming adds minimal overhead to flow execution
Combining with Flow Visualization
You can combine streaming with flow visualization to provide a complete picture:Code
