Quick Reference

Core Components

ComponentPurposeTime to Learn
πŸ›οΈ Account InterfaceProvider configuration and key management5 min
πŸ€– Bifrost ClientMain client methods and request handling10 min
πŸ”Œ PluginsCustom middleware and request/response hooks15 min
πŸ› οΈ MCP IntegrationTool calling and external integrations15 min
πŸ“Š LoggingCustom logging and monitoring5 min
πŸ“‹ SchemasData structures and interfaces reference10 min

Usage Patterns

πŸš€ Basic Usage (Most Common)
import (
    bifrost "github.com/maximhq/bifrost/core"
    "github.com/maximhq/bifrost/core/schemas"
)

// Simple account implementation
type MyAccount struct{}
// ... implement Account interface

func main() {
    client, _ := bifrost.Init(schemas.BifrostConfig{
        Account: &MyAccount{},
    })
    defer client.Cleanup()

    response, err := client.ChatCompletionRequest(context.Background(), &schemas.BifrostRequest{
        Provider: schemas.OpenAI,
        Model:    "gpt-4o-mini",
        Input: schemas.RequestInput{
            ChatCompletionInput: &[]schemas.BifrostMessage{
                {Role: schemas.ModelChatMessageRoleUser, Content: schemas.MessageContent{ContentStr: &message}},
            },
        },
    })
}
⚑ Multi-Provider with Fallbacks
response, err := client.ChatCompletionRequest(ctx, &schemas.BifrostRequest{
    Provider: schemas.OpenAI,
    Model:    "gpt-4o-mini",
    Input:    input,
    Fallbacks: []schemas.Fallback{
        {Provider: schemas.Anthropic, Model: "claude-3-sonnet-20240229"},
        {Provider: schemas.Vertex, Model: "gemini-pro"},
    },
})
πŸ› οΈ Tool Calling
response, err := client.ChatCompletionRequest(ctx, &schemas.BifrostRequest{
    Provider: schemas.OpenAI,
    Model:    "gpt-4o-mini",
    Input:    input,
    Params: &schemas.ModelParameters{
        Tools: &[]schemas.Tool{weatherTool},
        ToolChoice: &schemas.ToolChoice{ToolChoiceStr: &auto},
    },
})
πŸ”Œ With Custom Plugin
client, _ := bifrost.Init(schemas.BifrostConfig{
    Account: &MyAccount{},
    Plugins: []schemas.Plugin{&MyCustomPlugin{}},
})

🎯 Common Use Cases

”I want to…”

GoalStart HereExample Code
Add multiple AI providersAccount InterfaceMulti-provider setup
Handle failover automaticallyBifrost ClientFallback configuration
Add custom logging/monitoringPluginsRate limiting, caching
Use external tools/APIsMCP IntegrationDatabase queries, web search
Optimize for productionAccount InterfaceConnection pooling, keys
Debug requests/responsesLoggingCustom logger setup
Build a chatbot with toolsMCP IntegrationTool registration
Understand error typesSchemasBifrostError handling
Add rate limitingPluginsPreHook implementation
Cache responsesPluginsPostHook response caching

πŸ—οΈ Architecture Overview

Understanding the Flow:
Your App β†’ Account β†’ Bifrost Client β†’ Plugins β†’ Provider β†’ Response
  • Account Interface: Configuration provider (keys, settings, provider configs)
  • Bifrost Client: Core request router with fallbacks and concurrency
  • Plugins: Request/response middleware (rate limiting, caching, monitoring)
  • MCP Integration: Tool calling and external service integration
πŸ›οΈ Deep Architecture: For system internals, worker design, and performance details, see Architecture Documentation.

🌐 Language Integrations

Using HTTP Transport Instead? If you need to use Bifrost from non-Go languages (Python, Node.js, etc.) or in microservices:
πŸ’‘ Tip: HTTP transport hosts the same Go package via REST API, so concepts like Account and Plugins are configured via JSON instead of Go code.

πŸ”§ Advanced Configuration

Performance Tuning

Production Setup

Development


πŸ“š Next Steps

Quick Start Path:
  1. ⚑ 30-second setup - Get running now
  2. πŸ›οΈ Account setup - Configure providers and keys
  3. πŸ€– Client usage - Learn core methods
  4. πŸ”Œ Add plugins - Customize behavior (optional)
Advanced Features: