FlameGate is a self-hostable LLM proxy, intelligent router, and WebAssembly extension runtime. It accepts requests in multiple client dialects (OpenAI, Anthropic, Gemini, plus embeddings, images, audio, web search, and web fetch), applies token-saving transforms and content guardrails, routes each request to the best available provider account, and meters usage against strict budget limits.
You get a single, robust API gateway for all your AI workloads with automatic failover, semantic caching, and a real-time dashboard — without locking your tools or code to a single vendor.
- Multi-dialect gateway — One unified
/v1API that speaks OpenAI (/v1/chat/completions), Anthropic (/v1/messages), Gemini (/v1beta/models), and OpenAI Responses (/v1/responses) dialects, plus embeddings, image generation, speech/transcription, web search, and web fetch. - Zero-discard transparent streaming — High-fidelity SSE pipeline preserving reasoning tokens (
reasoning_content,thinking_delta), sequential tool-call blocks, 15s heartbeat keepalives, and cross-dialect live translation. - Smart routing & failover — Account selection with round-robin or fill-first strategies, automatic rate-limit cooldowns, and continuous background health probes that route around degraded accounts and models.
- Token optimization — Context slimming and dynamic headroom cut prompt tokens and payload size before requests leave the gateway.
- Semantic response cache — Repeated or near-identical prompts are served from memory/cache for zero upstream cost, supporting exact hash and embedding-based similarity modes.
- Content guardrails — In-flight inspection for PII, toxicity, prompt-injection, bias, and banned topics with native and pluggable detectors.
- WASM extension runtime — Install and update provider connectors as WebAssembly modules (
wazeroruntime) without rebuilding the core binary. Extensions hot-reload on file change. - Metering & budgeting — High-throughput buffered usage tracking, per-plan token allocation, and hard spend limits per API key.
- Per-key rate limiting — In-memory RPM/TPM and concurrency quotas per key or tier.
- Built-in dashboard — React dashboard (Vite, Tailwind, shadcn/ui) with real-time request metrics, key management, system health, and routing policies.
- Zero-config tunnels — Built-in Cloudflare and Tailscale tunnel integration for secure remote deployment.
- Interactive API docs — Embedded Scalar OpenAPI documentation served by the admin API.
flowchart TD
subgraph Clients["Clients & Tools"]
CLI["CLI Tools<br/>Claude Code · OpenCode · Cline · Codex"]
SDK["AI Applications & SDKs<br/>OpenAI · Anthropic · LangChain"]
Browser["Web Browser<br/>Dashboard · Key Usage Portal"]
end
subgraph Listeners["FlameGate Listeners"]
ProxyListener["LLM Proxy API (:20181 / :20180)<br/><code>/v1/chat/completions</code> · <code>/v1/messages</code> · <code>/v1/responses</code> · <code>/v1beta/models</code>"]
AdminListener["Admin & Dashboard (:20180)<br/>React UI · <code>/api</code> · <code>/portal</code> · Scalar <code>/docs</code>"]
end
CLI --> ProxyListener
SDK --> ProxyListener
Browser --> AdminListener
subgraph Core["FlameGate Core Microkernel"]
direction TB
Auth["1. Auth & Rate Limiting<br/>API Key Validation · Spend Budgets · In-Memory RPM/TPM"]
Guard["2. Content Guardrails & Token Optimizers<br/>PII Masking · Injection Defense · Context Slimmer · Semantic Cache"]
Router["3. Smart Router & Dispatcher<br/>Dynamic Model Mapping · Account Fallback · Rate-Limit Cooldown"]
Meter["4. Async Usage Metering<br/>Buffered Spend Tracking · Real-time Metrics Hub"]
Auth --> Guard --> Router --> Meter
end
ProxyListener --> Core
subgraph Extensions["WASM Extensions Layer (wazero runtime)"]
ExtAntigravity["Google Antigravity<br/>(Gemini 2.5/3.8, Claude, GPT via Cloud Code)"]
ExtOpenCode["OpenCode Free<br/>(GLHF / Zen API)"]
ExtCline["ClinePass Extension"]
ExtMiMo["Xiaomi MiMo Extension"]
ExtCustom["Custom WASM Providers & Translators"]
end
subgraph Native["Direct Providers & Networking"]
DirectAPI["Direct OpenAI-compatible Endpoints"]
ProxyPools["Outbound Proxy Pools (SOCKS5 / HTTP)"]
end
subgraph Storage["Persistence & Crypto Vault"]
DB[("Database<br/>SQLite / PostgreSQL")]
Vault[("Crypto Vault<br/>AES-256-GCM Envelope Encryption")]
end
Router --> Extensions
Router --> Native
Core -.-> Storage
AdminListener -.-> Storage
| Port | Service | Default Address | Description |
|---|---|---|---|
20180 |
Admin & Dashboard | http://127.0.0.1:20180 |
Web UI, Admin REST API (/api), Public Key Portal (/portal), and OpenAPI Docs (/docs). |
20181 |
LLM Proxy API | http://127.0.0.1:20181 |
Dedicated high-throughput listener for /v1 client traffic (OpenAI, Anthropic, Gemini dialects). |
5180 |
Frontend Dev Server | http://localhost:5180 |
Vite development server with hot-reload (development only). |
Tip
By default, setting server.proxy_port = 20181 keeps heavy LLM inference traffic isolated from the administrative dashboard. If server.proxy_port is set to 0, the /v1 proxy API shares port 20180 with the admin dashboard.
Install the pre-compiled binary directly to ~/.local/bin with one command:
curl -fsSL https://raw.githubusercontent.com/bobbyunknown/flamegate/main/scripts/install.sh | bashRun instantly with npx / bunx or install globally using your favorite Node package manager:
# Run directly without global installation
npx flamegate
# Or install globally
npm install -g flamegate
# or: bun install -g flamegate / pnpm add -g flamegateOfficial multi-architecture Docker images (linux/amd64, linux/arm64) are published to Docker Hub and GitHub Container Registry (GHCR):
bobbyunknown/flamegate:latestghcr.io/bobbyunknown/flamegate:latest
A ready-to-use docker-compose.yml is included:
# Clone the repository
git clone https://github.com/bobbyunknown/flamegate.git
cd flamegate
# Start FlameGate in the background
docker compose up -d
# Generate your initial administrator API key
docker compose exec flamegate flamegate bootstrapAccess the dashboard at http://localhost:20180.
# Pull the latest image
docker pull bobbyunknown/flamegate:latest
# Run the container (mapping Dashboard :20180 and Proxy :20181)
docker run -d \
--name flamegate \
--restart unless-stopped \
-p 20180:20180 \
-p 20181:20181 \
-v flamegate_data:/root/.flamegate \
bobbyunknown/flamegate:latest
# Bootstrap initial API key
docker exec -it flamegate flamegate bootstrapDownload standalone, zero-dependency native binaries from GitHub Releases:
- Linux:
flamegate-linux-amd64,flamegate-linux-arm64 - macOS:
flamegate-darwin-arm64(Apple Silicon),flamegate-darwin-amd64(Intel) - Windows:
flamegate-windows-amd64.exe,flamegate-windows-arm64.exe
# Example for macOS (Apple Silicon)
chmod +x flamegate-darwin-arm64
mv flamegate-darwin-arm64 flamegate
# Bootstrap key and run
./flamegate bootstrap
./flamegatePrerequisites:
- Go 1.26+
- Bun (or Node.js 18+)
git clone https://github.com/bobbyunknown/flamegate.git
cd flamegate
# Build React UI assets and compile standalone binary
make build-ui
# Bootstrap initial admin key
./bin/flamegate bootstrap
# Run the server
./bin/flamegateOpen http://localhost:20180 in your browser. Log in using the admin API key generated from ./flamegate bootstrap (or docker compose exec flamegate flamegate bootstrap).
Use any OpenAI-compatible client, SDK, or curl pointing to the LLM proxy port (20181):
curl http://localhost:20181/v1/chat/completions \
-H "Authorization: Bearer fg_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Hello FlameGate!"}
]
}'Usage:
flamegate [flags]
flamegate [command]
Commands:
status Check whether local server is running and print its URL
bootstrap Create an initial API key and print it once
service Manage background service (install, start, stop, restart, status, uninstall)
ext Manage WASM extensions (install, list, enable, disable, uninstall)
version Print version and commit metadata
help Show help message
Flags:
-c, --config <path> Path to a TOML config file (default: ~/.flamegate/flamegate.toml)
-k, --key-name <name> (bootstrap) Name for the created API key (default: default)
-bootstrap Create an initial API key and exit
-healthcheck Perform local health check and exit with status code
FlameGate includes native support to run automatically in the background across macOS, Linux, and Windows:
# 1. Install FlameGate as an OS background service (Launchd / Systemd)
flamegate service install
# 2. Start the service
flamegate service start
# 3. Check service status (RUNNING / STOPPED)
flamegate service status
# 4. Stop or restart
flamegate service restart
flamegate service stop
# 5. Uninstall service
flamegate service uninstallFlameGate utilizes a WebAssembly runtime (wazero) to support custom providers and dialect translators without modifying or recompiling the core application.
# Install an extension from a local folder (must contain schema.json + <slug>.wasm)
./flamegate ext install ./path-to-extension
# View installed extensions
./flamegate ext list
# Enable or disable extensions dynamically
./flamegate ext enable <slug>
./flamegate ext disable <slug>
# Remove an extension
./flamegate ext uninstall <slug>Official extensions, developer SDKs, and runnable examples are maintained in the flamegate-ext/ directory:
- Extension Architecture & ABI Guide — Complete ABI specification, memory model, and lifecycle guide.
- Go Extension SDK — Go package for building zero-dependency WASM extensions using TinyGo.
- Rust Extension SDK — Rust crate for building high-performance extensions using
wasm32-wasip1. - Runnable Examples:
minimal-openai-go— Minimal OpenAI-compatible extension in Go.minimal-openai-rust— Minimal OpenAI-compatible extension in Rust.
Configuration is loaded from defaults → TOML file → environment variables.
- Default file location:
~/.flamegate/flamegate.toml(or%APPDATA%\flamegate\flamegate.tomlon Windows). - Environment variables use the
FLAMEGATE_prefix with double underscores for nested keys (e.g.FLAMEGATE_SERVER__PORT=20180,FLAMEGATE_SERVER__PROXY_PORT=20181).
Reference configuration template: flamegate.example.toml.
| Setting | Description | Default |
|---|---|---|
server.host / server.port |
Admin API + dashboard listener | 127.0.0.1:20180 |
server.proxy_port |
Dedicated /v1 proxy listener (0 = share server port) |
20181 |
database.driver |
sqlite or postgres |
sqlite |
database.dsn |
Connection string (SQLite defaults to <data_dir>/flamegate.db) |
empty |
security.master_key |
Base64 32-byte key for credential encryption; generated if empty | empty |
security.jwt_secret |
Signs dashboard session tokens; generated if empty | empty |
security.bind_loopback_only |
Restrict dashboard and admin API to loopback interfaces | true |
log.level / log.format |
debug | info | warn | error; text | json |
info / text |
meter.async |
Asynchronous buffered usage writes | true |
cache.enabled |
Semantic and exact response cache | false |
limits.enabled |
Per-key rate limiting engine | false |
health.enabled |
Background health probe service | true |
# Run backend with hot reload
make dev
# Run frontend dev server with Vite (:5180)
make ui-dev
# Run all unit and integration tests
make test
# Run tests with race detector
make test-race
# Run linter
make lint