Bifrost LLM Gateway: Architecture, MCP, Plugins, and Commercialization Deep Dive

·5 min readtechnologyai-infra

TL;DR: Bifrost is a Go-based AI gateway adding only 11µs overhead at 5K rps while unifying 20+ LLM providers through an OpenAI-compatible API. Key differentiators: Virtual Keys as governance entities (permissions, budgets, MCP filtering per consumer), Code Mode that slashes token usage by 92.8% at 500+ tools, and a Skills Repository for distributing Agent Skills across Claude Code/Codex. Apache 2.0 OSS core with Enterprise upsell for HA clustering, OIDC federation, and audit-grade compliance.

Bifrost positions itself as “the fastest way to build AI applications that never go down.” It’s a single gateway sitting between your application and every LLM provider, handling failover, load balancing, governance, and observability — all with an OpenAI-compatible API that requires zero code changes beyond swapping the base URL.

This deep dive covers architecture, the MCP system (code mode, agent mode, tool filtering), the Go plugin system, Skills Repository, and how Bifrost monetizes an MIT-licensed open source core.

Architecture: Three Interfaces, One Governance Engine

Bifrost exposes three interfaces:

InterfacePurpose
HTTP API GatewayOpenAI-compatible REST endpoint. Drop-in replacement for any provider SDK.
Go SDKEmbed directly into Go applications. Zero network hop overhead.
Web UIVisual configuration for virtual keys, providers, routing, observability.

All three route through the same core: a Virtual Key system that acts as the governance entity for every request.

Client → Bifrost → Virtual Key (governance/routing) → LLM Provider

Virtual Keys: Not Just API Keys

Virtual Keys are the core abstraction. Each VK carries:

  • Permissions — which providers/models are accessible
  • Budgets — spending caps
  • Rate limits — request throttling
  • Routing rules — which provider to use, failover chains
  • MCP tool filtering — which tools are available to this consumer

This is the key insight: instead of scattering governance across provider dashboards, Bifrost centralizes it in one place. Each consumer (user, service, team) gets a VK that defines their access boundary.

Deployment Options

ModeDescription
Self-hostedDocker/Kubernetes. Full control, runs on your infrastructure.
Enterprise CloudManaged service. Bifrost operates the gateway for you.
EdgeLightweight agent on every org computer. Intercepts all AI traffic — even apps that don’t support proxying. Ensures nothing bypasses governance.

The Edge agent is the compliance killer feature: no more shadow AI where developers bypass company AI policies by using personal API keys.

Performance Claims

Bifrost adds 11µs of overhead at 5,000 requests per second. Built in Go for low-latency, high-throughput operation.

MCP: The Model Context Protocol Layer

Bifrost’s MCP implementation is where it gets interesting. Rather than just proxying MCP requests, Bifrost adds four major features on top.

Tool Filtering: Three-Level Stack

Bifrost filters MCP tools at three stacked levels. A tool must pass ALL applicable filters to be available:

LevelScopeExample
Client configtools_to_execute baseline whitelist["read_file", "list_directory"]
Request headersPer-request overridex-bf-tools: calculator
Virtual Key configPer-consumer restrictionsFinance team VK → no filesystem tools

This enables fine-grained access control: the same MCP server exposes different tools to different consumers based on their virtual key.

Code Mode: LLM Writes Python to Orchestrate Tools

This is the standout feature. When you connect 8-10 MCP servers with 150+ tools, every LLM request includes all tool definitions in context. The model spends most of its budget reading tool catalogs instead of doing work.

Code Mode solves this by exposing only 4 generic tools. The LLM writes Python/Starlark code that orchestrates everything in a sandbox:

MetricClassic MCPCode ModeImprovement
Input tokens (508 tools)1.15M/query83K/query92.8% reduction
Estimated cost$377/round$29/round92.2% lower
Execution speedBaseline40% faster—

The savings scale with tool count. At 96 tools: 58% reduction. At 251 tools: 84.5%. At 508 tools: 92.8%.

Agent Mode: Autonomous Tool Execution

Agent Mode transforms Bifrost from a gateway into an autonomous agent runtime. When enabled:

  1. LLM returns tool calls
  2. Bifrost auto-executes approved tools
  3. Results fed back to LLM
  4. Loop repeats until no more calls or max depth reached

Configuration uses two fields:

  • tools_to_execute: which tools are available (whitelist)
  • tools_to_auto_execute: which tools can run without approval (subset)

Not compatible with streaming. The execution loop requires complete responses before proceeding.

Tool Hosting: No External MCP Server Needed

