Event System
📋 Table of Contents
🔍 Overview
All Available Events
#
Event
When Fired
Key Data
🔄 Event Lifecycle Diagram
📊 Event Categories
🔌 Event Interception
🏗️ Interceptor Architecture
Creating an Interceptor
Registering an Interceptor
📡 Available Events
1. onAIMessageCreate
Event Arguments
Argument
Type
Description
Example
2. onAIRequestCreate
Event Arguments
Argument
Type
Description
3. onAIProviderRequest
Event Arguments
Argument
Type
Description
4. onAIProviderCreate
Event Arguments
Argument
Type
Description
5. onAIModelCreate
Event Arguments
Argument
Type
Description
6. onAITransformCreate
Event Arguments
Argument
Type
Description
7. beforeAIModelInvoke
Event Arguments
Argument
Type
Description
8. onAIRequest
Event Arguments
Argument
Type
Description
9. onAIResponse
Event Arguments
Argument
Type
Description
10. afterAIModelInvoke
Event Arguments
Argument
Type
Description
11. onAIToolCreate
Event Arguments
Argument
Type
Description
12. beforeAIToolExecute
Event Arguments
Argument
Type
Description
13. afterAIToolExecute
Event Arguments
Argument
Type
Description
14. onAIError
Event Arguments
Argument
Type
Description
15. onAIRateLimitHit
Event Arguments
Argument
Type
Description
16. beforeAIPipelineRun
Event Arguments
Argument
Type
Description
17. afterAIPipelineRun
Event Arguments
Argument
Type
Description
18. onAITokenCount
Event Arguments
Argument
Type
Description
Event Priority Reference
19. onMCPServerCreate
Event Arguments
Argument
Type
Description
20. onMCPServerRemove
Event Arguments
Argument
Type
Description
21. onMCPRequest
Event Arguments
Argument
Type
Description
22. onMCPResponse
Event Arguments
Argument
Type
Description
23. onMCPError
Event Arguments
Argument
Type
Description
Example
💡 Common Use Cases
1. Request Logging and Monitoring
2. Cost Tracking and Budgeting
3. Response Caching
4. Content Filtering and Moderation
5. Multi-Provider Fallback
6. A/B Testing Different Models
7. Adding Safety Guardrails
✅ Best Practices
1. Keep Event Handlers Lightweight
2. Handle Errors Gracefully
3. Document Side Effects
4. Use Naming Conventions
5. Order Matters
6. Test Interceptors Independently
7. Make Interceptors Configurable
📚 Examples
Complete Monitoring Solution
Security and Compliance
Next Steps
Related Documentation
Additional Resources
Last updated