fuse
Skip to content
Documentation

Set up Fuse in minutes.

Fuse is a drop-in endpoint, not a client library. Point your existing OpenAI or Anthropic SDK at the gateway, authenticate with a Fuse virtual key, and every guardrail — budgets, rate limits, fallback routing, loop detection, model ACLs, DLP — applies instantly.

Quickstart

  1. 1Sign up and open the dashboard. Email verification keeps accounts real.
  2. 2Add a provider key (Dashboard → Provider Keys). Your upstream credentials are encrypted at rest with AES-256-GCM and never logged in plaintext.
  3. 3Mint a virtual key (Dashboard → Virtual Keys). It starts with ash_live_ and carries your budgets, rate limits, and policy attachments.
  4. 4Swap your baseURL and use the virtual key as the API key. That's the whole migration:
client.ts — diff
- const client = new OpenAI({ baseURL: "https://api.openai.com/v1", ... });
+ const client = new OpenAI({
+   baseURL: "https://gateway.usefuse.dev/v1",
+   apiKey: process.env.FUSE_VIRTUAL_KEY, // ash_live_…
+ });

Endpoints

One virtual key reaches every provider. The route you call decides where the request goes; namespaced prefixes exist so an OpenAI SDK pointed at {gateway}/deepseek/v1 just works. Unknown paths return 404.

RouteProviderSDK compatibility
/v1/chat/completionsOpenAIOpenAI SDK
/v1/responsesOpenAICodex / Responses API
/v1/messagesAnthropicAnthropic SDK
/deepseek/v1/chat/completionsDeepSeekOpenAI SDK
/xai/v1/chat/completionsxAIOpenAI SDK
/gemini/v1/chat/completionsGeminiOpenAI SDK
/api/v1/chat/completionsOpenRouterOpenAI SDK

Provider setup

Authenticate to Fuse with your virtual key in the Authorization header — never your raw provider key. Anthropic requests should carry their usual anthropic-version header; it is forwarded upstream.

OpenAI — SDK

client.ts
const client = new OpenAI({
  baseURL: "https://gateway.usefuse.dev/v1",
  apiKey: process.env.FUSE_VIRTUAL_KEY, // ash_live_…
});

const res = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello" }],
});

Anthropic — SDK

client.ts
const client = new Anthropic({
  baseURL: "https://gateway.usefuse.dev",
  apiKey: process.env.FUSE_VIRTUAL_KEY, // ash_live_…
});

const res = await client.messages.create({
  model: "claude-sonnet-4-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

OpenAI — curl

curl
curl https://gateway.usefuse.dev/v1/chat/completions \
  -H "Authorization: Bearer $FUSE_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
# streaming: add "stream": true — SSE is piped through untouched

Anthropic — curl

curl
curl https://gateway.usefuse.dev/v1/messages \
  -H "Authorization: Bearer $FUSE_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model":"claude-sonnet-4-5","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'

DeepSeek / xAI / Gemini

Same OpenAI-compatible body, namespaced route. Point an OpenAI SDK at the prefixed baseURL or call the path directly:

curl
curl https://gateway.usefuse.dev/deepseek/v1/chat/completions \
  -H "Authorization: Bearer $FUSE_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hello"}]}'

# also available: /xai/v1/chat/completions · /gemini/v1/chat/completions
# bare /chat/completions after the prefix works too: /deepseek/chat/completions

OpenRouter

curl
curl https://gateway.usefuse.dev/api/v1/chat/completions \
  -H "Authorization: Bearer $FUSE_VIRTUAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-4o","messages":[{"role":"user","content":"Hello"}]}'

Use Fuse with AI coding agents

Coding agents speak the OpenAI or Anthropic protocols, so they work with Fuse unchanged — point them at the gateway with your virtual key and every agent session gets budgets, rate limits, fallback routing, model ACLs, and DLP. Set the key in an environment variable and never paste it into a committed config file.

Claude Code

Claude Code sends Bearer auth to ANTHROPIC_BASE_URL, which is exactly what Fuse's Anthropic route expects. Use ANTHROPIC_AUTH_TOKEN (not ANTHROPIC_API_KEY — that sends an x-api-key header). Claude Code forks work the same way.

