Overview
Providers implement theProvider trait, which defines a simple contract:
Step-by-Step Guide
Complete Example
Here’s the full implementation fromexamples/custom_provider.rs:
Advanced Features
Error Handling
Providers should return descriptive errors:Streaming Support
For streaming responses, implementchat_stream:
Authentication
Handle API keys securely:Best Practices
Keep implementations simple and focused
Keep implementations simple and focused
Focus on API communication. Don’t add business logic — that belongs in the agent orchestration layer.
Handle rate limits gracefully
Handle rate limits gracefully
Implement exponential backoff for rate-limited APIs:
Never log API keys or sensitive data
Never log API keys or sensitive data
Use masked logging for credentials:
Test against provider's actual API
Test against provider's actual API
Use integration tests with real (or mocked) API calls:
Next Steps
Creating Channels
Learn how to add messaging platform support
Creating Tools
Give your agent new capabilities