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

Provider Type
Description
Use Cases

LLM chat, embeddings, streaming

RAG, semantic search, content generation

Transactional and templated emails

Notifications, password resets, receipts

SMS, push, chat platforms

Verification codes, alerts, notifications

AI Providers

Connect to multiple AI/LLM services with one interface:

Provider
Best For
Features

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:

Provider
Best For
Features

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:

Channel
Use Cases
Providers

SMS

Verification codes, alerts

Twilio, AWS SNS

Push

Mobile notifications

Firebase, AWS SNS

WhatsApp

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:

  1. Provider files are created in Infrastructure/Providers/{YourApplication}.DataStoreProviders/{Category}/{Provider}/

  2. NuGet package is referenced automatically

  3. Default configuration is added to Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/{Category}/{Provider}.json

  4. README 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}.json

  • Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/Email/{Provider}.json

  • Application/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

Last updated