shell
export ANTHROPIC_BASE_URL="https://gateway.usefuse.dev"
export ANTHROPIC_AUTH_TOKEN="ash_live_…"   # Fuse virtual key
claude
Setup notes
  • Persistence: To save permanently, add these environment variables to the env block of ~/.claude/settings.json — never in a project-level settings file that gets committed.
  • Provider key: Ensure your virtual key has an Anthropic provider key attached in the dashboard.

OpenAI Codex CLI

Codex reads ~/.codex/config.toml. Codex speaks the OpenAI Responses API by default — Fuse proxies /v1/responses natively, so no wire_api override is needed.

~/.codex/config.toml
model_provider = "fuse"
model = "gpt-4o"

[model_providers.fuse]
name = "Fuse"
base_url = "https://gateway.usefuse.dev/v1"
env_key = "FUSE_VIRTUAL_KEY"

Export your virtual key in your terminal:

shell
export FUSE_VIRTUAL_KEY="ash_live_…"
codex
Setup notes & troubleshooting
  • Config placement: Place model_provider and model at the top of ~/.codex/config.toml before any table headers ([...]); otherwise Codex ignores the provider setting.
  • OAuth session conflict: If Codex returns an upstream 401 error, it may still be logged into a ChatGPT account — run codex logout so it falls back to your configured env_key.
  • Environment scope: The environment variable must be set in the shell session that launches Codex. If a background daemon is running, terminate it and relaunch from a fresh shell to pick up new keys.
  • Key validation: An error like 401 invalid_key means the virtual key was not found or was revoked. Confirm your key exists in Dashboard → Virtual Keys.

Antigravity CLI (agy)

Antigravity CLI speaks Google's Cloud Code protocol natively, but version 1.2.15+ supports an enterprise-gateway mode using the OpenAI Chat Completions protocol — exactly what Fuse serves on the /gemini/v1 route. Configure it via environment variables:

shell
export AGY_LLM_GATEWAY_URL="https://gateway.usefuse.dev/gemini/v1"
export AGY_LLM_GATEWAY_API_KEY="ash_live_…"   # Fuse virtual key
export AGY_LLM_GATEWAY_WIRE_PROTOCOL="openai"
export AGY_LLM_GATEWAY_MODELS="gemini-2.5-flash,gemini-1.5-pro"

agy -p "Explain binary search in Go"   # runs through Fuse gateway
Setup notes & troubleshooting
  • Provider key: The virtual key must have a Gemini provider key attached (Dashboard → Provider Keys) — Fuse routes by path, so /gemini/v1 always forwards to Google Gemini.
  • Path resolution: Fuse serves Gemini on both /gemini/v1/chat/completions and /gemini/chat/completions. If your client version appends /v1/chat/completions automatically, set AGY_LLM_GATEWAY_URL="$https://gateway.usefuse.dev/gemini".
  • Model selection: AGY_LLM_GATEWAY_MODELS defines the comma-separated list populated in agy's interactive model picker.
  • Process reload: Set variables in a fresh terminal session before invoking agy.

OpenCode

Add Fuse as a custom OpenAI-compatible provider in opencode.json. The {env:…} syntax references your shell variable so API tokens are never saved into repository files.

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "fuse": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Fuse",
      "options": {
        "baseURL": "https://gateway.usefuse.dev/api/v1",
        "apiKey": "{env:FUSE_VIRTUAL_KEY}"
      },
      "models": {
        "anthropic/claude-3.5-sonnet": { "name": "Claude 3.5 Sonnet" },
        "openai/gpt-4o": { "name": "GPT-4o" }
      }
    }
  },
  "model": "fuse/anthropic/claude-3.5-sonnet"
}

Export your virtual key before starting OpenCode:

shell
export FUSE_VIRTUAL_KEY="ash_live_…"
opencode
Setup notes
  • Base URL structure: baseURL must end at /api/v1 — OpenCode automatically appends /chat/completions.
  • OpenRouter upstream: When using OpenRouter routes (/api/v1), ensure your virtual key is linked to an OpenRouter credential in Dashboard → Provider Keys.
  • Model IDs: Use standard model identifiers (e.g. anthropic/claude-3.5-sonnet or openai/gpt-4o) matching the upstream provider catalog.

