Overview
Tambo streams AI responses in real-time, delivering:- Component props - Stream gradually as the AI generates them
- Component state - Update via
useTamboComponentState()with streaming support - Tool results - Execute client-side tools and stream responses
- Text content - Character-by-character streaming for assistant messages
How Streaming Works
When the AI generates a response:- Message starts - Thread status becomes
"streaming" - Content streams - Props, text, and tool calls stream in real-time
- Components render - Components re-render as props update
- Message completes - Thread status returns to
"idle"
Streaming Pipeline
Streaming Status
Monitor streaming state withuseTambo():
Status Values
"idle"- No active stream"streaming"- AI is generating response"error"- Stream encountered an error
Component Prop Streaming
Components receive props incrementally:Handling Partial Props
Handle incomplete data during streaming:Streaming Arrays
Arrays build incrementally:Streaming Objects
Nested objects stream field-by-field:Component State Streaming
State updates also stream withuseTamboComponentState():
update_Note_state({ isPinned: true })
isPending = true → State updates → isPending = false
Tool Streaming
Tools execute client-side and can stream results:- Display the result as text
- Render a component with the data
- Call another tool
Streaming Control
Disable Streaming for Components
Disable streaming for specific components:Cancel Streaming
Stop an in-progress stream:TamboStream API
The underlying streaming implementation usesTamboStream:
Stream Events
Events emitted during streaming:RUN_STARTED- Stream beginsCONTENT_DELTA- Text content chunkCOMPONENT_CREATED- Component initializedCOMPONENT_PROPS- Props updateTOOL_CALL_STARTED- Tool execution beginsTOOL_CALL_ARGS- Tool arguments streamTOOL_CALL_RESULT- Tool completesRUN_COMPLETED- Stream finishesRUN_ERROR- Error occurred
Loading States
Component Loading
Show loading states during streaming:Custom Loading Components
Thread Loading
Streaming Performance
Debounced Updates
Tambo batches rapid updates to reduce re-renders:Optimistic Updates
User messages appear immediately:Best Practices
Handle Undefined Props
Always check for undefined during streaming:Use Keys for Arrays
Stable keys prevent re-renders:Show Progress
Indicate streaming activity:Graceful Degradation
Handle streaming errors:Next Steps
- Learn about Threads for conversation management
- Explore Components to understand component rendering
- See Interactable Components for stateful streaming
- Check Tools for tool execution and results