Provider Routing

Take control of your AI provider strategy with flexible routing options, BYOAPI key support, and intelligent fallback mechanisms.

Intelligent Provider Management

Fusion AI gives you complete flexibility in how you route requests to AI providers. Whether you want to use your own API keys, set up complex fallback chains, or implement sophisticated multi-provider logic, we've got you covered.

Bring Your Own API Key

Use your own API keys for direct billing, enhanced privacy, and full control over your AI provider relationships. Fusion AI acts as an intelligent router while your costs go directly to your chosen providers.

Benefits of BYOAPI

  • Direct Billing: Pay providers directly at their rates
  • Enhanced Privacy: Your keys, your data relationships
  • Rate Limit Control: Use your provider's full rate limits
  • Model Access: Access your provider's latest models

Supported Providers

OpenAI

GPT-4, GPT-3.5

Anthropic

Claude 3.5

Google

Gemini Pro

Azure

OpenAI Models

Setup Example

# 1. Add your API keys to Fusion
curl -X POST https://api.mcp4.ai/v1/keys \
  -H "Authorization: Bearer sk-fusion-..." \
  -d '{
    "provider": "openai",
    "api_key": "sk-your-openai-key...",
    "name": "Primary OpenAI"
  }'

# 2. Use BYOAPI in requests
curl -X POST https://api.mcp4.ai/v1/chat \
  -H "Authorization: Bearer sk-fusion-..." \
  -H "X-Use-BYOAPI: true" \
  -d '{
    "prompt": "Hello world",
    "provider": "openai"
  }'

Your OpenAI key is used directly, costs appear on your OpenAI bill.

Security Best Practices

  • • Store API keys securely in your Fusion dashboard
  • • Use environment-specific keys (dev, staging, prod)
  • • Regularly rotate your API keys
  • • Monitor usage and set up billing alerts

Fallback Rules

Ensure 99.9% uptime with intelligent fallback mechanisms. When your primary provider is unavailable, Fusion AI automatically routes to backup providers based on your configured rules.

1

Primary Attempt

Request goes to your preferred provider first (fastest, cheapest, or highest quality).

2

Detect Failure

Monitor for rate limits, outages, errors, or timeout conditions automatically.

3

Auto Fallback

Instantly route to your next available provider with zero downtime.

Fallback Triggers

  • Rate Limits: When provider limits are exceeded
  • Service Outages: Provider API unavailable
  • Timeout Errors: Requests taking too long
  • Model Unavailable: Specific model temporarily offline

Fallback Configuration

# Configure fallback chain
curl -X POST https://api.mcp4.ai/v1/fallbacks \
  -H "Authorization: Bearer sk-fusion-..." \
  -d '{
    "primary": "openai",
    "fallbacks": [
      {
        "provider": "anthropic",
        "priority": 1,
        "conditions": ["rate_limit", "outage"]
      },
      {
        "provider": "google",
        "priority": 2,
        "conditions": ["all"]
      }
    ]
  }'

Smart Fallback Features

Context Preservation: Full conversation history maintained
Format Translation: Automatic API format conversion
Retry Logic: Intelligent backoff and retry attempts
Health Monitoring: Real-time provider status tracking

Multi-provider Logic

Implement sophisticated routing strategies that leverage multiple providers simultaneously. Optimize for cost, performance, quality, or any combination based on your specific needs.

Routing Strategies

💰 Cost Optimization

Route to the cheapest provider that meets quality thresholds for your prompt type.

⚡ Performance First

Prioritize speed and low latency, perfect for real-time applications.

🎯 Quality Focused

Route to providers with the highest accuracy for specific domains or tasks.

⚖️ Load Balancing

Distribute requests across providers to maximize throughput and reliability.

Advanced Routing

# Multi-provider strategy
curl -X POST https://api.mcp4.ai/v1/chat \
  -H "Authorization: Bearer sk-fusion-..." \
  -d '{
    "prompt": "Analyze this complex data",
    "strategy": {
      "type": "weighted",
      "providers": {
        "openai": {"weight": 60, "max_cost": 0.01},
        "anthropic": {"weight": 30, "quality_min": 0.9},
        "google": {"weight": 10, "fallback_only": true}
      },
      "optimization": "cost_quality_balance"
    }
  }'

Intelligent routing based on cost, quality, and availability.

NeuroSwitch Integration

Multi-provider logic works seamlessly with NeuroSwitch to provide the most intelligent routing possible:

1

Analyze: NeuroSwitch categorizes your prompt

2

Match: Apply your multi-provider rules

3

Route: Select optimal provider dynamically

A/B Testing

Split traffic between providers to compare quality, cost, and performance metrics.

  • • Split traffic percentages
  • • Quality score tracking
  • • Cost comparison reports
  • • Statistical significance

Canary Deployments

Gradually roll out new providers or models to minimize risk and validate performance.

  • • Gradual traffic increases
  • • Error rate monitoring
  • • Automatic rollback
  • • Success criteria tracking

Consensus Routing

Send requests to multiple providers and use consensus or best-response selection.

  • • Multiple provider calls
  • • Response quality scoring
  • • Consensus algorithms
  • • Confidence intervals

Related Resources