### Install Bifrost with Example Values File Source: https://docs.getbifrost.ai/deployment-guides/helm/values Install the Bifrost Helm chart using a specific example values file from a remote URL. Ensure the image tag is set to the desired version. ```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 ``` -------------------------------- ### Minimal Bifrost Installation (SQLite) Source: https://docs.getbifrost.ai/deployment-guides/helm Install Bifrost using the Helm chart with a minimal configuration using SQLite for storage. This is the fastest way to get started. ```bash helm install bifrost bifrost/bifrost \ --set image.tag=v1.4.11 \ --set bifrost.encryptionKeySecret.name="bifrost-encryption-key" \ --set bifrost.encryptionKeySecret.key="encryption-key" ``` -------------------------------- ### Start and Enable Bifrost Service and Setup Directories Source: https://docs.getbifrost.ai/enterprise/clustering Initializes the Bifrost user, creates necessary directories, and enables/starts the systemd service. This prepares the node to join the cluster. ```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 ``` -------------------------------- ### Multi-Node Deployment Configuration (Go SDK) Source: https://docs.getbifrost.ai/providers/performance This Go SDK example demonstrates calculating per-node concurrency and buffer size for a multi-node setup, dividing total values by the number of nodes. It also shows how to set the global initial pool size. ```go const numNodes = 4 func (a *MyAccount) GetConfigForProvider(provider schemas.ModelProvider) (*schemas.ProviderConfig, error) { // Total capacity divided by number of nodes // Total: 10,000 RPS across 4 nodes = 2,500 RPS per node return &schemas.ProviderConfig{ NetworkConfig: schemas.DefaultNetworkConfig, ConcurrencyAndBufferSize: schemas.ConcurrencyAndBufferSize{ Concurrency: 10000 / numNodes, // 2500 per node BufferSize: 15000 / numNodes, // 3750 per node }, }, nil } // In main initialization bifrostConfig := schemas.BifrostConfig{ Account: myAccount, InitialPoolSize: 15000 / numNodes, // 3750 per node } ``` -------------------------------- ### Local Development Example with Docker Source: https://docs.getbifrost.ai/enterprise/clustering Demonstrates starting multiple Bifrost nodes using Docker with mDNS discovery enabled. Each node automatically discovers others on the same local network. ```bash # Start first node docker run -p 8080:8080 -p 10101:10101 -p 10201:10102 \ -v $(pwd)/config-mdns.json:/etc/bifrost/config.json \ /bifrost:latest # Start second node (discovers first automatically) docker run -p 8081:8080 -p 10111:10101 -p 10211:10102 \ -v $(pwd)/config-mdns.json:/etc/bifrost/config.json \ /bifrost:latest # Start third node (discovers both automatically) docker run -p 8082:8080 -p 10121:10101 -p 10221:10102 \ -v $(pwd)/config-mdns.json:/etc/bifrost/config.json \ /bifrost:latest ``` -------------------------------- ### Production Configuration Example Source: https://docs.getbifrost.ai/deployment-guides/config-json A production-ready `config.json` demonstrating PostgreSQL storage, multi-provider setup, governance, and common plugins. Ensure environment variables for sensitive information are set. ```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" } } } ``` -------------------------------- ### Install Bifrost for Development Source: https://docs.getbifrost.ai/deployment-guides/helm/values Use this command for a simple local testing setup with SQLite and a single replica. Ensure you replace placeholder keys with your actual values. ```bash helm install bifrost bifrost/bifrost \ --set image.tag=v1.4.11 \ --set 'bifrost.providers.openai.keys[0].name=dev-key' \ --set 'bifrost.providers.openai.keys[0].value=sk-your-key' \ --set 'bifrost.providers.openai.keys[0].weight=1' ``` ```bash # Access kubectl port-forward svc/bifrost 8080:8080 ``` -------------------------------- ### Install and Run Bifrost with NPX Source: https://docs.getbifrost.ai/quickstart/gateway/setting-up Use this command to install and run the latest version of Bifrost locally using NPX. This is a quick way to get started without a formal installation. ```bash npx -y @maximhq/bifrost ``` -------------------------------- ### Provider Call Examples (Gateway and Go SDK) Source: https://docs.getbifrost.ai/contributing/adding-a-provider Demonstrates how to interact with a provider using both a command-line gateway and the Go SDK. Use the Gateway example for direct API calls and the Go SDK for programmatic integration. ```bash curl -X POST http://localhost:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "[provider]/[model]", "messages": [{"role": "user", "content": "Hello"}] }' ``` ```go response, err := client.ChatCompletion(ctx, &schemas.BifrostChatRequest{ Provider: schemas.ProviderName, Model: "model-name", Input: messages, }) ``` -------------------------------- ### Set Image Tag during Installation Source: https://docs.getbifrost.ai/deployment-guides/helm/values The image tag is required for the chart to start. Ensure it is always specified during installation. ```bash # Always specify the tag - the chart will not start without it helm install bifrost bifrost/bifrost --set image.tag=v1.4.11 ``` -------------------------------- ### Example Custom Settings Source: https://docs.getbifrost.ai/contributing/setting-up-repo An example demonstrating how to run the 'make dev' command with custom environment variables for port, logging style, logging level, and app directory. ```bash PORT=3001 LOG_STYLE=pretty LOG_LEVEL=debug APP_DIR=/app/data make dev ``` -------------------------------- ### Install Bifrost CLI Source: https://docs.getbifrost.ai/quickstart/cli/getting-started Use npx to download and run the latest Bifrost CLI without a global installation. This command handles all necessary setup. ```bash npx -y @maximhq/bifrost-cli ``` -------------------------------- ### Install Bifrost Mocker Plugin Source: https://docs.getbifrost.ai/features/plugins Add the mocker plugin to your Go project using 'go get'. ```go go get github.com/maximhq/bifrost/plugins/mocker ``` -------------------------------- ### Complete Tool Hosting Example in Go Source: https://docs.getbifrost.ai/mcp/tool-hosting Initializes Bifrost, registers calculator and time tools, and makes a chat completion request. Ensure your API key is set. ```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) } } ``` -------------------------------- ### vLLM Configuration Example (Go SDK) Source: https://docs.getbifrost.ai/providers/supported-providers/vllm An example of how to configure the vLLM provider using the Go SDK, demonstrating the structure for setting up provider keys and their configurations. ```go case schemas.VLLM: return []schemas.Key{{ Name: "vllm-local", Value: *schemas.NewEnvVar(""), Models: []string{"meta-llama/Llama-3.2-1B-Instruct"}, Weight: 1.0, VLLMKeyConfig: &schemas.VLLMKeyConfig{ URL: *schemas.NewEnvVar("http://localhost:8000"), ModelName: "meta-llama/Llama-3.2-1B-Instruct", }, }}, nil ``` -------------------------------- ### Install Mocker Plugin Source: https://docs.getbifrost.ai/features/plugins/mocker Add the Mocker plugin to your Go project using the go get command. ```bash go get github.com/maximhq/bifrost/plugins/mocker ``` -------------------------------- ### List Models Endpoint Source: https://docs.getbifrost.ai/api-reference This example shows the GET request to the /v1/models endpoint, used to retrieve a list of available language models. ```http GET / v1 / models ``` -------------------------------- ### Full Bifrost Client Configuration Example Source: https://docs.getbifrost.ai/deployment-guides/helm/client A comprehensive example demonstrating various client configurations, including encryption, authentication, client-specific settings, and MCP agent parameters. ```yaml # client-full.yaml image: tag: "v1.4.11" bifrost: encryptionKeySecret: name: "bifrost-encryption" key: "encryption-key" authConfig: isEnabled: true disableAuthOnInference: false existingSecret: "bifrost-admin" usernameKey: "username" passwordKey: "password" client: initialPoolSize: 1000 dropExcessRequests: true allowedOrigins: - "https://app.yourdomain.com" enableLogging: true disableContentLogging: false logRetentionDays: 90 enforceGovernanceHeader: true maxRequestBodySizeMb: 100 headerFilterConfig: allowlist: [] denylist: [] prometheusLabels: - name: "environment" value: "production" mcp: toolSyncInterval: "10m" toolManagerConfig: maxAgentDepth: 10 toolExecutionTimeout: 30 codeModeBindingLevel: "server" disableAutoToolInject: false ``` -------------------------------- ### Go Plugin Hello World Example Source: https://docs.getbifrost.ai/plugins/writing-go-plugin This is a complete hello-world example for a Bifrost Go plugin. It demonstrates the basic structure and required functions for a plugin to be loaded and function within Bifrost. ```go package main import ( "fmt" "github.com/maximhq/bifrost/core/schemas" ) // Init is called when the plugin is loaded // config contains the plugin configuration from config.json func Init(config any) error { fmt.Println("Init called") // Initialize your plugin here (database connections, API clients, etc.) return nil } // GetName returns the plugin's unique identifier func GetName() string { return "Hello World Plugin" } // HTTPTransportPreHook intercepts requests BEFORE they enter Bifrost core // Modify req in-place. Return (*HTTPResponse, nil) to short-circuit. // Only called when using HTTP transport (bifrost-http) func HTTPTransportPreHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest) (*schemas.HTTPResponse, error) { // Use ctx.Log for structured, scoped logging (recommended) ctx.Log(schemas.LogLevelInfo, "HTTPTransportPreHook called") // Read headers using case-insensitive helper (recommended) contentType := req.CaseInsensitiveHeaderLookup("Content-Type") fmt.Printf("Content-Type: %s\n", contentType) // Modify request in-place req.Headers["x-custom-header"] = "custom-value" // Store values in context for use in other hooks ctx.SetValue(schemas.BifrostContextKey("my-plugin-key"), "pre-hook-value") // Return nil to continue, or return &schemas.HTTPResponse{} to short-circuit return nil, nil } // HTTPTransportPostHook intercepts responses AFTER they exit Bifrost core // Modify resp in-place. Called in reverse order of pre-hooks. // Only called for NON-STREAMING responses when using HTTP transport (bifrost-http) func HTTPTransportPostHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, resp *schemas.HTTPResponse) error { ctx.Log(schemas.LogLevelInfo, "HTTPTransportPostHook called") // Modify response headers resp.Headers["x-processed-by"] = "my-plugin" // Read context values set in pre-hook if val := ctx.Value(schemas.BifrostContextKey("my-plugin-key")); val != nil { fmt.Printf("Context value: %v\n", val) } // Return nil to continue, or return error to short-circuit return nil } // HTTPTransportStreamChunkHook intercepts streaming chunks BEFORE they're sent to the client // Modify chunk or return nil to skip. Called in reverse order of pre-hooks. // Only called for STREAMING responses when using HTTP transport (bifrost-http) func HTTPTransportStreamChunkHook(ctx *schemas.BifrostContext, req *schemas.HTTPRequest, chunk *schemas.BifrostStreamChunk) (*schemas.BifrostStreamChunk, error) { ctx.Log(schemas.LogLevelInfo, "HTTPTransportStreamChunkHook called") // chunk is a typed struct containing one of: // - BifrostTextCompletionResponse (text completion streaming) // - BifrostChatResponse (chat completion streaming) // - BifrostResponsesStreamResponse (responses API streaming) // - BifrostSpeechStreamResponse (speech synthesis streaming) // - BifrostTranscriptionStreamResponse (transcription streaming) // - BifrostImageGenerationStreamResponse (image generation streaming) // - BifrostError (error during streaming) // Return chunk unchanged to pass through return chunk, nil // Or return nil to skip/filter this chunk: // return nil, nil // Or return modified chunk: // modifiedChunk := &schemas.BifrostStreamChunk{BifrostChatResponse: ...} // return modifiedChunk, nil } // PreRequestHook is called once per top-level request (NOT per fallback attempt). // This is the routing phase — use it for provider/model/fallback decisions. // Mutations to req.Provider/req.Model/req.Fallbacks commit and propagate to every attempt. // Errors are non-blocking (logged + skipped). func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error { ctx.Log(schemas.LogLevelInfo, "PreRequestHook called") // Plugins that don't participate in routing should just return nil return nil } // PreLLMHook is called before the request is sent to the provider // This is where you can modify requests or short-circuit the flow func PreLLMHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) (*schemas.BifrostRequest, *schemas.LLMPluginShortCircuit, error) { ctx.Log(schemas.LogLevelInfo, "PreLLMHook called") // Modify the request or return a short-circuit to skip provider call return req, nil, nil } ``` -------------------------------- ### vLLM Rerank Request Example Source: https://docs.getbifrost.ai/providers/supported-providers/vllm Demonstrates how to send a rerank request to a vLLM server. 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 } }' ``` -------------------------------- ### Get Integration Type Source: https://docs.getbifrost.ai/quickstart/go-sdk/context-keys Identify the SDK integration format in use, which is useful in gateway plugins. Examples include 'openai', 'anthropic', or 'bedrock'. ```go integrationType := ctx.Value(schemas.BifrostContextKeyIntegrationType).(string) // e.g., "openai", "anthropic", "bedrock" ``` -------------------------------- ### Gemini Go SDK Examples Source: https://docs.getbifrost.ai/providers/reasoning Demonstrates using the Bifrost Go SDK with Gemini for dynamic budget, effort-based conversion, and direct budget settings. ```go // Using Bifrost Go SDK with Gemini // Example 1: Dynamic budget chatReq := &schemas.BifrostChatRequest{ Provider: schemas.Gemini, Model: "gemini-2.0-flash-thinking-exp-1219", Input: messages, Params: &schemas.ChatParameters{ MaxCompletionTokens: schemas.Ptr(4096), Reasoning: &schemas.ChatReasoning{ MaxTokens: schemas.Ptr(-1), // Let Gemini decide }, }, } // Example 2: Effort-based for Gemini 3.0+ chatReq := &schemas.BifrostChatRequest{ Provider: schemas.Gemini, Model: "gemini-3.0-flash", Input: messages, Params: &schemas.ChatParameters{ MaxCompletionTokens: schemas.Ptr(4096), Reasoning: &schemas.ChatReasoning{ Effort: schemas.Ptr("high"), // Converts to thinkingLevel }, }, } // Example 3: Budget-based (all versions) chatReq := &schemas.BifrostChatRequest{ Provider: schemas.Gemini, Model: "gemini-2.5-flash", Input: messages, Params: &schemas.ChatParameters{ MaxCompletionTokens: schemas.Ptr(4096), Reasoning: &schemas.ChatReasoning{ MaxTokens: schemas.Ptr(3000), // Direct budget }, }, } ``` -------------------------------- ### Error Handling Example: Undefined Variable Source: https://docs.getbifrost.ai/mcp/code-mode This example illustrates a common error in Bifrost's Code Mode: an undefined variable. The error message and hints guide the user to use available server keys, such as 'youtubeAPI' or 'filesystem', instead of the undefined 'youtube'. ```python # Error: youtube is not defined # Hints: # - Variable or identifier 'youtube' is not defined # - Available server keys: youtubeAPI, filesystem # - Use one of the available server keys as the object name ``` -------------------------------- ### Skill Plugin Name Format Source: https://docs.getbifrost.ai/features/skills-repository Skills installed from the marketplace are exposed as plugins with this naming convention. For example, a skill named 'review-migrations' will be named 'bifrost-review-migrations'. ```text bifrost-{skill-name} ``` ```text bifrost-review-migrations ``` -------------------------------- ### Full Plugin Structure with Hooks (Go) Source: https://docs.getbifrost.ai/plugins/writing-go-plugin A comprehensive Go plugin example including Init, GetName, TransportInterceptor, PreHook, PostHook, and Cleanup functions. ```go package main import ( "fmt" "github.com/maximhq/bifrost/core/schemas" ) // Init is called when the plugin is loaded // config contains the plugin configuration from config.json func Init(config any) error { fmt.Println("Init called") // Initialize your plugin here (database connections, API clients, etc.) return nil } ``` ```go // GetName returns the plugin's unique identifier func GetName() string { return "Hello World Plugin" } ``` ```go // TransportInterceptor modifies raw HTTP headers and body // Only called when using HTTP transport (bifrost-http) func TransportInterceptor(ctx *schemas.BifrostContext, url string, headers map[string]string, body map[string]any) (map[string]string, map[string]any, error) { fmt.Println("TransportInterceptor called") // Modify headers or body before they enter Bifrost core return headers, body, nil } ``` ```go // PreHook is called before the request is sent to the provider // This is where you can modify requests or short-circuit the flow func PreHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) (*schemas.BifrostRequest, *schemas.PluginShortCircuit, error) { fmt.Println("PreHook called") // Modify the request or return a short-circuit to skip provider call return req, nil, nil } ``` ```go // PostHook is called after receiving a response from the provider // This is where you can modify responses or handle errors func PostHook(ctx *schemas.BifrostContext, resp *schemas.BifrostResponse, bifrostErr *schemas.BifrostError) (*schemas.BifrostResponse, *schemas.BifrostError, error) { fmt.Println("PostHook called") // Modify the response or error before returning to caller return resp, bifrostErr, nil } ``` ```go // Cleanup is called when Bifrost shuts down func Cleanup() error { fmt.Println("Cleanup called") // Clean up resources (close connections, flush buffers, etc.) return nil } ``` -------------------------------- ### Run LiteLLM Migration Tool Source: https://docs.getbifrost.ai/migration-guides/litellm Execute the Bifrost migration CLI tool to start the migration process from LiteLLM. Ensure you have Node.js and npm installed. ```bash npx @maximhq/bifrost-migration-cli ``` -------------------------------- ### Configuration Section Example Source: https://docs.getbifrost.ai/contributing/adding-a-provider Example configuration details for the provider, including HTTP settings like base URL, API version, max connections, and idle timeout. ```markdown ## Configuration **HTTP Settings:** - **Base URL**: `[default URL]` (default) - **API Version**: [version info] - **Max Connections**: 5000 per host - **Idle Timeout**: 60 seconds ``` -------------------------------- ### Configure Ollama Provider in config.json Source: https://docs.getbifrost.ai/providers/supported-providers/ollama Example of how to configure an Ollama provider, including local server setup with an empty API key and model allowlist. ```json { "providers": { "ollama": { "keys": [ { "name": "ollama-local", "value": "", "models": [ "*" ], "weight": 1.0, "ollama_key_config": { "url": "http://localhost:11434" } } ] } } } ``` -------------------------------- ### OpenCode Provider Configuration with Pricing Overrides Source: https://docs.getbifrost.ai/providers/supported-providers/opencode Example configuration for the OpenCode provider, including API key setup and per-model pricing overrides for Zen models. ```json { "providers": { "opencode-zen": { "keys": [{ "value": "env.OPENCODE_API_KEY", "models": ["*"] }] } }, "pricing_overrides": [ { "id": "deepseek-v4-flash-zen", "name": "DeepSeek V4 Flash on Zen", "scope_kind": "provider", "provider_id": "opencode-zen", "match_type": "exact", "pattern": "deepseek-v4-flash", "request_types": ["chat_completion"], "pricing_patch": "{\"input_cost_per_token\":1.4e-07,\"output_cost_per_token\":2.8e-07,\"cache_read_input_token_cost\":2.8e-08}" }, { "id": "gpt-5-nano-zen", "name": "GPT 5 Nano on Zen", "scope_kind": "provider", "provider_id": "opencode-zen", "match_type": "exact", "pattern": "gpt-5-nano", "request_types": ["chat_completion"], "pricing_patch": "{\"input_cost_per_token\":5.0e-08,\"output_cost_per_token\":4.0e-07}" } ] } ``` -------------------------------- ### Create and Retrieve Virtual Keys Source: https://docs.getbifrost.ai/architecture/framework/config-store Demonstrates creating a new virtual key and retrieving an existing one using the ConfigStore. ```go // Create a new virtual key newKey := &tables.TableVirtualKey{ ID: "vk-12345", Name: "My Test Key", // ... other fields } err := store.CreateVirtualKey(ctx, newKey) // Retrieve a virtual key virtualKey, err := store.GetVirtualKey(ctx, "vk-12345") ``` -------------------------------- ### MCP Client Configuration Example (Go) Source: https://docs.getbifrost.ai/mcp/connecting-to-servers Example of configuring an MCP client with specific tools to execute and auto-execute. All tools are available by default, but only 'read_file' and 'list_directory' can be auto-executed. ```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 } ``` -------------------------------- ### Install Bifrost with Encryption Configuration Source: https://docs.getbifrost.ai/deployment-guides/helm/client Deploy Bifrost using Helm, applying the encryption configuration from a values file. This example also sets a specific image tag. ```bash helm install bifrost bifrost/bifrost \ --set image.tag=v1.4.11 \ -f encryption-values.yaml ``` -------------------------------- ### Plugin Directory Structure Example Source: https://docs.getbifrost.ai/plugins/writing-go-plugin 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 ``` -------------------------------- ### Run Pinecone Local with Docker Source: https://docs.getbifrost.ai/integrations/vector-databases/pinecone Use this command to start a local Pinecone index instance using Docker for development purposes. Ensure Docker is installed and running. ```bash docker run -d \ --name pinecone-local \ -p 5081:5081 \ ghcr.io/pinecone-io/pinecone-index:latest ``` -------------------------------- ### Initialize Bifrost with MCP Configuration (Go) Source: https://docs.getbifrost.ai/mcp/connecting-to-servers Configure MCP clients for filesystem and web search services. Use lightweight ping for health checks on STDIO connections and listTools for HTTP connections. Specify which tools are available and which can be auto-executed. ```go package main import ( "context" bifrost "github.com/maximhq/bifrost/core" "github.com/maximhq/bifrost/core/schemas" ) func main() { mcpConfig := &schemas.MCPConfig{ ClientConfigs: []*schemas.MCPClientConfig{ { Name: "filesystem", ConnectionType: schemas.MCPConnectionTypeSTDIO, IsPingAvailable: true, // Use lightweight ping for health checks StdioConfig: &schemas.MCPStdioConfig{ Command: "npx", Args: []string{"-y", "@anthropic/mcp-filesystem"}, Envs: []string{"HOME", "PATH"}, }, ToolsToExecute: []string{"*"}, }, { Name: "web_search", ConnectionType: schemas.MCPConnectionTypeHTTP, ConnectionString: bifrost.Ptr("http://localhost:3001/mcp"), IsPingAvailable: false, // Use listTools for health checks ToolsToExecute: []string{"search", "fetch_url"}, }, }, } client, err := bifrost.Init(context.Background(), schemas.BifrostConfig{ Account: account, MCPConfig: mcpConfig, Logger: bifrost.NewDefaultLogger(schemas.LogLevelInfo), }) if err != nil { panic(err) } } ``` -------------------------------- ### Initialize Go Plugin Project Source: https://docs.getbifrost.ai/plugins/writing-plugin Create a new directory for your plugin and initialize a Go module. Ensure your go.mod file specifies the correct Go version. ```bash mkdir my-plugin cd my-plugin go mod init github.com/yourusername/my-plugin ``` ```bash go get github.com/maximhq/bifrost/core@latest ``` ```go module github.com/yourusername/my-plugin go 1.26.1 require github.com/maximhq/bifrost/core v1.2.38 ``` -------------------------------- ### Documentation Make Command Source: https://docs.getbifrost.ai/contributing/setting-up-repo Command to start a local documentation server for viewing project documentation. ```bash make docs # Start local documentation server ``` -------------------------------- ### Start Bifrost Development Environment Source: https://docs.getbifrost.ai/contributing/setting-up-repo Launch the complete Bifrost development environment, including the UI and API with hot reloading. This command automates dependency installation and server startup. ```bash make dev ``` -------------------------------- ### Test Bifrost API with cURL Source: https://docs.getbifrost.ai/quickstart/gateway/setting-up Make a test API call to the Bifrost gateway using cURL to verify its setup. This example sends a chat completion request to a specified model. ```bash curl -X POST http://localhost:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hello, Bifrost!"}] }' ``` -------------------------------- ### Set Up Go Workspace Source: https://docs.getbifrost.ai/contributing/setting-up-repo Configure the Go workspace by creating a `go.work` file, which links all local modules for development purposes. ```bash make setup-workspace ``` -------------------------------- ### Use Bifrost CLI Overview Source: https://docs.getbifrost.ai/llms.txt This provides a general overview of using the Bifrost CLI. It's a starting point for understanding the command-line interface capabilities. ```bash bifrost overview "List all available agents." ``` -------------------------------- ### Runware Provider Configuration (config.json) Source: https://docs.getbifrost.ai/providers/supported-providers/runware Configure Runware as a provider in your Bifrost setup using a JSON configuration file. This example shows how to add an API key and specify allowed models. ```json { "providers": { "runware": { "keys": [ { "name": "runware-key-1", "value": "env.RUNWARE_API_KEY", "models": [ "*" ], "weight": 1.0 } ] } } } ``` -------------------------------- ### Configure Retries via API Source: https://docs.getbifrost.ai/quickstart/gateway/provider-configuration Set up exponential backoff for retries by configuring `max_retries`, `retry_backoff_initial`, and `retry_backoff_max` in the `network_config`. This example uses 5 retries, starting with 1ms and capping at 10 seconds. ```bash curl --location 'http://localhost:8080/api/providers' \ --header 'Content-Type: application/json' \ --data '{ "provider": "openai", "keys": [ { "name": "openai-key-1", "value": "env.OPENAI_API_KEY", "models": ["*"], "weight": 1.0 } ], "network_config": { "max_retries": 5, "retry_backoff_initial": 1, "retry_backoff_max": 10000 } }' ``` -------------------------------- ### Direct Provider API Initialization (OpenAI) Source: https://docs.getbifrost.ai/integrations Example of initializing the OpenAI client when directly using the provider's API. Requires a valid API key. ```python import openai client = openai.OpenAI( api_key="your-openai-key" ) ```