AI routing infrastructure

One gateway.
Every model.

A control layer between your AI tools, coding agents and model providers. Auto-fallback, quota-aware routing, local or remote.

236 providers · 90+ free · 15–95% saved · OpenAI-compatible
gateway.js — auto-fallback
$ blackriver-gateway start
 claude ........ ok
 quota out → glm $0.50
 switched in 8ms
 openai, gemini, mistral ... ready
Tools
Gateway
Models

The promise

One endpoint. Never stop building.

Resilience

Never hit limits

Auto-fallback across providers in milliseconds. Quota out? The next provider takes over — zero downtime.

Cost

Save up to 95% on tokens

Route by cost, capability, quota or policy. Stops premium endpoints from being used for tasks that don't need them.

Pricing

$0 to start

Self-host for free. 90+ free-tier providers onboard by default. No credit card. No vendor lock-in.

Compatibility

Every tool works

OpenAI-compatible endpoint. Claude Code, Codex, Cursor, Cline, OpenCode, Roo, Copilot — point, route, build.

Surface

One endpoint, many decisions

Provider, model, fallback, quota, cost, latency and policy are decided at the gateway — not inside every tool.

Operations

Production-grade

Local, remote or private. Audit logs, observability, enterprise controls. Built for teams shipping AI in production.

Routing

Stop hardcoding your AI stack.

BlackRiver Gateway gives teams one endpoint for many providers. Requests can be routed by cost, model capability, quota, latency, availability or internal policy.

When one provider fails, hits limits or becomes too expensive for the task, the gateway moves traffic — without forcing every tool to be reconfigured.

01

Subscription first

Use the accounts and subscriptions your team already pays for before sending traffic elsewhere.

02

Fallback routing

Move requests to alternative providers when rate limits, outages or quota exhaustion hit.

03

Cost control

Select models based on task value instead of always defaulting to premium endpoints.

Providers we route through

236 providers. One OpenAI-compatible endpoint.

From the largest commercial model APIs to free tiers, local models and self-hosted backends. New providers ship in days, not quarters.

OpenAI Anthropic Google Gemini Mistral OpenRouter Groq Cohere Together Fireworks Perplexity DeepSeek xAI Replicate Anyscale Lepton Novita DeepInfra AI21 Upstage Voyage Jina Cloudflare AI Cerebras NVIDIA NIM SambaNova Friendli Hyperbolic AIOZ Nebius Chutes Kluster Submodel Pollinations LongCat Kiro Antigravity Ollama LM Studio vLLM LocalAI + 196 more

Quickstart

Three commands. Zero config.

Step 1

Install & run

One command. The gateway starts on localhost with sensible defaults.

shell
$ npm i -g @blackriver/gateway
$ blackriver-gateway start
› listening on http://localhost:8080

Step 2

Connect a free provider

Paste a key or pick a free tier. Quota, cost and capability are detected automatically.

providers.env
# any of these, mixed together
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=AIza...
OPENROUTER_API_KEY=sk-or-...

# or pick a free tier
FREE_PROVIDERS=pollinations,longcat

Step 3

Point your IDE

Set the base URL. Existing OpenAI clients work without code changes.

client.js
// any OpenAI-compatible tool
baseURL = "https://gateway.blackriver.ai/v1"
apiKey  = "br_..."

Features

Everything built in. No add-ons.

Engine

Smart combos

Auto-combo engine fans a request across providers, merges results and picks the best answer by score, cost or policy.

State

Memory & skills

Persistent memory, semantic recall and reusable skills. Context survives model, provider and tool swaps.

Resilience

3-layer fallback

Provider, model and account fallbacks. If one route is blocked, the next one tries — automatically, in milliseconds.

Cost

Free quota

Tracks free-tier usage across providers. Routes around exhausted quotas so paid traffic is the last to be used.

Efficiency

Compression

Cuts 15–95% of eligible tokens with stacked RTK and Caveman-style rewrites before requests leave the gateway.

Protocol

MCP server

95 MCP tools exposed to agents. Let coding agents and copilots drive the gateway themselves.

Protocol

A2A protocol

Agent-to-agent handoff. External agents can negotiate models, context and policy with the gateway directly.

