Providers
FlexBase provides unified abstractions for external service providers, enabling you to switch implementations without changing application code. All providers follow consistent patterns for configuration, usage, and error handling.
Available Providers
Communication Providers
AI Providers
Connect to multiple AI/LLM services with one interface:
Azure OpenAI
Enterprise, compliance
GPT-4o, embeddings, SLA
OpenAI
Latest models
GPT-4o, o1, latest features
Anthropic Claude
Long context, analysis
200K context, reasoning
Google Gemini
Multimodal
Text, images, competitive pricing
Ollama
Local/offline
Privacy, no API costs
// Works with ANY AI provider
public class ChatService
{
private readonly IFlexAIProvider _aiProvider; // Could be OpenAI, Claude, Ollama, etc.
public async Task<string> AskAsync(string question)
{
return await _aiProvider.ChatAsync(question);
}
}Email Providers
Send emails through multiple services:
Console
Development
No real emails, console output
SMTP
Standard servers
Office 365, Gmail, custom
SMTP + Templates
Branded emails
Built-in templates, variables
SendGrid
Transactional
Delivery tracking, analytics
Message Providers
Send messages across multiple channels:
SMS
Verification codes, alerts
Twilio, AWS SNS
Push
Mobile notifications
Firebase, AWS SNS
Customer support
Twilio
Slack/Teams
Internal alerts
Native APIs
Console
Development
Testing
Common Patterns
Automatic Setup via Flex Studio
Providers are automatically added to your application through Flex Studio. When you add a provider:
Provider files are created in
Infrastructure/Providers/{YourApplication}.DataStoreProviders/{Category}/{Provider}/NuGet package is referenced automatically
Default configuration is added to
Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/{Category}/{Provider}.jsonREADME documentation is included in the provider folder
You can find all provider files, configuration examples, and documentation in the generated infrastructure folder.
Configuration
Providers use the IOptions pattern. Configuration files are automatically created when you add providers via Flex Studio:
Configuration files are located at:
Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/AI/{Provider}.jsonApplication/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/Email/{Provider}.jsonApplication/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/Message/{Provider}.json
Dependency Injection
After adding providers via Flex Studio, register only the provider in Program.cs (the generated queries/handlers/plugins are auto-wired by Flex):
Multiple Providers
Use keyed services (.NET 8+) for multiple providers:
Provider-Agnostic Benefits
1. Easy Testing
Use console/mock providers during development:
2. Cost Optimization
Switch providers based on cost or features:
3. Vendor Independence
Avoid vendor lock-in - switch providers with configuration:
Error Handling
All providers follow consistent error patterns:
Best Practices
1. Use Console Providers in Development
2. Validate Configuration on Startup
3. Implement Retry Logic
4. Monitor and Log
Integration Examples
AI + Vector Store (RAG)
Email + Message (Multi-Channel Notifications)
Advanced Usage Examples
AI Providers
AI providers enable seamless integration with various LLM services. Below is an example of using an AI provider for generating responses:
Email Providers
Email providers support sending templated and transactional emails. Below is an example:
Message Providers
Message providers allow sending SMS, push notifications, and more. Below is an example:
See Also
Data Stores - Vector, search, document stores
Relational Databases - EF Core and Dapper
AI Providers Details - Complete AI provider documentation
Email Providers Details - Complete email provider documentation
Message Providers Details - Complete message provider documentation
Last updated