Anything else (Cursor, aider, …)

Any tool with a custom OpenAI endpoint setting works the same way:

ToolSetting
CursorModels → OpenAI API Key → Override Base URL: https://gateway.usefuse.dev/v1
aiderexport OPENAI_API_BASE=https://gateway.usefuse.dev/v1 + OPENAI_API_KEY
Any OpenAI SDKbaseURL: https://gateway.usefuse.dev/v1, virtual key as the API key

Want a specific agent routed through Anthropic models instead? Point it at the Anthropic-compatible surface ( https://gateway.usefuse.dev/v1/messages with Bearer auth) or use a namespaced prefix like https://gateway.usefuse.dev/deepseek/v1.

Guardrails & routing behavior

Technical reference for how Fuse inspects, gates, and routes traffic at the edge before sending requests upstream.

COST ENFORCEMENTBudgets & Sliding-Window Rate Limits

Spend is tracked atomically per virtual key in distributed Redis cache. At 80% of your budget cap, an automated alert email is triggered. At 100%, Fuse returns 429 budget_exceeded pre-flight — zero upstream spend is incurred. Sliding-window requests-per-minute (RPM) limits enforce fair usage per key.

FAILOVER ENGINEAutomatic Circuit Breaking & Fallback Chains

When upstream providers return 429, 5xx, or timeout, Fuse walks your fallback chain (e.g. Claude Sonnet → GPT-4o → DeepSeek-V3). Client errors (4xx) terminate immediately without wasting retries. All fallback responses carry the x-fuse-fallback-model header so you always know which model answered.

AGENT SAFETYTool-Call Loop Detection

Fuse maintains SHA-256 fingerprints of consecutive tool-call outputs across a sliding 120-second window. If an autonomous agent (like Claude Code or Codex) becomes stuck in a recursive loop firing identical calls, Fuse intercepts the stream and returns 429 loop_detected before your budget is burned.

ACCESS CONTROLModel Allow / Block Lists

Attach guardrail policies to restrict which models or providers a virtual key can invoke. Calling a blocked model immediately aborts with 403 model_access_denied before touching any provider API. Fallback chains automatically drop blocked models as inert targets.

DATA PROTECTIONSensitive Data & Secret Scanning (DLP)

Scans the newest user message at the network perimeter for system credentials (AWS keys, GitHub tokens, Slack tokens, private PEM keys, DB connection strings) and PII (credit cards with Luhn validation, SSNs, emails, IPs), plus custom user regexes. Supports Redact (default in-place substitution), Block (422 sensitive_data_blocked), or Log only. Scanners are built to fail open: scanner errors will never disrupt production traffic.

OBSERVABILITYZero-Latency Async Telemetry

Server-Sent Events (SSE) streaming responses are piped byte-for-byte to your client without buffering delay (<15ms edge overhead). Token counting and estimated cost calculations are synced asynchronously in the background via ctx.waitUntil(), logging to your dashboard in real time.

Error reference

Fuse returns machine-readable error codes so your retry logic can react precisely instead of string-matching messages.

StatusError codeMeaning
401invalid_keyVirtual key not found, revoked, or missing/invalid bearer token.
403model_access_deniedA guardrail policy blocked this model or provider for the key.
404not_foundUnknown route or unsupported path — check the endpoint table above.
422sensitive_data_blockedDLP action is set to block and the newest user message matched a rule.
429budget_exceededVirtual key hit its hard spend cap; rejected before any upstream call.
429rate_limit_exceededPer-key requests-per-minute limit exceeded.
429loop_detectedRepeated identical tool-call results over a 120-second window.
502upstream_unavailableEvery target in the fallback chain failed. Safe to retry with backoff.

Response headers worth watching: x-fuse-fallback-model names the backup model that answered when failover or auto-downgrade occurs (omitted when the primary model serves the request), and x-fuse-quota is stamped with overage when your monthly request volume exceeds your plan allowance.

Support

Stuck on setup? We answer.