### Install Bifrost with Example Configuration (Helm) Source: https://github.com/maximhq/bifrost/blob/dev/helm-charts/bifrost/README.md Install the Bifrost Helm chart using a pre-configured example values file. This is useful for quick setup or development. ```bash # From Helm repository helm install bifrost bifrost/bifrost \ -f https://raw.githubusercontent.com/maximhq/bifrost/main/helm-charts/bifrost/values-examples/postgres-only.yaml \ --set image.tag=v1.5.2 # From local source helm install bifrost ./bifrost -f ./bifrost/values-examples/postgres-only.yaml ``` -------------------------------- ### Example Custom Environment Setup Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx An example demonstrating how to set custom environment variables for the development environment. ```bash PORT=3001 LOG_STYLE=pretty LOG_LEVEL=debug APP_DIR=/app/data make dev ``` -------------------------------- ### Install Bifrost with Example Values File Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm/values.mdx Install the Bifrost Helm chart using a pre-defined example values file from a remote URL and specify an image tag. ```bash helm install bifrost bifrost/bifrost \ -f https://raw.githubusercontent.com/maximhq/bifrost/main/helm-charts/bifrost/values-examples/production-ha.yaml \ --set image.tag=v1.4.11 ``` -------------------------------- ### Quick Start with uv Source: https://github.com/maximhq/bifrost/blob/dev/tests/integrations/python/README.md Basic commands to install dependencies and run all tests using uv. ```bash # 1. Install dependencies uv sync # 2. Run all tests uv run pytest ``` -------------------------------- ### Install and Run Bifrost UI Source: https://github.com/maximhq/bifrost/blob/dev/ui/README.md Install project dependencies and start the development server. The server connects to the Bifrost HTTP transport backend by default. ```bash npm install npm run dev ``` -------------------------------- ### Init Container Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm/values.mdx Define an init container to perform setup tasks before the main application container starts, such as waiting for a database. ```yaml initContainers: - name: wait-for-db image: busybox:1.35 command: ["sh", "-c", "until nc -z postgres-svc 5432; do sleep 2; done"] ``` -------------------------------- ### Install and Run Bifrost Integration Tests Source: https://github.com/maximhq/bifrost/blob/dev/tests/integrations/python/README.md Quick start guide for installing dependencies, setting environment variables, and running tests using uv and pytest. Supports running all tests, specific files, by pattern, or in parallel. ```bash # 1. Install uv (if not already installed) curl -LsSf https://astral.sh/uv/install.sh | sh # 2. Install dependencies cd bifrost/tests/integrations uv sync # 3. Set environment variables export BIFROST_BASE_URL="http://localhost:8080" export OPENAI_API_KEY="your-key" export ANTHROPIC_API_KEY="your-key" # 4. Run tests uv run pytest # All tests uv run pytest tests/integrations/test_openai.py -v # Specific integration uv run pytest -k "tool_call" -v # By pattern uv run pytest -n auto # Parallel execution ``` -------------------------------- ### Interactive Bifrost Helm Chart Installation Source: https://github.com/maximhq/bifrost/blob/dev/helm-charts/bifrost/README.md Executes an included installation script for a guided, interactive setup of the Bifrost Helm chart. ```bash cd bifrost/helm-charts/bifrost ./scripts/install.sh ``` -------------------------------- ### Provider Constructor Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/adding-a-provider.mdx Illustrates the generic structure for a provider's constructor, including configuration checks, client initialization, proxy setup, and BaseURL normalization. ```go package providername import ( "context" "strings" "sync" "time" "github.com/bytedance/sonic" providerUtils "github.com/maximhq/bifrost/core/providers/utils" schemas "github.com/maximhq/bifrost/core/schemas" "github.com/valyala/fasthttp" ) // ProviderNameProvider implements the Provider interface type ProviderNameProvider struct { logger schemas.Logger client *fasthttp.Client networkConfig schemas.NetworkConfig sendBackRawResponse bool customProviderConfig *schemas.CustomProviderConfig } // Response pools for memory efficiency (optional but recommended) var chatResponsePool = sync.Pool{ New: func() any { return &ProviderNameChatResponse{} }, } // NewProviderNameProvider creates a new provider instance func NewProviderNameProvider(config *schemas.ProviderConfig, logger schemas.Logger) *ProviderNameProvider { config.CheckAndSetDefaults() client := &fasthttp.Client{ ReadTimeout: time.Second * time.Duration(config.NetworkConfig.DefaultRequestTimeoutInSeconds), WriteTimeout: time.Second * time. Duration(config.NetworkConfig.DefaultRequestTimeoutInSeconds), MaxConnsPerHost: 5000, MaxIdleConnDuration: 30 * time.Second, MaxConnWaitTimeout: 10 * time.Second, } // Configure proxy if provided client = providerUtils.ConfigureProxy(client, config.ProxyConfig, logger) // Set default BaseURL if not provided if config.NetworkConfig.BaseURL == "" { config.NetworkConfig.BaseURL = defaultBaseURL } config.NetworkConfig.BaseURL = strings.TrimRight(config.NetworkConfig.BaseURL, "/") // Pre-warm response pools (optional optimization) for i := 0; i < config.ConcurrencyAndBufferSize.Concurrency; i++ { chatResponsePool.Put(&ProviderNameChatResponse{}) } return &ProviderNameProvider{ logger: logger, client: client, networkConfig: config.NetworkConfig, sendBackRawResponse: config.SendBackRawResponse, customProviderConfig: config.CustomProviderConfig, } } // GetProviderKey returns the provider identifier func (provider *ProviderNameProvider) GetProviderKey() schemas.ModelProvider { return schemas.ProviderName } ``` -------------------------------- ### Start Development Environment Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx Start the complete development environment, which includes the UI and API with hot reloading. This command automatically handles dependency installation and server startup. ```bash make dev ``` -------------------------------- ### Start Local Documentation Server Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx Starts a local server to view the documentation. ```bash make docs # Start local documentation server ``` -------------------------------- ### Start MCP Server (Go) Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/http-no-ping-server/README.md Run the MCP server implementation using Go. Ensure you have Go 1.26.1+ installed. ```bash go run main.go ``` -------------------------------- ### Launch Bifrost CLI Source: https://github.com/maximhq/bifrost/blob/dev/docs/quickstart/cli/getting-started.mdx Run the Bifrost CLI after it has been installed. This command opens the interactive setup. ```bash bifrost ``` -------------------------------- ### Provider Test File Structure Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/adding-a-provider.mdx A Go example demonstrating the typical structure for a provider's test file, including setup, configuration, and test execution. ```go package providername_test import ( "os" "testing" "github.com/maximhq/bifrost/core/internal/llmtests" "github.com/maximhq/bifrost/core/schemas" ) func TestProviderName(t *testing.T) { t.Parallel() // Check for API key - skip if not available if os.Getenv("PROVIDER_API_KEY") == "" { t.Skip("Skipping tests because PROVIDER_API_KEY is not set") } // Initialize test client client, ctx, cancel, err := llmtests.SetupTest() if err != nil { t.Fatalf("Error initializing test setup: %v", err) } defer cancel() // Configure test scenarios testConfig := llmtests.ComprehensiveTestConfig{ Provider: schemas.ProviderName, ChatModel: "model-name", Fallbacks: []schemas.Fallback{ {Provider: schemas.ProviderName, Model: "fallback-model"}, }, Scenarios: llmtests.TestScenarios{ SimpleChat: true, CompletionStream: true, ToolCalls: true, TextCompletion: false, // Not supported Embedding: false, // Not supported ListModels: true, // ... configure based on provider capabilities }, } // Run all tests t.Run("ProviderNameTests", func(t *testing.T) { llmtests.RunAllComprehensiveTests(t, client, ctx, testConfig) }) client.Shutdown() } ``` -------------------------------- ### Install Mocker Plugin Source: https://github.com/maximhq/bifrost/blob/dev/docs/features/plugins/mocker.mdx Add the Mocker plugin to your Go project using the go get command. ```bash go get github.com/maximhq/bifrost/plugins/mocker ``` -------------------------------- ### Install Bifrost Helm Chart from Repository Source: https://github.com/maximhq/bifrost/blob/dev/helm-charts/bifrost/README.md Installs the Bifrost Helm chart from the repository, demonstrating both default installation and installation with a custom values file. ```bash # Add repository helm repo add bifrost https://maximhq.github.io/bifrost/helm-charts helm repo update # Install with default values helm install bifrost bifrost/bifrost --set image.tag=v1.4.3 # Or install with custom values helm install bifrost bifrost/bifrost -f my-values.yaml ``` -------------------------------- ### Install Bifrost with NPX Source: https://github.com/maximhq/bifrost/blob/dev/docs/changelogs/v1.3.45.mdx Use NPX to install and run Bifrost with the specified transport version. This is a convenient way to get started without a full installation. ```bash npx -y @maximhq/bifrost --transport-version v1.3.45 ``` -------------------------------- ### Install and Run Bifrost with NPX Source: https://github.com/maximhq/bifrost/blob/dev/docs/changelogs/v1.4.17.mdx Use NPX to install and run Bifrost with the specified transport version. This is a convenient way to quickly get started. ```bash npx -y @maximhq/bifrost --transport-version v1.4.17 ``` -------------------------------- ### Complete Bifrost Tool Hosting Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/mcp/tool-hosting.mdx This example shows how to initialize Bifrost, register custom tools (calculator and time), and make a chat completion request that utilizes these tools. Ensure you replace 'your-api-key' with your actual API key. ```go package main import ( "context" "encoding/json" "fmt" "time" bifrost "github.com/maximhq/bifrost/core" "github.com/maximhq/bifrost/core/schemas" ) func main() { // Initialize with empty MCP config to enable tool registration client, err := bifrost.Init(context.Background(), schemas.BifrostConfig{ Account: schemas.Account{ Provider: schemas.OpenAI, APIKey: "your-api-key", }, MCPConfig: &schemas.MCPConfig{}, }) if err != nil { panic(err) } // Register a calculator tool registerCalculator(client) // Register a time tool registerTimeTool(client) // Make a request - tools are automatically available response, err := client.ChatCompletionRequest(schemas.NewBifrostContext(context.Background(), schemas.NoDeadline), &schemas.BifrostChatRequest{ Provider: schemas.OpenAI, Model: "gpt-4o", Input: []schemas.ChatMessage{ { Role: schemas.ChatMessageRoleUser, Content: schemas.ChatMessageContent{ ContentStr: bifrost.Ptr("What is 15 * 7? Also, what time is it?"), }, }, }, }) if err != nil { panic(err) } // Handle tool calls... } func registerCalculator(client *bifrost.Bifrost) { schema := schemas.ChatTool{ Type: schemas.ChatToolTypeFunction, Function: &schemas.ChatToolFunction{ Name: "calculator", Description: schemas.Ptr("Perform arithmetic: add, subtract, multiply, divide"), Parameters: &schemas.ToolFunctionParameters{ Type: "object", Properties: &schemas.OrderedMap{ "operation": map[string]interface{}{ "type": "string", "enum": []string{"add", "subtract", "multiply", "divide"}, }, "a": map[string]interface{}{"type": "number"}, "b": map[string]interface{}{"type": "number"}, }, Required: []string{"operation", "a", "b"}, }, }, } handler := func(args any) (string, error) { m := args.(map[string]interface{}) op := m["operation"].(string) a := m["a"].(float64) b := m["b"].(float64) var result float64 switch op { case "add": result = a + b case "subtract": result = a - b case "multiply": result = a * b case "divide": if b == 0 { return "", fmt.Errorf("cannot divide by zero") } result = a / b } return fmt.Sprintf("%.2f", result), nil } if err := client.RegisterMCPTool("calculator", "Arithmetic calculator", handler, schema); err != nil { panic(err) } } func registerTimeTool(client *bifrost.Bifrost) { schema := schemas.ChatTool{ Type: schemas.ChatToolTypeFunction, Function: &schemas.ChatToolFunction{ Name: "get_current_time", Description: schemas.Ptr("Get the current date and time"), Parameters: &schemas.ToolFunctionParameters{ Type: "object", Properties: &schemas.OrderedMap{ "timezone": map[string]interface{}{ "type": "string", "description": "Timezone (e.g., 'America/New_York', 'UTC')", }, }, Required: []string{}, }, }, } handler := func(args any) (string, error) { m := args.(map[string]interface{}) tzName, _ := m["timezone"].(string) var loc *time.Location var err error if tzName != "" { loc, err = time.LoadLocation(tzName) if err != nil { return "", fmt.Errorf("invalid timezone: %s", tzName) } } else { loc = time.UTC } now := time.Now().In(loc) return now.Format("2006-01-02 15:04:05 MST"), nil } if err := client.RegisterMCPTool("get_current_time", "Get current time", handler, schema); err != nil { panic(err) } } ``` -------------------------------- ### Install and Run Bifrost Gateway Locally Source: https://github.com/maximhq/bifrost/blob/dev/README.md Installs and runs the Bifrost Gateway on your local machine using npx. This is a quick way to get started. ```bash npx -y @maximhq/bifrost ``` -------------------------------- ### Initialize Bifrost with Logging Plugin (Go SDK) Source: https://github.com/maximhq/bifrost/blob/dev/docs/features/observability/default.mdx Demonstrates how to initialize Bifrost as a Go SDK and manually integrate the logging plugin, including setting up a log store and pricing manager. ```go package main import ( "context" bifrost "github.com/maximhq/bifrost/core" "github.com/maximhq/bifrost/core/schemas" "github.com/maximhq/bifrost/framework/logstore" "github.com/maximhq/bifrost/framework/pricing" "github.com/maximhq/bifrost/plugins/logging" ) func main() { ctx := context.Background() logger := schemas.NewLogger() // Initialize log store (SQLite) store, err := logstore.NewLogStore(ctx, &logstore.Config{ Enabled: true, Type: logstore.LogStoreTypeSQLite, Config: &logstore.SQLiteConfig{ Path: "./logs.db", }, }, logger) if err != nil { panic(err) } // Initialize pricing manager (required for cost calculation) pricingManager := pricing.NewPricingManager(logger) // Initialize logging plugin loggingPlugin, err := logging.Init(ctx, logger, store, pricingManager) if err != nil { panic(err) } // Initialize Bifrost with logging plugin client, err := bifrost.Init(ctx, schemas.BifrostConfig{ Account: &yourAccount, LLMPlugins: []schemas.LLMPlugin{loggingPlugin}, }) if err != nil { panic(err) } defer client.Shutdown() // All requests are now logged automatically } ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/maximhq/bifrost/blob/dev/tests/integrations/typescript/README.md Steps to set up the test environment, including installing dependencies, setting environment variables for AI provider API keys and Bifrost base URL, and running the tests. ```bash cd bifrost/tests/integrations/typescript npm install export BIFROST_BASE_URL="http://localhost:8080" export OPENAI_API_KEY="your-key" export ANTHROPIC_API_KEY="your-key" export GEMINI_API_KEY="your-key" npm test # All tests npm test -- tests/test-openai.test.ts # Specific SDK npm test -- -t "Simple Chat" # By pattern ``` -------------------------------- ### Go SDK Example with ToolsToExecute and ToolsToAutoExecute Source: https://github.com/maximhq/bifrost/blob/dev/docs/mcp/connecting-to-servers.mdx Example Go SDK configuration showing how to specify both `ToolsToExecute` and `ToolsToAutoExecute` for an MCP client. ```go { Name: "filesystem", ConnectionType: schemas.MCPConnectionTypeSTDIO, StdioConfig: &schemas.MCPStdioConfig{ Command: "npx", Args: []string{" -y", "@anthropic/mcp-filesystem"}, }, ToolsToExecute: []string{"*"}, // All tools available ToolsToAutoExecute: []string{"read_file", "list_directory"}, // Only these auto-execute } ``` -------------------------------- ### Note Callout Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/adding-a-provider.mdx Example of using a special callout for notes, providing additional information or setup requirements. ```markdown [Provider] requires [special setup/configuration]. ``` -------------------------------- ### Install Bifrost with NPX Source: https://github.com/maximhq/bifrost/blob/dev/docs/changelogs/v1.3.14.mdx Use NPX to install and run Bifrost with a specific transport version. This is useful for quick setup and testing. ```bash npx -y @maximhq/bifrost --transport-version v1.3.14 ``` -------------------------------- ### Set Up Go Workspace Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx Set up the Go workspace by creating a `go.work` file. This links all local modules, enabling seamless development across the project. ```bash make setup-workspace ``` -------------------------------- ### Plugin Versioning Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/plugins/writing-go-plugin.mdx Illustrates how to structure plugin directories for different Bifrost instances to manage version compatibility. ```text staging/ bifrost-http (v1.3.0) plugins/ my-plugin-v1.3.0.so production/ bifrost-http (v1.2.17) plugins/ my-plugin-v1.2.17.so ``` -------------------------------- ### Minimal Helm Install (SQLite) Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm.mdx Installs Bifrost with SQLite storage, suitable for quick setup. Requires creating an encryption key secret beforehand. ```bash kubectl create secret generic bifrost-encryption-key \ --from-literal=encryption-key="$(openssl rand -base64 32)" helm install bifrost bifrost/bifrost \ --set image.tag=v1.4.11 \ --set bifrost.encryptionKeySecret.name="bifrost-encryption-key" \ --set bifrost.encryptionKeySecret.key="encryption-key" ``` -------------------------------- ### Set Up Go Workspace Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx Commands for managing the Go workspace for local development. ```bash make setup-workspace # Set up Go workspace for local development make work-clean # Remove local go.work files ``` -------------------------------- ### Install Xcode Command Line Tools on macOS Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/how-to/install-make.mdx Install the Xcode Command Line Tools to get Apple's/BSD-flavored make. Follow the on-screen prompts. ```bash xcode-select --install make --version ``` -------------------------------- ### Deploy Example Configuration Source: https://github.com/maximhq/bifrost/blob/dev/terraform/README.md Follow these steps to deploy an example Bifrost configuration. This involves navigating to an example directory, copying the sample variables file, editing it with your specific values, and then initializing, planning, and applying the Terraform configuration. ```bash cd examples/aws-ecs cp terraform.tfvars.example terraform.tfvars # Edit terraform.tfvars with your values terraform init terraform plan terraform apply ``` -------------------------------- ### Example: Using Configured Logging Headers Source: https://github.com/maximhq/bifrost/blob/dev/docs/features/observability/default.mdx This example demonstrates making a request with configured headers (`X-Tenant-ID`, `X-Correlation-ID`) that will be captured in the log metadata. ```bash # Config has: logging_headers: ["X-Tenant-ID", "X-Correlation-ID"] curl http://localhost:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -H "X-Tenant-ID: tenant-123" \ -H "X-Correlation-ID: req-abc-456" \ -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}' ``` -------------------------------- ### Anthropic Streaming Events Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/providers/reasoning.mdx This example demonstrates the sequence of stream events for Anthropic, including content block starts, deltas for thinking and signature, and block stops. ```text // Stream events event: content_block_start data: {"type": "content_block_start", "content_block": {"type": "thinking"}} event: content_block_delta data: {"type": "content_block_delta", "delta": {"type": "thinking_delta", "thinking": "Let me"}} event: content_block_delta data: {"type": "content_block_delta", "delta": {"type": "thinking_delta", "thinking": " analyze..."}} event: content_block_delta data: {"type": "content_block_delta", "delta": {"type": "signature_delta", "signature": "EqoB..."}} event: content_block_stop data: {"type": "content_block_stop"} ``` -------------------------------- ### Get Temperature Tool Input Example Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/temperature/README.md An example of the input payload required to call the `get_temperature` tool. The `location` field specifies the city for which to retrieve temperature data. ```json { "location": "New York" } ``` -------------------------------- ### Setup Bifrost User, Directory, and Systemd Service Source: https://github.com/maximhq/bifrost/blob/dev/docs/enterprise/clustering.mdx Creates the 'bifrost' user, its data directory, sets ownership, reloads systemd, and enables/starts the Bifrost service. ```bash sudo useradd -r -s /bin/false bifrost sudo mkdir -p /var/lib/bifrost sudo chown bifrost:bifrost /var/lib/bifrost sudo systemctl daemon-reload sudo systemctl enable bifrost sudo systemctl start bifrost sudo systemctl status bifrost ``` -------------------------------- ### Initialize Go Plugin Project Source: https://github.com/maximhq/bifrost/blob/dev/docs/plugins/writing-go-plugin.mdx Create a new directory for your plugin and initialize a Go module. Ensure your Go version matches Bifrost's. ```bash mkdir my-plugin cd my-plugin go mod init github.com/yourusername/my-plugin ``` -------------------------------- ### Set Image Tag Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm/values.mdx Always specify the image tag during installation, as the chart will not start without it. ```bash # Always specify the tag - the chart will not start without it helm install bifrost bifrost/bifrost --set image.tag=v1.4.11 ``` -------------------------------- ### Install with Values File Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm/values.mdx Create a YAML file to define multiple configuration values for installation or upgrades. This is recommended for complex configurations. ```bash # Create your values file cat > my-values.yaml <<'EOF' image: tag: "v1.4.11" replicaCount: 2 bifrost: encryptionKey: "your-32-byte-encryption-key-here" client: initialPoolSize: 500 enableLogging: true EOF # Install helm install bifrost bifrost/bifrost -f my-values.yaml # Upgrade later helm upgrade bifrost bifrost/bifrost -f my-values.yaml # Upgrade and reuse all previously set values, overriding only one field helm upgrade bifrost bifrost/bifrost \ --reuse-values \ --set replicaCount=5 ``` -------------------------------- ### Go Hello-World Plugin Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/plugins/writing-go-plugin.mdx This is a basic Go plugin that implements the required interface functions for Bifrost. Ensure all necessary functions are defined. ```go package main import ( "fmt" "github.com/maximhq/bifrost/pkg/plugin" ) func main() { plugin.Serve(&plugin.ServeOpts{ Plugin: new(Hello), }) } type Hello struct{} // Hello implements plugin.Plugin func (h *Hello) Name() string { return "hello" } func (h *Hello) Version() string { return "0.0.1" } func (h *Hello) Register(client plugin.Client) error { return client.Handle("hello", func(req *plugin.Request, resp *plugin.Response) { resp.Write("Hello World!") }) } ``` -------------------------------- ### Build Project Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/temperature/README.md Compiles the TypeScript project into JavaScript. This command should be run after installing dependencies and before starting the server. ```bash npm run build ``` -------------------------------- ### Example Rule Configuration Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/helm/guardrails.mdx Demonstrates how to configure multiple rules with different conditions, apply targets, sampling rates, timeouts, and associated provider configurations. ```yaml bifrost: guardrails: rules: - id: 101 name: "block-secrets-input" description: "Block prompts containing API keys" enabled: true cel_expression: "true" apply_to: "input" sampling_rate: 100 timeout: 10 provider_config_ids: [1] - id: 102 name: "azure-output-gpt4o" description: "Scan GPT-4o responses" enabled: true cel_expression: "model == 'gpt-4o'" apply_to: "output" sampling_rate: 100 timeout: 15 provider_config_ids: [3] - id: 103 name: "grayswan-openai-input" enabled: true cel_expression: "provider == 'openai'" apply_to: "input" sampling_rate: 50 timeout: 20 provider_config_ids: [5] - id: 104 name: "strict-team-check" enabled: true cel_expression: "team == 'team-platform'" apply_to: "both" sampling_rate: 100 timeout: 30 provider_config_ids: [1, 3] # multiple providers run in parallel ``` -------------------------------- ### Add Bifrost Helm Repository and Install Source: https://github.com/maximhq/bifrost/blob/dev/helm-charts/bifrost/README.md Quickly add the Bifrost Helm repository and install the chart with default settings using the command line. ```bash helm repo add bifrost https://maximhq.github.io/bifrost/helm-charts helm repo update helm install bifrost bifrost/bifrost --set image.tag=v1.4.3 ``` -------------------------------- ### Go Package Documentation Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/code-conventions.mdx Illustrates how to document Go packages, exported types, and functions, including package comments, type comments, and function comments explaining purpose and potential errors. ```go // Package mcp provides Model Context Protocol integration // for connecting AI models to external tools and services. package mcp // Client manages connections to MCP servers. type Client struct { // fields... } // Connect establishes a connection to the MCP server. // Returns an error if the connection fails. func (c *Client) Connect(ctx context.Context) error { // implementation } ``` -------------------------------- ### Configure Bifrost Ingress Source: https://github.com/maximhq/bifrost/blob/dev/helm-charts/bifrost/README.md Example configuration for setting up Ingress for Bifrost. Ensure your cluster has an Ingress controller like Nginx installed. ```yaml ingress: enabled: true className: "nginx" annotations: cert-manager.io/cluster-issuer: "letsencrypt-prod" hosts: - host: bifrost.example.com paths: - path: / pathType: Prefix tls: - secretName: bifrost-tls hosts: - bifrost.example.com ``` -------------------------------- ### Build Everything Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/setting-up-repo.mdx Build all components of the project for production. ```bash make build ``` -------------------------------- ### Integration Test Setup for Bifrost Source: https://github.com/maximhq/bifrost/blob/dev/docs/plugins/writing-go-plugin.mdx Bash commands to start a test Bifrost instance with a plugin and send test requests using curl. ```bash # Start test Bifrost with plugin ./bifrost-http --config test-config.json # Run test requests curl -X POST http://localhost:8080/v1/chat/completions ... ``` -------------------------------- ### Install, Build, and Run MCP Server Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/error-test-server/README.md Standard commands to install dependencies, build the project, and run the MCP error test server. ```bash # Install dependencies npm install # Build npm run build # Run node dist/index.js ``` -------------------------------- ### Production-Ready config.json Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/deployment-guides/config-json.mdx A comprehensive config.json for production environments. It includes PostgreSQL storage, multi-provider setup, governance features, and common plugins. ```json { "$schema": "https://www.getbifrost.ai/schema", "encryption_key": "env.BIFROST_ENCRYPTION_KEY", "client": { "initial_pool_size": 500, "drop_excess_requests": true, "enable_logging": true, "log_retention_days": 90, "enforce_auth_on_inference": true, "allowed_origins": ["https://app.yourcompany.com"] }, "providers": { "openai": { "keys": [ { "name": "openai-primary", "value": "env.OPENAI_API_KEY", "models": ["*"], "weight": 1.0 } ], "network_config": { "default_request_timeout_in_seconds": 120, "max_retries": 3 } }, "anthropic": { "keys": [ { "name": "anthropic-primary", "value": "env.ANTHROPIC_API_KEY", "models": ["*"], "weight": 1.0 } ] } }, "config_store": { "enabled": true, "type": "postgres", "config": { "host": "env.PG_HOST", "port": "5432", "user": "env.PG_USER", "password": "env.PG_PASSWORD", "db_name": "bifrost", "ssl_mode": "require" } }, "logs_store": { "enabled": true, "type": "postgres", "config": { "host": "env.PG_HOST", "port": "5432", "user": "env.PG_USER", "password": "env.PG_PASSWORD", "db_name": "bifrost", "ssl_mode": "require" } } } ``` -------------------------------- ### Complexity Router Configuration JSON Response Source: https://github.com/maximhq/bifrost/blob/dev/docs/features/governance/complexity-router.mdx Example JSON response when retrieving the complexity analyzer configuration via GET or PUT requests. ```json { "tier_boundaries": { "simple_medium": 0.15, "medium_complex": 0.35, "complex_reasoning": 0.60 }, "keywords": { "code_keywords": ["function", "class", "..."], "reasoning_keywords": ["step by step", "..."], "technical_keywords": ["architecture", "..."], "simple_keywords": ["hello", "hi", "..."] } } ``` -------------------------------- ### Tool-Level Binding Stub Example Source: https://github.com/maximhq/bifrost/blob/dev/docs/architecture/core/mcp.mdx Generated Python stub file for tool-level binding. Each tool gets its own file, providing a more granular approach. ```python # servers/filesystem/read_file.pyi # Usage: filesystem.read_file(param=value) def read_file(path: str) -> dict: # Read contents of a file ``` -------------------------------- ### Install Framework Package Source: https://github.com/maximhq/bifrost/blob/dev/docs/architecture/framework/what-is-framework.mdx Use this command to install the framework package for your Go project. ```bash go get github.com/maximhq/bifrost/framework ``` -------------------------------- ### Render Helm Manifests for Bifrost Source: https://github.com/maximhq/bifrost/blob/dev/examples/configs/withnginxreverseproxy/README.md Render the Kubernetes manifests for Bifrost using Helm, applying the example's specific values. This allows for verification before installation. ```bash helm template bifrost ./helm-charts/bifrost \ -f examples/configs/withnginxreverseproxy/helm-values.yaml ``` -------------------------------- ### Send Rerank Request to vLLM Source: https://github.com/maximhq/bifrost/blob/dev/docs/providers/supported-providers/vllm.mdx Example of sending a rerank request to the vLLM API using curl. Ensure your vLLM server is started with a rerank-capable model. ```bash curl -X POST http://localhost:8080/v1/rerank \ -H "Content-Type: application/json" \ -d '{ "model": "vllm/BAAI/bge-reranker-v2-m3", "query": "What is machine learning?", "documents": [ {"text": "Machine learning is a subset of AI."}, {"text": "Python is a programming language."}, {"text": "Deep learning uses neural networks."} ], "params": { "return_documents": true } }' ``` -------------------------------- ### Install Bifrost Go Package Source: https://github.com/maximhq/bifrost/blob/dev/docs/quickstart/go-sdk/setting-up.mdx Initialize your Go module and install the Bifrost core package. This is the first step to using Bifrost in your project. ```bash go mod init my-bifrost-app go get github.com/maximhq/bifrost/core ``` -------------------------------- ### Complete PR Example with Changelogs Source: https://github.com/maximhq/bifrost/blob/dev/docs/contributing/raising-a-pr.mdx An example demonstrating how to structure a commit message and update changelogs for a multi-package change. ```markdown Commit: [feat]: Add retry logic with exponential backoff Modified files: - core/mcp/utils.go ← add retry executor - core/mcp/clientmanager.go ← use retry logic Update changelogs: 1. core/changelog.md: [feat]: add exponential backoff retry mechanism [@your-name](https://github.com/your-name) 2. transports/changelog.md: [fix]: apply retry logic to connection establishment [@your-name](https://github.com/your-name) ``` -------------------------------- ### Example Tool: greet Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/http-no-ping-server/README.md A sample tool that greets a person by name. Used for testing MCP server functionality. ```json { "name": "greet", "arguments": { "name": "Alice" } } ``` -------------------------------- ### Install/Upgrade Bifrost with Helm Source: https://github.com/maximhq/bifrost/blob/dev/examples/configs/withnginxreverseproxy/README.md Install or upgrade the Bifrost deployment in Kubernetes using Helm, with the provided example values file. This command ensures the NGINX ingress is configured. ```bash helm upgrade --install bifrost ./helm-charts/bifrost \ -f examples/configs/withnginxreverseproxy/helm-values.yaml ``` -------------------------------- ### Build and Run Go Test Server Source: https://github.com/maximhq/bifrost/blob/dev/examples/mcps/go-test-server/README.md Commands to build the Go Test Server executable and then run it. ```bash # Build go build -o bin/go-test-server # Run ./bin/go-test-server ```