OctaFuse/octafuse-gateway

Octafuse Gateway是可自托管的开源 AI Gateway:把多供应商、多账号、多 API Key 收成一个 Base URL、一个 API Key,并带路由、预算、计费与审计。

What is OctaFuse Gateway?

OctaFuse Gateway is a self-hostable, open-source AI gateway built for AI agents. It gives you one central place to connect, manage, and pay for many different AI services — text, images, speech, and agent tools — instead of dealing with each provider separately.

It is licensed under AGPLv3 and requires Node.js 20+.

Main idea

Instead of configuring every AI provider and tool separately, you set up OctaFuse once. Then your apps and agents talk to one gateway address, and OctaFuse handles routing, keys, budgets, billing, and logging.

What it can do

1. Connect many AI providers

  • Supports OpenAI, Anthropic, Google Gemini, DashScope (Alibaba Cloud), MiniMax, and Volcengine Ark endpoints.
  • Has built-in import templates for many providers and models, so you don’t have to manually enter endpoints and prices.

2. Speak multiple API protocols

It exposes familiar endpoints, including:

  • OpenAI-style: Chat Completions, Responses, Images, Audio, Models
  • Anthropic-style Messages
  • Google Gemini generateContent
  • DashScope native endpoints for ASR, TTS, image generation, and real-time audio
  • MiniMax native endpoints for speech-to-text, TTS, and image generation
  • Volcengine Ark endpoint for Seedream image generation

It can also convert between protocols — for example, you can use an OpenAI image API call to reach Alibaba Cloud’s Qwen/Wanxiang models or MiniMax image models.

3. Provide agent tools

OctaFuse includes built-in tools for agents, all under /v1/tools/*:

  • Web search (Bocha, Tavily, Alibaba CleverSee, Tencent WSA, DeepSeek Search)
  • Web fetch/scraping (Firecrawl, Tavily Extract, Jina Reader, DeepSeek Fetch)
  • Deep search (search + read combined)
  • AI detection (Tencent TMS currently)

These tools also get logging, billing, and cost control.

4. Smart routing

If you have multiple providers for the same model, you can choose routing strategies:

  • hash_affinity — same user/model stays on the same provider, good for prompt cache and session continuity
  • weighted_random — random by weight, good for load balancing and A/B testing
  • weight_priority — fixed priority order, good for primary/backup setups
  • weighted_round_robin — rotates evenly by weight

5. User management and billing

  • Three-level structure: External system → User → API key
  • Two quota types: periodic (subscription-style) and permanent (top-up style)
  • Three ledgers per call: catalog price (standard price), cost price (what you actually pay), user price (what the user is charged)
  • Peak/off-peak pricing by model and route, with weekday/weekend differences
  • Per-user model multipliers: discount, markup, or free

6. Admin panel and API

  • Full admin console for managing providers, routes, users, and keys
  • Playground and simulator for testing providers, models, routes, and real-time speech recognition
  • Detailed request logs and analytics

7. Flexible deployment

  • Cloudflare Workers + D1 (free tier possible)
  • Docker + PostgreSQL / MySQL

Quick start

Run two terminals:

git clone https://github.com/OctaFuse/octafuse-gateway.git
cd octafuse-gateway
npm install
npm run db:migrate

Terminal 1 — proxy service on :8787:

npm run dev:proxy

Terminal 2 — admin panel on :8789:

npm run dev:admin

Default local admin login: admin / admin

For Cloudflare deployment:

npx wrangler login
npm run bootstrap:cloudflare

How it compares to other AI gateways

The README compares OctaFuse with New API, LiteLLM, Sub2API, and Bifrost. OctaFuse focuses on agent capability delivery and AI resource operations, with strengths in:

  • Built-in agent tools (search, fetch, deep search) with billing
  • Provider/model presets and one-click import
  • Fine-grained routing with cache affinity and failover
  • Triple-ledger billing with time-based pricing
  • Flexible deployment including Cloudflare Workers edge

It currently covers text, images, ASR, TTS, and real-time voice — but not video as a unified request entry.

Documentation

  • User docs: docs/users/
  • Developer docs: docs/developers/
  • Operator/deployment docs: docs/operators/
  • HTTP examples: examples/

License

GNU Affero General Public License v3.0 (AGPLv3) — see LICENSE.

Related

  • Project
  • Project
  • Project
  • Project
  • Dispatch