Routing

17 routing strategies

Cost-first, capability-first, round-robin, weighted, sticky-session, latency-aware, policy-aware and more.

Tools

One config. Every coding tool works.

Point Claude Code, Codex, Cursor, Cline, OpenCode or any OpenAI-compatible client at the gateway. Routing, fallback and policy become a setting, not a refactor.

Coding agents

Claude Code, Codex, Cursor

Route coding traffic through one controlled layer. Keep using your existing IDE.

AI workflows

Cline, OpenCode, Roo

Avoid brittle one-provider workflows. Fallback, retry and policy are handled at the edge.

Copilots

Copilot, Continue, Kiro

Standard OpenAI-compatible endpoint. Drop in, route out.

Self-hosted

Antigravity, Kilocode

Use the gateway as the routing brain for local and private deployments.

Why

Why BlackRiver Gateway

Optionality

No vendor lock-in

Every provider becomes a route. Switching is a config change, not a project. The gateway treats each model the same.

Resilience

Tools stay online

When one provider goes down, the gateway keeps your IDE, agents and copilots working — automatically, in the background.

Economics

Cheaper by default

Use existing subscriptions, free tiers and cheaper models first. Premium endpoints are reserved for tasks that need them.

Compare

How we compare.

Capability BlackRiver Gateway LiteLLM Portkey OpenRouter
OpenAI-compatible endpointYesYesYesYes
Self-hostableYes — local or remoteYesCloud-firstNo
Auto-fallback across providers3-layerManualManualYes
Free-tier routing90+ providersNoNoLimited
MCP server (95 tools)YesNoNoNo
A2A protocolYesNoNoNo
Token compression15–95%NoNoNo
Memory & skillsBuilt inNoNoNo
TokenOptimizer integrationNativeNoWebhookNo
Pricing modelFree self-hostFree self-hostUsage-basedPer-token

Architecture

One endpoint. Many decisions.

The gateway exposes an OpenAI-compatible API surface while routing traffic to multiple provider backends behind the scenes.

gateway.js
// any OpenAI-compatible client
const client = new OpenAI({
  baseURL: "https://gateway.blackriver.ai/v1",
  apiKey:  process.env.BLACKRIVER_GATEWAY_KEY,
});

const response = await client.chat.completions.create({
  model: "auto:code",
  messages: [{ role: "user", content: "Refactor this module" }],
});

// Gateway decides:
//   provider, model, fallback, quota, cost, policy.

Where it runs

Deploy anywhere your stack lives.

01

npm

Local install, runs on any Node host.

02

Docker

Single image, single port, zero config.

03

Desktop

Native app for macOS, Windows, Linux.

04

ARM

Apple Silicon, Raspberry Pi, Graviton.

05

Termux

Run the gateway on an Android phone.

06

PWA

Browser-only dashboard for quick routing.

07

OpenCode plugin

Drop-in for OpenCode-based IDEs.

08

Source

Build it yourself. MIT-style license.

Combos

Auto-combo engine.

A single request can fan out across multiple models in parallel, get scored, deduplicated and merged. The gateway picks the answer that best fits the policy you defined — without your tool knowing.

Request

"Refactor this module"

Fan-out

3 models in parallel

Score

Best answer by policy

Claude Sonnet0.92
GPT-4o0.81
Gemini 1.5 Pro0.74
Result: Claude Sonnet wins on quality, but Gemini wins on cost — policy decides.

Free tier

~1.6B free tokens a month.

By combining free tiers across providers, the gateway exposes close to 1.6 billion free tokens every month — without spinning up a single paid account.

90+

Free-tier providers onboard by default.

11

Free-forever providers, no rate cliff.

1.6B

Combined free monthly tokens.

$0

Cost to start. Self-host forever.

Compression

Save 15–95% on tokens.

TokenOptimizer-aware compression runs at the gateway. System prompts, tool outputs and long contexts are rewritten before they leave — typically 60% on tool-heavy sessions, up to 95% on chatty ones.

Raw prompt 1,420 tokens
RTK compression 540 tokens (-62%)
+ Caveman rewrite 180 tokens (-87%)
Same task. Same model. Different bill. TokenOptimizer turns this into a measurable audit.

