How streaming works
When you use the streaming API, you receive events as they occur:- Token events: Individual tokens from the LLM response as they’re generated
- Step events: Information about tool calls and intermediate steps during task execution
- Done event: Final completion status and token usage statistics
Example
Here’s a complete example of how to use streaming with the Lumo SDK:streaming_example.py
Event types
StreamTokenEvent
Received when new tokens are generated by the LLM. Contains:content: The token string to append to the response
StreamStepEvent
Received when a step completes (e.g., after tool execution). Contains:step: Step data including tool calls and LLM output
StreamDoneEvent
Received when the task completes. Contains:token_usage: Token usage statistics for the entire task
Benefits of streaming
- Real-time feedback: Show progress to users as the task executes
- Better UX: Display partial results immediately instead of waiting for completion
- Debugging: Monitor tool calls and intermediate steps as they happen
- Efficiency: Process responses incrementally for large outputs

