Self-hosted service
cita-777/metapi avatar
cita-777/metapi

metapi puts your relay accounts behind one key, and ships its admin token as a placeholder

把你在各处注册的 New API / One API / OneHub / DoneHub / Veloera / AnyRouter / Sub2API 等站点, 汇聚成 一个 API Key、一个入口,自动发现模型、智能路由、成本最优

3,300 stars526 forksTypeScriptMIT

At a glance

What is it?
metapi is a meta-aggregation layer over AI API relay platforms: New API, One API, OneHub, DoneHub, Veloera, AnyRouter, Sub2API, generic OpenAI and Claude compatible endpoints, and OAuth connections to Codex, Claude, Gemini CLI and Antigravity. It discovers models, splits traffic by weighted cost, balance and usage, and cools failed channels. It also handles your accounts' credentials, which is where the care has to go.
Who is it for?
metapi is worth setting up if you already pay for two or more relay platforms and the switching is costing you attention, because model discovery, cost weighting and failover are the parts it automates. It is not worth setting up to reach a model you do not already have access to, and the OAuth connectors make that concrete: they hold credentials for other services on your behalf, so those services terms, not this project's, decide whether the arrangement is allowed.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 29 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 5, 2026, and from our analysis. They are not legal advice.

Editorial analysis

A gateway whose upstreams are accounts you already hold

The framing is a layer above relay platforms. The upstream list has four groups: aggregation panels, namely New API, One API, OneHub, DoneHub, Veloera, AnyRouter and Sub2API; generic compatible endpoints, meaning OpenAI, Claude and Gemini compatible ones plus cliproxyapi and OrcaRouter; official presets, including Alibaba Cloud, Zhipu, a Doubao coding plan, DeepSeek, Moonshot's Kimi, MiniMax, ModelScope and others; and OAuth connections to Codex, Claude, Gemini CLI and Antigravity. Downstream, models are aggregated under /v1/* and tools such as Cursor, Claude Code, Codex and Open WebUI are meant to connect without knowing any of that. That last group is the one to think about. An OAuth connection means this gateway holds a credential for a different service and acts with it, so what governs it is that service's terms rather than anything written here. Everything upstream is a relationship you already had; the aggregator only changes where the traffic enters.

The routing weights are written down, and the cost signal has four levels

The routing engine is described with numbers rather than adjectives, which makes it easy to argue with. Traffic is split across channels by weighted probability, using cost at 40 percent, balance at 30 percent and usage at 30 percent. Cost itself resolves through four levels in order: measured cost first, then the cost configured on the account, then a catalogue reference price, and finally a default fallback when none of the others exist. That ordering matters, because the first level depends on what the upstream actually charged while the last is a guess, and a gateway that cannot tell you which level it used is a gateway you cannot predict. Failures are handled on a timer: a failed channel cools down for ten minutes by default, and a failed request retries on another available channel. The file also claims that every routing decision is visualised and explained, so the claim to check when you deploy is whether the dashboard shows which of the four cost levels produced a given price.

Automatic check-in is a cron expression, and it acts with your credentials

One feature needs reading twice before you enable it. The project lists daily check-in as a solved problem: instead of visiting each site to collect the daily allowance, a scheduled task performs it and tracks the rewards, with the schedule living in the configuration file as CHECKIN_CRON set to 0 8 * * *, meaning eight in the morning daily, alongside BALANCE_REFRESH_CRON at every hour. Token renewal works the same way, with expired tokens triggering an automatic re-login. The bullet describing that second one ends mid word in this version of the file, so the detail of what gets re-logged in to is not stated. Feature-wise the automation is ordinary; the judgement is yours, because a scheduled sign-in performed with your session on someone else's site is exactly the kind of action whose rules live in that site's terms, not in this repository. Capability also varies by upstream: adapters cover model enumeration and proxying everywhere, while balance queries and token management exist only where the upstream offers those interfaces, and OrcaRouter currently offers neither.

Three placeholders ship in the env file, and one instruction is easy to miss

The configuration template is where to look before deploying. It sets AUTH_TOKEN to change-me-admin-token and PROXY_TOKEN to change-me-proxy-sk-token, both obviously placeholders, and then ACCOUNT_CREDENTIAL_SECRET to REPLACE_WITH_STRONG_RANDOM_SECRET with a comment that says more than the other two lines do: generate a unique secret of 32 bytes or more, keep it out of git, and do not reuse AUTH_TOKEN. That last clause is the one worth internalising, because the credential secret is what encrypts the stored account credentials, so reusing the admin token would put the two secrets in the same value. ADMIN_IP_ALLOWLIST is empty by default, which means no address restriction, and the file also carries PORT set to 4000, DATA_DIR pointing at ./data, a timezone of Asia/Shanghai, and a notification cooldown of 300 seconds. Model availability probing is off by default, with concurrency 1, a thirty minute interval and a fifteen second timeout when you turn it on.