Resilience

3 layers of fallback. Zero downtime.

Layer 1 — Provider

Cross-provider

If a provider returns an error, hits a rate limit or times out, the gateway moves the request to the next configured provider in milliseconds.

Layer 2 — Model

Cross-model

If a specific model is degraded or removed, the gateway re-routes to the next model in the capability tier — without the client knowing.

Layer 3 — Account

Cross-account

If a subscription is exhausted, the gateway shifts traffic to another account, free tier or organization pool — also without the client knowing.

Proxy

3-level proxy. Stealth by default.

1 — Sticky

Sticky sessions

Pin a session, model or tool to a specific account or provider to preserve state and avoid context churn.

2 — Stealth

Stealth mode

Header rewriting, fingerprint rotation and traffic shaping keep sessions under the radar of aggressive rate limits.

3 — Private

Private & local-first

Run entirely on your own hardware, on your own VPC or on a single developer laptop. No telemetry, no lock-in.

Dashboard

A real dashboard. Not a config file.

Inspect traffic, replay requests, watch provider health, manage keys and audit every call. The gateway ships with a first-party UI — and a CLI for teams that prefer it.

Live traffic healthy

claude-sonnet → claude

last 1h · 1,284 req

p95 412ms

gpt-4o → openai

last 1h · 921 req

p95 380ms

gemini-1.5 → google

last 1h · 612 req

p95 290ms

glm-4.5 → zhipu

last 1h · 410 req

p95 540ms

Inspect

Replay any request

Step through headers, body and routing decisions. Rerun against a different provider, model or policy.

Audit

Full event log

Every call, key rotation, fallback and policy change is logged. Export to TokenOptimizer for cost analysis.

CLI

First-party CLI

Manage providers, policies and secrets from the terminal. Scriptable. Script-friendly.

Protocols

Connect an agent — it drives the gateway itself.

MCP

MCP server

95 Model Context Protocol tools exposed to agents. Inspect, replay, route, fallback, switch policy — all from inside the agent.

A2A

A2A server

Agent-to-agent handoff. External agents negotiate models, context and policy with the gateway directly over a typed protocol.

Cloud agents

Cloud agents

Cloud-hosted agents can connect, register and use the gateway as a shared routing brain across the team.

Platform

Not just a proxy — a platform.

Services

Embedded services

Memory, cache, queue, scheduler and skills are embedded services — not external systems to wire up.

Context

Your knowledge, in context

Plug in documents, embeddings and indexes. The gateway injects the right context into the right model at the right time.

Safety

Guardrails built in

PII redaction, prompt guards and per-team policy live at the edge — not in every tool's prompt.

Engagement

Gamification

Surface provider health, savings and fallback wins to the team. Make routing decisions visible and rewarding.

Enterprise

From developer router to company control layer.

The same gateway a single developer installs in 30 seconds becomes the AI routing layer for the whole company — with policy, audit and observability in place.

Policy

Policy-aware routing

Define allowed providers, model tiers and fallback behavior by team, tool or project. Enforced at the edge.

Visibility

Usage visibility

See which tools, agents and workflows are consuming AI budget through the gateway. Per-team, per-project, per-user.

Integration

TokenOptimizer integration

Gateway traffic feeds cost intelligence, audit reports and optimization dashboards inside TokenOptimizer. Same company, two products.

Operations

Private forks & enterprise builds

Private deployments, SSO, audit-grade logging, signed builds and dedicated support for teams that need more than self-host.

Company

BlackRiver AI Ltd.

A UK company created to build, own and operate AI products and infrastructure. The gateway is one of its products.

ProductBlackRiver Gateway
OperatorBlackRiver AI Ltd
Company number17291854
JurisdictionEngland & Wales
BaseLondon, United Kingdom
Sister productTokenOptimizer

Contact

Build AI routing with BlackRiver AI.

Gateway deployment, provider routing, enterprise controls, private forks and integration with TokenOptimizer.

A note on lineage

BlackRiver Gateway is a BlackRiver AI product. The architecture, UX patterns and provider-fallback model draw from open-source AI router projects in the wider community. Original licenses, attribution and notices are preserved in the public repository and documentation.