HTTP Transport Overview

Bifrost HTTP transport provides a REST API service for:
  • Multi-provider access through unified endpoints
  • Drop-in replacements for OpenAI, Anthropic, Google GenAI APIs
  • Language-agnostic integration with any HTTP client
  • Production-ready deployment with monitoring and scaling
  • MCP tool execution via HTTP endpoints
# Start Bifrost HTTP service
docker run -p 8080:8080 \
  -v $(pwd)/config.json:/app/config/config.json \
  -e OPENAI_API_KEY \
  maximhq/bifrost

# Make requests to any provider
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"provider": "openai", "model": "gpt-4o-mini", "messages": [...]}'

πŸš€ Core Features

Unified API Endpoints

EndpointPurposeDocumentation
POST /v1/chat/completionsChat conversationsEndpoints Guide
POST /v1/text/completionsText generationEndpoints Guide
POST /v1/mcp/tool/executeTool executionEndpoints Guide
GET /metricsPrometheus metricsEndpoints Guide

Drop-in API Compatibility

ProviderEndpointCompatibility
OpenAIPOST /openai/v1/chat/completionsOpenAI Compatible
AnthropicPOST /anthropic/v1/messagesAnthropic Compatible
Google GenAIPOST /genai/v1beta/models/{model}GenAI Compatible
πŸ“– Migration: See Migration Guide for step-by-step migration from existing providers.

βš™οΈ Configuration

Core Configuration Files

ComponentConfigurationTime to Setup
πŸ”§ ProvidersAPI keys, models, fallbacks5 min
πŸ› οΈ MCP IntegrationTool servers and connections10 min
πŸ”Œ PluginsCustom middleware (coming soon)5 min

Quick Configuration Example

{
  "providers": {
    "openai": {
      "keys": [
        {
          "value": "env.OPENAI_API_KEY",
          "models": ["gpt-4o-mini"],
          "weight": 1.0
        }
      ]
    },
    "anthropic": {
      "keys": [
        {
          "value": "env.ANTHROPIC_API_KEY",
          "models": ["claude-3-sonnet-20240229"],
          "weight": 1.0
        }
      ]
    }
  },
  "mcp": {
    "client_configs": [
      {
        "name": "filesystem",
        "connection_type": "stdio",
        "stdio_config": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem"]
        }
      }
    ]
  }
}

πŸ”— Integration Patterns

”I want to…”

GoalIntegration TypeGuide
Replace OpenAI APIDrop-in replacementOpenAI Compatible
Replace Anthropic APIDrop-in replacementAnthropic Compatible
Use with existing SDKsChange base URL onlyMigration Guide
Add multiple providersProvider configurationProviders Config
Add external toolsMCP integrationMCP Config
Custom monitoringPlugin configurationPlugins Config
Production deploymentDocker + configDeployment Guide

Language Examples

Python (OpenAI SDK)
from openai import OpenAI

# Change base URL to use Bifrost
client = OpenAI(
    base_url="http://localhost:8080/openai",  # Point to Bifrost
    api_key="your-openai-key"
)

# Use normally - Bifrost handles provider routing
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)
JavaScript/Node.js
import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "http://localhost:8080/openai", // Point to Bifrost
  apiKey: process.env.OPENAI_API_KEY,
});

const response = await openai.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello!" }],
});
cURL
# Direct Bifrost API
curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "openai",
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}],
    "fallbacks": [{"provider": "anthropic", "model": "claude-3-sonnet-20240229"}]
  }'

# OpenAI-compatible endpoint
curl -X POST http://localhost:8080/openai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

πŸš€ Deployment Options

# Quick start
docker run -p 8080:8080 \
  -v $(pwd)/config.json:/app/config/config.json \
  -e OPENAI_API_KEY \
  -e ANTHROPIC_API_KEY \
  maximhq/bifrost

# Production with custom settings
docker run -p 8080:8080 \
  -v $(pwd)/config.json:/app/config/config.json \
  -v $(pwd)/logs:/app/logs \
  -e OPENAI_API_KEY \
  -e ANTHROPIC_API_KEY \
  maximhq/bifrost \
  -pool-size 500 \
  -drop-excess-requests

Binary Deployment

# Install
go install github.com/maximhq/bifrost/transports/bifrost-http@latest

# Run
bifrost-http \
  -config config.json \
  -port 8080 \
  -pool-size 300 \
  -plugins maxim

Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bifrost
spec:
  replicas: 3
  selector:
    matchLabels:
      app: bifrost
  template:
    metadata:
      labels:
        app: bifrost
    spec:
      containers:
        - name: bifrost
          image: maximhq/bifrost:latest
          ports:
            - containerPort: 8080
          env:
            - name: OPENAI_API_KEY
              valueFrom:
                secretKeyRef:
                  name: ai-keys
                  key: openai
          volumeMounts:
            - name: config
              mountPath: /app/config
      volumes:
        - name: config
          configMap:
            name: bifrost-config

πŸ“Š Monitoring and Observability

Built-in Metrics

# Prometheus metrics endpoint
curl http://localhost:8080/metrics

# Key metrics available:
# - bifrost_requests_total{provider, model, status}
# - bifrost_request_duration_seconds{provider, model}
# - bifrost_tokens_total{provider, model, type}
# - bifrost_errors_total{provider, error_type}

Health Checks

# Basic health check
curl http://localhost:8080/v1/chat/completions \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"provider":"openai","model":"gpt-4o-mini","messages":[{"role":"user","content":"test"}]}'

πŸ“š Complete Documentation

πŸ“– API Reference

🎯 Next Steps

  1. ⚑ Quick Setup - Get Bifrost HTTP running in 30 seconds
  2. πŸ”§ Configure Providers - Add your AI provider credentials
  3. πŸ”— Choose Integration - Pick drop-in replacement or unified API
πŸ›οΈ Architecture: For HTTP transport design and performance details, see Architecture Documentation.