Register custom tools directly in your Go application:

  1. Define tool schema (OpenAI function format)
  2. Implement handler function
  3. Register via Bifrost SDK

No external MCP server process required. The tool runs in-process with Bifrost.

Session Management

Per-user MCP sessions with OAuth token lifecycle. Three states: active (valid, auto-refreshes), needs_reauth (credential dead), orphaned (user lost access, token still alive). Actions: re-authenticate, edit, revoke.

Plugin System: Go’s Native .so Architecture

Bifrost extends through Go’s standard library plugin system. Plugins are shared object files (.so) loaded at runtime.

Hook Points

HookWhenPurpose
PreLLMHookBefore LLM callModify request, add headers
PostLLMHookAfter LLM responseTransform response, log
HTTPTransportPreHookBefore upstream call (v1.4+)Modify upstream request
HTTPTransportPostHookAfter upstream response (v1.4+)Modify upstream response
InitPlugin loadSetup state
CleanupPlugin unloadTeardown state

Dynamic vs Static Builds

Bifrost ships statically linked by default (portable, no external dependencies). To use plugins, you need a dynamically linked binary:

Terminal window
make build DYNAMIC=1
  • Static: portable, can’t load plugins
  • Dynamic: can load plugins, must match target libc (glibc vs musl)
  • Linux/macOS only — Windows not supported by Go’s plugin system

Use Cases

  • Transform requests/responses
  • Custom validation logic
  • External system integration (logging, monitoring)
  • Custom caching strategies
  • Response enrichment

Skills Repository: Distribute Agent Instructions

Bifrost’s Skills Repository turns the gateway into a central hub for managing Agent Skills — reusable SKILL.md instructions plus supporting files.

How It Works

  • Create skills from the Bifrost dashboard (two-pane editor)
  • Version with SemVer — immutable published versions
  • Marketplace URLs — public for CLI agents to fetch
  • Install in Claude Code/Codex — register Bifrost as a skills marketplace
  • Bundle install — bifrost-all-skills plugin for all skills at once

Skill Structure

FieldPurpose
nameStable identifier (lowercase, hyphens). Immutable after creation.
descriptionShown in dashboard and marketplaces
licenseSPDX identifier (MIT, Apache-2.0)
compatibilityList of supported harnesses
allowed_toolsExperimental: tools the skill can use

Skills can include reference files, examples, scripts, and assets. Management actions are authenticated and permission-gated.

Semantic Caching: Two Modes, Same Plugin

Bifrost caches LLM responses via two complementary paths:

Direct (Hash) Matching

Deterministic exact-match. Request normalized and hashed. Identical request = instant replay. No embeddings required.

Semantic (Similarity) Matching

Embedding-based lookup. Serves cached answer when new request is close enough to a previous one, even if wording differs.

Both can run together: direct first (fastest), semantic on miss. Streaming supported — cached responses replayed chunk-by-chunk.

Common gotcha: caching requires a cache key (x-bf-cache-key header or CacheKey context value). Without one, the request bypasses the cache entirely.

Telemetry: Prometheus and OpenTelemetry

Built-in monitoring at /metrics. No extra instrumentation needed.

CategoryMetrics
HTTP Transporthttp_requests_total, http_request_duration_seconds, size histograms
Upstream ProviderSuccess/error rates, token usage, costs (USD), cache performance
Custom LabelsConfigurable dimensions, runtime injection via x-bf-dim-* headers

Async collection — zero-latency impact on requests.

Enterprise: What You Pay For

Bifrost Enterprise is a strict superset of the OSS gateway. Every OSS feature works identically. Enterprise adds:

CapabilityDetail
HA ClusteringHigh-availability deployment with multiple nodes
Predictive Load BalancingWeighted distribution across API keys with model-specific filtering
Identity FederationOIDC login with directory sync (Okta, custom IdP)
RBACRole-based access control for dashboard and API
Audit LogsImmutable, timestamped trails. SOC2/GDPR/HIPAA/ISO27001 friendly.
Log ExportsS3, GCS, BigQuery, data lake integration
Datadog ConnectorNative APM, LLM Observability, request tracing
Private NetworkDeploy behind firewalls, no external connectivity required

14-day free trial. No public pricing — contact sales.

Licensing and Commercialization

Apache 2.0 OSS Core

Bifrost core is Apache 2.0 licensed (GitHub: maximhq/bifrost). The Docker image at maximhq/bifrost is the OSS build — no enterprise features included. Enterprise UI (ui/app/enterprise/) is cleaned out during OSS builds via make cleanup-enterprise.

