Skip to main content

Overview

Key Management Features:
  • Multiple Keys per Provider - Distribute load across multiple API keys
  • Weighted Distribution - Control traffic distribution with custom weights
  • Model-Specific Keys - Assign keys to specific models only
  • Automatic Rotation - Seamless failover when keys are rate-limited
  • Load Balancing - Intelligent request distribution
  • Cost Optimization - Use different keys for different cost tiers
Benefits:
  • Higher Rate Limits - Combine multiple keys for increased throughput
  • Improved Reliability - Automatic failover prevents service interruption
  • Cost Control - Route traffic based on budget and usage patterns
  • Zero Downtime - Hot-swap keys without service interruption

Basic Key Setup

Single Key Configuration

Go Package Usage
HTTP Transport Usage Configuration (config.json):
Environment variables:

Key Distribution Strategies

Load Balancing Strategy

Distribute requests evenly across multiple keys for maximum throughput: Go Package - Equal Distribution
HTTP Transport - Equal Distribution
Environment setup:

Tiered Access Strategy

Use premium keys for expensive models, standard keys for cheaper models: Go Package - Tiered Strategy
Result: Cost optimization with dedicated premium keys for expensive models HTTP Transport - Tiered Strategy

Priority-Based Strategy

Route traffic based on key priority and reliability: Go Package - Priority Strategy
HTTP Transport - Priority Strategy

Advanced Key Patterns

Multi-Provider Key Management

Go Package - Cross-Provider Keys
HTTP Transport - Cross-Provider Keys

Dynamic Key Selection

Go Package - Runtime Key Selection
HTTP Transport - Hot Key Reload This feature is under development.

Key Selection Algorithm

Bifrost uses weighted random selection for key distribution:
Example with 3 keys:

Best Practices

Security Best Practices

Environment Variable Management Recommended approach:
Key Rotation Schedule Recommended rotation schedule:
Implementation:

Performance Optimization

Weight Optimization High-throughput scenario:
Cost-optimized scenario:

Next Steps

Tip: Use weights that sum to 1.0 for easier percentage calculations, but Bifrost automatically normalizes weights if they don’t sum to 1.0.