The public demo publishes its own admin token in the file

The demonstration instance is documented with its credentials, which is either careless or deliberate and the file argues for deliberate. The address is metapi-t9od.onrender.com, the administrator token is 123456, and the warning above it says the demo is a public environment, that you should not enter your API keys, account passwords or site information, and that the data may be cleared at any time. A second note explains the limits: it runs on Render's free plan and uses OpenRouter's free models, so only models with the :free suffix work. Read together, the two notes define the demo as a place to click through the interface and nothing else, which is a reasonable thing to publish and an easy thing to mistake for a working instance. The badge row above it also carries the same Docker Hub link twice, which is the only cosmetic error in an otherwise unusually careful header.

One entry point, two wire formats, and eight endpoint families

The proxy layer is where the compatibility claim is cashed out. Downstream it speaks both the OpenAI and the Claude format, and inside that it covers Responses, Chat Completions, Messages, legacy Completions, Embeddings, Images and Models, plus the standard /v1/files endpoint. Streaming is handled as server sent events with automatic conversion in both directions between the OpenAI and Claude shapes, which is what lets one key serve tools written against either vendor. That conversion is the part most likely to surprise you, since a format that round trips cleanly in text can lose a field that only one side sends, so the honest test of the gateway is a tool you already use rather than a curl request. Notification plumbing is broad and configurable: a webhook URL, a Bark URL, a ServerChan key, and Telegram with its own enable flag, bot token, chat id, message thread id, an overridable API base URL and a switch for using the system proxy.

An Electron shell around a Fastify server, with two lockfiles and a stale tag

The package is more than a server. Its main entry points at dist/desktop/main.js and electron-builder.yml sits at the root, so there is a desktop application wrapped around the gateway, with tsconfig.desktop.json type checking it and a dev script that starts the server, the web client, a TypeScript watcher and then waits for the server port, the dev server port and the built main file before launching Electron with two environment variables pointing it back at those local servers. Restart and update are shell and batch scripts at the root, update-and-restart.sh and restart.bat, which is what an application that manages itself looks like on disk. The engine requirement is Node 25 or newer. Alongside sit drizzle.config.ts and a drizzle directory for the database layer, vitest and vite configs, render.yaml and zeabur-template.yaml for two hosting paths, a docker directory, five TypeScript configs, and both package-lock.json and pnpm-lock.yaml even though the scripts call npm. Version 1.3.0 in package.json matches the newest tag from 2026-04-06, and the last push in this tree is dated 2026-09-06, five months later with no release since.

Editorial conclusion

metapi is worth setting up if you already pay for two or more relay platforms and the switching is costing you attention, because model discovery, cost weighting and failover are the parts it automates. It is not worth setting up to reach a model you do not already have access to, and the OAuth connectors make that concrete: they hold credentials for other services on your behalf, so those services terms, not this project's, decide whether the arrangement is allowed. Before you deploy, change all three placeholders in the env file, which means the admin token, the proxy token and the credential secret, and give the secret its own 32 byte random value rather than reusing the admin token. Set ADMIN_IP_ALLOWLIST to something narrower than empty. Read what automatic check-in does on the sites you connect, since that is a scheduled action performed with your credentials on a third party's site. And note the shape of the project itself: it is an Electron application with a Node 25 floor, two lockfiles in the tree, and no release since v1.3.0 in April, so pin a version before you depend on it.

Frequently asked questions

What is cita-777/metapi?

A meta-aggregation layer over AI API relay platforms. It turns several relay sites and compatible endpoints into one entry point with models aggregated under /v1/*, adding model discovery, weighted routing, failover and a dashboard. Its package version is 1.3.0 and it is MIT licensed.

How does metapi choose which upstream to use?

It splits requests across channels by weighted probability, using cost at 40 percent, balance at 30 percent and usage at 30 percent, and resolves cost through four levels: measured cost, account configured cost, catalogue reference price, then a default fallback. Failed channels cool down for 10 minutes by default and requests retry on another channel.

What are metapi's default configuration values?

PORT is 4000, DATA_DIR is ./data, check-in runs on 0 8 * * *, balance refresh on 0 * * * *, model availability probing is disabled, and ADMIN_IP_ALLOWLIST is empty. The admin token and proxy token ship as change-me placeholders, and the credential secret ships as a replace-me value the file says must differ from the admin token.

Does metapi have a desktop application?

Yes. The package main points at dist/desktop/main.js and electron-builder.yml is at the root, with a desktop dev script that starts the server, the web client and Electron together, update-and-restart.sh and restart.bat for restarting, and an engines requirement of Node 25 or newer.

Official sources

  1. cita-777/metapi on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/cita-777-metapi.svg)](https://hysenlabs.com/projects/cita-777-metapi)