Antigravity bifrost gateway

From boisenoise/skills-collections · View interactive version

Antigravity bifrost gateway is an AI agent skill from the GitHub repository boisenoise/skills-collections. Run and configure Bifrost, the open-source AI gateway: one OpenAI-compatible API for 20+ LLM providers with fallbacks, virtual keys and budgets, semantic caching, observability and an MCP gateway.

How to use this skill

Skill file

Bifrost AI Gateway

Overview

Bifrost is an open-source (Apache-2.0), self-hosted AI gateway written in Go. It puts 20+ providers (OpenAI, Anthropic, AWS Bedrock, Google Vertex and Gemini, Azure OpenAI, Mistral, Groq, Ollama, vLLM and others) behind one OpenAI-compatible API, and adds fallbacks, weighted load balancing, virtual keys with budgets and rate limits, semantic caching, request logging, Prometheus and OpenTelemetry export, and an MCP gateway. Applications keep their existing SDKs and change only the base URL. Documentation: https://docs.getbifrost.ai

When to Use This Skill

Not a fit when the user cannot run a service at all (Bifrost is self-hosted), or for model training and fine-tuning.

How It Works

1. Start the gateway

# Node.js: download and run the binary
npx -y @maximhq/bifrost

# Docker: persist config and logs in ./data
docker run -p 8080:8080 -v $(pwd)/data:/app/data maximhq/bifrost

2. Add providers

Use the web UI (Model Providers page), the management API, or config.json in the app directory (the mounted ./data folder for Docker; ~/.config/bifrost for npx unless -app-dir is set):

{
  "$schema": "https://www.getbifrost.ai/schema",
  "providers": {
    "openai": {
      "keys": [{ "name": "openai-1", "value": "env.OPENAI_API_KEY", "models": ["*"], "weight": 1.0 }]
    },
    "anthropic": {
      "keys": [{ "name": "anthropic-1", "value": "env.ANTHROPIC_API_KEY", "models": ["*"], "weight": 1.0 }]
    }
  }
}
curl -X POST http://localhost:8080/api/providers \
  -H "Content-Type: application/json" \
  -d '{"provider": "openai", "keys": [{"name": "openai-1", "value": "env.OPENAI_API_KEY", "models": ["*"], "weight": 1.0}]}'

3. Send requests

Address models as provider/model on the OpenAI-compatible endpoint:

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"}]}'

Existing SDKs only change their base URL:

| Client | Base URL |

|---|---|

| Any OpenAI-compatible client | http://localhost:8080/v1 |

| OpenAI SDK | http://localhost:8080/openai |

| Anthropic SDK | http://localhost:8080/anthropic |

| Google GenAI SDK | http://localhost:8080/genai |

| LangChain | http://localhost:8080/langchain |

import os
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8080/openai",
    api_key=os.environ["BIFROST_VIRTUAL_KEY"],
)
reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-6",  # any configured provider through the same client
    messages=[{"role": "user", "content": "Summarize this ticket in one line."}],
)

4. Add fallbacks, retries and load balancing

```json

{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hi"}], "fallbacks": ["anthropic/claude-sonnet-4-6", "gemini/gemini-2.5-flash"]}

```

5. Govern access with virtual keys

Virtual keys (sk-bf-...) carry provider and model allowlists, budgets and rate limits:

curl -X POST http://localhost:8080/api/governance/virtual-keys \
  -H "Content-Type: application/json" \
  -d '{
    "name": "support-bot",
    "provider_configs": [
      {"provider": "openai", "weight": 0.7, "allowed_models": ["gpt-4o-mini"], "key_ids": ["*"]},
      {"provider": "anthropic", "weight": 0.3, "allowed_models": ["claude-sonnet-4-6"], "key_ids": ["*"]}
    ],
    "budgets": [{"max_limit": 100.00, "reset_duration": "1M"}],
    "rate_limit": {"request_max_limit": 100, "request_reset_duration": "1m", "token_max_limit": 10000, "token_reset_duration": "1h"},
    "is_active": true
  }'

6. Enable semantic caching

Caching needs a vector store (Redis/Valkey, Weaviate, Qdrant or Pinecone) and the semantic_cache plugin:

{
  "vector_store": {"enabled": true, "type": "redis", "config": {"addr": "localhost:6379"}},
  "plugins": [{
    "name": "semantic_cache",
    "enabled": true,
    "config": {"provider": "openai", "embedding_model": "text-embedding-3-small", "dimension": 1536, "threshold": 0.85, "ttl": 300}
  }]
}

7. Observe traffic

```json

{"plugins": [{"name": "otel", "enabled": true, "config": {"collector_url": "http://otel-collector:4318/v1/traces", "trace_type": "genai_extension", "protocol": "http"}}]}

```

8. Use the MCP gateway

Bifrost connects to MCP servers (STDIO, HTTP or SSE) and re-exposes their tools at /mcp:

{
  "mcp": {
    "client_configs": [
      {"name": "docs", "connection_type": "http", "connection_string": "https://mcp.example.com/mcp", "auth_type": "none", "tools_to_execute": ["*"]}
    ]
  }
}
# Connect Claude Code to every tool Bifrost exposes
claude mcp add --transport http bifrost http://localhost:8080/mcp

9. Route coding agents through Bifrost

Claude Code (Anthropic-compatible route), in ~/.claude/settings.json or the shell:

{"env": {"ANTHROPIC_BASE_URL": "http://localhost:8080/anthropic", "ANTHROPIC_AUTH_TOKEN": "<BIFROST_VIRTUAL_KEY>"}}

Codex CLI (Responses API provider), in ~/.codex/config.toml, with the virtual key exported as OPENAI_API_KEY:

model = "openai/gpt-5"
model_provider = "bifrost"

[model_providers.bifrost]
name = "Bifrost"
base_url = "http://localhost:8080/openai/v1"
wire_api = "responses"
env_key = "OPENAI_API_KEY"
requires_openai_auth = false
supports_websockets = false

Keep the trailing /v1 (Codex appends /responses), and run /logout in Codex first if it is signed in with an OpenAI account.

Examples

Example 1: Failover from OpenAI to Anthropic

User: "Our support bot goes down whenever OpenAI rate-limits us. Add a backup."

  1. Add openai and anthropic providers (step 2) and set "max_retries": 2 in the OpenAI network_config.
  2. Point the bot's OpenAI client at http://localhost:8080/openai.
  3. Send "model": "openai/gpt-4o-mini" with "fallbacks": ["anthropic/claude-sonnet-4-6"].

Result: a 429 rotates to another OpenAI key if one exists, then falls back to Claude. The x-bifrost-routing-info-provider and x-bifrost-fallback-index response headers and the request log show which provider served it.

Example 2: Monthly budget per team

User: "Cap the data team at $200 a month and 60 requests per minute."

  1. Create a virtual key named data-team with "budgets": [{"max_limit": 200, "reset_duration": "1M"}] and "rate_limit": {"request_max_limit": 60, "request_reset_duration": "1m"}.
  2. Turn on enforce_auth_on_inference so requests without a key are rejected.
  3. Give the team the generated virtual-key value as their API key.

Result: requests over the rate limit return 429, requests after the budget is spent return 402, spend is tracked per key in the dashboard, and the budget resets monthly.

Production Checklist

Score one point per item before calling a deployment production-ready (8/8 is the target):

Best Practices

Limitations

Security & Safety Notes

Common Pitfalls

Related Skills

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.