Self-hosted gateway that exposes many LLM providers (OpenAI, Anthropic, Gemini, Vertex, Azure, AWS and more) behind one OpenAI-compatible API with load balancing.
cita-777/metapi
A self-hosted gateway that merges multiple AI relay sites (New API, One API, Sub2API and others) into one API key and endpoint with smart routing.
- Stars
- 3,334
- Forks
- 527
- Open issues
- 112
- Last commit
- 2 months ago
What is it?
Metapi aggregates several AI relay sites built on New API, One API, OneHub, DoneHub, Veloera, AnyRouter, Sub2API and similar panels, along with some OpenAI, Claude and Gemini compatible endpoints and OAuth-connected accounts. Downstream tools such as Cursor, Claude Code, Codex or Open WebUI connect to a single proxy endpoint and can call every discovered model through it, with models from upstream sites appearing automatically.
Requests are routed across channels using weighted probability based on cost, balance and usage rate. Failing channels are put into a cooldown period and requests are retried on other available channels. The dashboard tracks balances across sites, runs scheduled check-ins, refreshes balances hourly by default, and sends alerts through Webhook, Bark, Server酱, Telegram or SMTP.
Metapi ships as a single Docker container with SQLite by default, and can use MySQL or PostgreSQL as its runtime database. It is built with Fastify, React and TypeScript, and is licensed under MIT.
Key features
- 01Exposes OpenAI and Claude compatible endpoints, including chat, responses, embeddings and files.
- 02Discovers models from upstream sites automatically and builds the routing table without manual setup.
- 03Routes requests by weighted cost, balance and usage, with automatic failover and cooldown.
- 04Schedules daily check-ins and periodic balance refreshes for each account.
- 05Sends alerts through Webhook, Bark, Server酱, Telegram or SMTP email.
- 06Deploys as a single Docker container with SQLite, MySQL or PostgreSQL storage.
Use cases
- Consolidating API keys from several relay sites so editors and chat tools use one endpoint.
- Routing requests to the cheapest available channel for a given model.
- Tracking balances and check-in rewards across many relay accounts in one dashboard.
- Keeping AI tools working through upstream outages by failing over to other channels.
Quick start
- 1
Create a project folder
mkdir metapi && cd metapi - 2
Create the docker-compose.yml file with the README configuration
- 3
Set the admin token and proxy token, then start the container
export AUTH_TOKEN=your-admin-token && export PROXY_TOKEN=your-proxy-sk-token && docker compose up -d - 4
Open http://localhost:4000 and log in with AUTH_TOKEN
Things to know
- The README warns that the default admin token change-me-admin-token applies when running outside Compose without AUTH_TOKEN set, so credentials must be changed before use.
- Armv7l support covers only server and Docker deployment, with no desktop installer.
In collections
Topics
FAQ
- What is metapi?
- A self-hosted gateway that merges multiple AI relay sites (New API, One API, Sub2API and others) into one API key and endpoint with smart routing. Metapi aggregates several AI relay sites built on New API, One API, OneHub, DoneHub, Veloera, AnyRouter, Sub2API and similar panels, along with some OpenAI, Claude and Gemini compatible endpoints and OAuth-connected accounts. Downstream tools such as Cursor, Claude Code, Codex or Open WebUI connect to a single proxy endpoint and can call every discovered model through it, with models from upstream sites appearing automatically.
- Is metapi free to use? What license does it have?
- metapi is open source under the MIT license. Check the license terms before using it in commercial products.
- Is metapi still maintained?
- Updated within 6 months. The last commit to metapi was on Sep 6, 2026.
- What can I use metapi for?
- Consolidating API keys from several relay sites so editors and chat tools use one endpoint. Routing requests to the cheapest available channel for a given model. Tracking balances and check-in rewards across many relay accounts in one dashboard. Keeping AI tools working through upstream outages by failing over to other channels.
- How do I install metapi?
- Create a project folder: mkdir metapi && cd metapi Create the docker-compose.yml file with the README configuration Set the admin token and proxy token, then start the container: export AUTH_TOKEN=your-admin-token && export PROXY_TOKEN=your-proxy-sk-token && docker compose up -d Open http://localhost:4000 and log in with AUTH_TOKEN
- Where can I get metapi?
- The source code and installation instructions are on GitHub: https://github.com/cita-777/metapi
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Self-hosted, source-available LLM router that sends simple prompts to cheap or local models and complex ones to premium models, behind an OpenAI-compatible proxy.
A self-hosted AI gateway that exposes OpenAI, Claude and Gemini compatible APIs in front of many upstream model providers, with routing, keys, quotas and cost tracking.
An open source unified LLM gateway that exposes Anthropic, OpenAI, Gemini and other vendor models behind one endpoint and API key.
A self-hosted gateway that exposes multiple LLM providers behind OpenAI, Responses and Anthropic-compatible endpoints, shipped as a single executable.
A local model gateway that lets Claude Code, Codex, OpenCode and other coding agents share one endpoint and route requests across multiple model providers.