Skip to main content

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 the Provider 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 in tests/core-providers/yourprovider_test.go:

Integration with Bifrost Core

Register Your Provider

Add your provider to the core factory function in core/bifrost.go:

Update Key Requirements

If your provider requires API keys, update the key checking logic:

Documentation Requirements

Provider Documentation

Create comprehensive documentation including:
  1. Setup Guide - How to get API keys and configure
  2. Supported Features - What capabilities are available
  3. Model List - Supported models and their capabilities
  4. Examples - Real usage examples
  5. 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 validProviders map in transports/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 ParseModelString correctly handles your provider prefix
Required Updates in utils.go:
Test Your Integration:

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

  1. Fork the Repository - Create your development environment
  2. Choose a Provider - Select a provider you want to integrate
  3. Study Existing Examples - Look at OpenAI or Anthropic implementations
  4. Start with Basic Implementation - Get chat completion working first
  5. Add Advanced Features - Streaming, tools, multi-modal support
  6. Test Thoroughly - Write comprehensive tests
  7. Document Everything - Create clear documentation
  8. 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!