Self-hosting one-api / new-api vs. a Managed AI Gateway: Cost, Ops & Security
"Should we run our own one-api?" is a question almost every team doing multi-model access eventually faces. Online answers are polarized: the open-source camp says "it's half an hour of work", the managed camp says "self-hosting is digging your own pit". Both have a point, and both skip the crucial context. This article gives you an honest decision framework. We operate a managed gateway ourselves (4-4 AI, built on the new-api ecosystem), so we will flag the judgments that favor us — adjust for that bias with your own data.
First, three concepts
- one-api: the open-source LLM gateway — OpenAI-compatible protocol, multi-channel management, token issuance;
- new-api: a fork of one-api with broader channel adapters and richer billing features;
- Managed gateway (e.g. 4-4 AI): someone else runs the above for you and adds commercial capabilities (billing, prepaid cards, usage reports, high availability) — you just top up and use.
Essentially, self-hosting vs. managed is not about features. It is about who owns operational responsibility and failure risk.
Dimension 1: cost model — the hidden cost list of self-hosting
The explicit cost of self-hosting is simple: one server plus a database. The real difference is in the hidden parts:
| Cost item | Self-hosted | Managed |
|---|---|---|
| Server + database | monthly fee, plus backup storage | none (included in the service fee) |
| Version upgrades & security patches | you perform every upgrade; you fix every failure | platform responsibility, invisible to users |
| Channel maintenance | upstream changes an endpoint — you update channel configs | platform maintains channel health |
| Incident response | it breaks at 3 a.m., you crawl out of bed | SLA / platform on-call |
| Backups & restore drills | you must build it — and actually rehearse it | platform duty |
| Security hardening | exposed databases, weak passwords, unauthorized access — all on you | platform baseline |
A practical way to estimate:
Self-host monthly cost ≈ server fees
+ maintenance hours per month × your hourly rate
+ expected loss of one major incident (downtime × business loss)
Once items two and three are written down explicitly, most small teams flip their conclusion — at low usage, the "free" self-hosted setup is actually more expensive. Conversely, if you have dedicated ops staff, very high volume, and strict data-sovereignty requirements, the self-hosting math can work.
Dimension 2: operations — what you actually sign up for
Most tutorials stop at "docker run and you're done". Long-term operation of a new-api instance at least involves:
- Data layer: backup strategy for MySQL/SQLite, disk-water monitoring. One server reinstall without backups — channel configs, tokens, user data all gone. This incident pattern shows up constantly in community forums;
- Process supervision: register a systemd service or use container orchestration so the service survives reboots. A bare
nohupdeployment disappears the first time the server restarts; - Security baseline: never expose the database to the public internet, change every default password, configure and renew HTTPS certificates, rotate logs;
- Upgrade cadence: upstream updates are frequent; schema-changing upgrades require a backup-first procedure;
- Observability: usage stats, anomaly alerts, per-channel success-rate monitoring — all self-assembled.
On a managed platform, none of these five items exist for you. The price is accepting the platform's rules and pricing.
Dimension 3: security — the biggest gap in responsibility
Self-hosted gateway incidents follow highly repetitive patterns:
- database (e.g. MySQL 3306) exposed to the public internet, getting scanned and brute-forced;
- console left with default admin credentials, tokens issued by anyone;
- upstream keys stored in plaintext env files or repos, leaking with the codebase.
A managed platform turns these into platform responsibility. If you self-host, do at least these four: bind the database to 127.0.0.1, change every default password, enable HTTPS, export database backups off-box regularly. Those four block the vast majority of incidents.
Dimension 4: decision matrix — pick by your stage
| Your situation | Recommendation |
|---|---|
| Personal project / small team, no dedicated ops | Managed gateway. Hidden costs dwarf the service fee; time-to-market wins |
| Mid-size team, stable growth | Start managed; revisit self-hosting only when gateway fees become a significant line item |
| Ops team + high volume + data-sovereignty needs | Self-hosting is reasonable. Base it on new-api, then complete the ops checklist above |
| Reselling API access as a business | Harder call: self-hosting gives control but heavy duty; choose managed only after confirming multi-tenant billing / prepaid-card support |
There is also a middle path: validate the business on a managed gateway first, keep your engineering hours on the core product, and migrate to self-hosting once volume justifies it. Gateways are OpenAI-compatible — migration is one Base URL switch.
FAQ
one-api or new-api — which to self-host?
Most of the fork ecosystem (including our own codebase) has moved to new-api; channel adapters are more active there. But the choice doesn't change the core fact: you own all the ops.
Is self-hosting really cheaper?
Run the formula above — don't count only server fees. Maintenance hours and expected incident loss are usually the bigger terms. The higher your volume and ops maturity, the better self-hosting gets.
Is a managed gateway slower?
Same-datacenter-class forwarding latency is milliseconds on both paths; the bottleneck is almost always the upstream model, not the gateway. When choosing, care more about channel stability and failover than about latency marketing.
How hard is migrating from self-hosted to managed?
Business-side, swap the Base URL from your self-hosted domain to the managed one and change the key. The protocol is fully compatible — no business code changes.
Related articles
One key for GLM, DeepSeek, Qwen and more — unified billing and usage analytics.
View models & pricing Get started