Overview
Adding a new provider to Bifrost enables users to access different AI models through a unified interface. This guide walks you through the entire process from design to deployment.Prerequisites
Required Skills
- Go Programming - Intermediate level proficiency
- HTTP/REST APIs - Understanding of API communication
- JSON Processing - Request/response serialization
- Testing - Unit and integration test writing
Development Environment
- Go 1.23+ - Latest Go version
- Provider API Access - API keys for testing
- Git - Version control familiarity
- Testing Tools - Go test framework knowledge
Provider Interface
Core Interface Definition
Every provider must implement theProvider interface:
Provider Structure Template
Step-by-Step Implementation
Step 1: Add Provider Constant
First, add your provider to the core schemas:Step 2: Implement Chat Completion
Step 3: Request Translation
Convert Bifrost requests to provider-specific format:Step 4: HTTP Communication
Step 5: Response Translation
Convert provider responses to Bifrost format:Step 6: Error Handling
Testing Your Provider
Unit Tests
Integration Tests
Create integration tests intests/core-providers/yourprovider_test.go:
Integration with Bifrost Core
Register Your Provider
Add your provider to the core factory function incore/bifrost.go:
Update Key Requirements
If your provider requires API keys, update the key checking logic:Documentation Requirements
Provider Documentation
Create comprehensive documentation including:- Setup Guide - How to get API keys and configure
- Supported Features - What capabilities are available
- Model List - Supported models and their capabilities
- Examples - Real usage examples
- Limitations - Known limitations or differences
Example Documentation Template
โ Submission Checklist
Before submitting your provider implementation:Code Quality
- Interface Implementation - Correctly implements Provider interface
- Error Handling - Proper error handling and BifrostError creation
- Type Conversion - Accurate Bifrost โ Provider type mapping
- HTTP Communication - Robust API communication with retries
- Code Style - Follows Go conventions and Bifrost patterns
Testing
- Unit Tests - Comprehensive unit test coverage (>80%)
- Integration Tests - Real API integration tests
- Error Scenarios - Tests for various error conditions
- Parameter Testing - Tests for all supported parameters
- Edge Cases - Tests for edge cases and boundary conditions
Documentation
- Code Comments - Clear function and complex logic documentation
- User Documentation - Setup and usage guides
- Examples - Working code examples
- Feature Matrix - Clear documentation of supported features
- Migration Guide - If replacing existing integrations
Integration
- Core Integration - Properly integrated with bifrost.go factory
- Schema Updates - Provider constant added to schemas
- Key Handling - Proper API key requirement configuration
- Configuration - Standard provider configuration support
HTTP Transport Integration
- Provider Recognition - Added to
validProvidersmap intransports/bifrost-http/integrations/utils.go - Model Patterns - Added patterns to appropriate
is*Model()functions in utils.go - Transport Tests - All tests pass in
tests/transports-integrations/directory - Multi-Provider Support - Verified
ParseModelStringcorrectly handles your provider prefix
Required Updates in utils.go:
Advanced Features
Streaming Support
If your provider supports streaming responses:Multi-Modal Support
For providers that support images or other media:Function Calling
For providers with function calling capabilities:Next Steps
- Fork the Repository - Create your development environment
- Choose a Provider - Select a provider you want to integrate
- Study Existing Examples - Look at OpenAI or Anthropic implementations
- Start with Basic Implementation - Get chat completion working first
- Add Advanced Features - Streaming, tools, multi-modal support
- Test Thoroughly - Write comprehensive tests
- Document Everything - Create clear documentation
- Submit Pull Request - Follow the contribution guidelines
Ready to build your provider? ๐ Check out the existing provider implementations in
core/providers/ for reference, and donโt hesitate to ask questions in GitHub Discussions if you need help!