Commercialization Path

The strategy is classic OSS → Enterprise upsell:

  1. OSS Core — Free, Apache 2.0. Docker image maximhq/bifrost is the OSS build. Enterprise features (HA clustering, OIDC, RBAC, audit logging) are excluded from OSS builds via make cleanup-enterprise. Covers basic gateway, MCP, plugins, caching, observability.
  2. Enterprise Add-on — HA clustering, OIDC, RBAC, audit logging, Datadog. Targets organizations that need compliance and scale.
  3. Edge Agents — Per-machine licensing potential for the compliance interceptor.
  4. Skills Repository — Marketplace dynamics. Potential revenue share on skill sales or premium marketplace tiers.
  5. Managed Cloud — Fully hosted option for organizations that don’t want to self-host.

Risk: Enterprise Features in OSS

The biggest risk to this model: if core OSS becomes too capable, enterprises see no reason to upgrade. Bifrost mitigates by keeping governance, compliance, and HA features behind the Enterprise paywall — exactly what enterprises need.

Request Options: The x-bf-* Header System

Bifrost controls behavior via HTTP headers (or Go SDK context keys):

HeaderPurpose
x-bf-vkVirtual key identifier
x-bf-api-key / x-bf-api-key-idExplicit API key selection
x-bf-direct-keyCaller-supplied raw provider key (bypasses registered pool)
x-bf-session-idKey stickiness (requires KV store)
x-bf-cache-keyCache key for semantic/direct caching
x-bf-dim-*Custom telemetry dimension labels
x-bf-send-back-raw-request/responseInclude raw provider data
x-bf-store-raw-requestPersist in log records
x-bf-disable-content-loggingPer-request content logging override

Integrations: Protocol Adapters

Integrations translate between Bifrost’s unified API and provider-specific formats. Supported:

IntegrationPurpose
OpenAIStandard OpenAI SDK compatibility
AnthropicClaude API compatibility
Google GenAIVertex AI / Gemini compatibility
LiteLLMLiteLLM proxy compatibility
LangchainLangchain framework integration
AWS BedrockBedrock models via Bifrost

Migration from direct provider → Bifrost requires changing only the base URL:

# Before: direct to OpenAI
client = OpenAI(api_key="your-key")
# After: through Bifrost
client = OpenAI(
base_url="http://localhost:8080/openai",
api_key="dummy-key" # Keys handled in Bifrost
)

Summary

Bifrost is a well-architected AI gateway that solves a real problem: provider sprawl, lack of governance, and the cost of managing multiple LLM connections. The 11µs overhead claim is credible for a Go-based proxy. The MCP features (especially Code Mode’s 92.8% token reduction) are genuinely innovative. The Skills Repository is a smart play for ecosystem lock-in.

The Apache 2.0 → Enterprise commercialization model is standard but workable. The key question: will the OSS version be good enough that enterprises never need to upgrade, or will the governance/compliance features create real pressure to pay?


References

  1. Bifrost AI Gateway — Overview — Bifrost Docs — https://docs.getbifrost.ai/overview
  2. Bifrost Edge — Overview — Bifrost Docs — https://docs.getbifrost.ai/edge/overview
  3. MCP Code Mode — Bifrost Docs — https://docs.getbifrost.ai/mcp/code-mode
  4. MCP Agent Mode — Bifrost Docs — https://docs.getbifrost.ai/mcp/agent-mode
  5. MCP Tool Filtering — Bifrost Docs — https://docs.getbifrost.ai/mcp/filtering
  6. MCP Sessions — Bifrost Docs — https://docs.getbifrost.ai/mcp/sessions
  7. Tool Hosting — Bifrost Docs — https://docs.getbifrost.ai/mcp/tool-hosting
  8. Plugins — Getting Started — Bifrost Docs — https://docs.getbifrost.ai/plugins/getting-started
  9. Skills Repository — Bifrost Docs — https://docs.getbifrost.ai/features/skills-repository
  10. Semantic Caching — Bifrost Docs — https://docs.getbifrost.ai/features/semantic-caching
  11. Telemetry — Bifrost Docs — https://docs.getbifrost.ai/features/telemetry
  12. Enterprise Overview — Bifrost Docs — https://docs.getbifrost.ai/enterprise/overview
  13. Request Options — Bifrost Docs — https://docs.getbifrost.ai/providers/request-options
  14. Integrations — Bifrost Docs — https://docs.getbifrost.ai/integrations/what-is-an-integration
  15. Bifrost GitHub — https://github.com/maximhq/bifrost