Skip to main content

Event Overview

Core Event Types

Events are emitted for all major operations:
  • Message Events: Chat message lifecycle (start, complete, error)
  • Image Generation Events: Image creation process (start, complete, error)
  • Authentication Events: Token management and auth state changes
  • Tool Calling Events: Function execution lifecycle
  • Stream Events: Real-time streaming updates

Message Events

Unified Message Event System

All message types (regular, auto-turn, follow-up) use the same event structure:

Message Lifecycle Events

Auto-Turn Specific Events

Image Generation Events

Image Generation Lifecycle

Image Generation UI Integration

Advanced Event Handling

Event Aggregation

Combine multiple events for complex UI states:

Event Filtering and Routing

Error Event Handling

Comprehensive Error Management

Performance and Debugging

Event Performance Monitoring

Event Debugging

Best Practices

Event Handler Organization

Memory Management

Next Steps

Auto-Turn Conversations

Apply event handling to conversational turns

Image Generation

Handle image generation events effectively

Tool Calling

Manage tool calling events and responses

Streaming Responses

Compare event-driven vs streaming approaches