Quick Start
1
Import Protocols
2
Implement Custom Store
Protocol Specifications
AuthProtocol
Authentication implementations for gateway requests.PairingProtocol
Channel pairing and authorization management.SessionBindingProtocol
Session to principal mapping for state tracking.These are
@runtime_checkable typing.Protocol classes — any object whose method shapes match (duck typing) satisfies them. No inheritance required.Custom Implementation Example
How It Works
Protocol implementations allow you to plug custom backends into the PraisonAI gateway without modifying core code.Configuration Options
Protocol implementations are injected when you start the gateway:Common Patterns
- Redis Backend
- Database Backend
- File Backend
Best Practices
Implement all protocol methods
Implement all protocol methods
Protocol compliance requires implementing all methods, even if some return empty results for your use case.
Handle database errors gracefully
Handle database errors gracefully
Wrap database operations in try-catch blocks and return safe defaults.
Use connection pooling for performance
Use connection pooling for performance
For database backends, use connection pools to avoid connection overhead.
Validate inputs to prevent injection
Validate inputs to prevent injection
Always validate and sanitize inputs, especially for database queries.
Related
Bot Pairing
Complete pairing system documentation
Unknown User Pairing
Owner-DM inline-button approval flow

