Self-hosting a gateway vs buying a relay service: cost and where each fits

Tutorials Published 2026-09-24 Updated 2026-09-27 67 views API Compass
Self-hosting sounds cheaper and more controllable, but the real cost is not the server. This article totals up both the visible and hidden costs and gives a usable decision boundary.

What self-hosting solves

With an open-source gateway such as One API, New API or LiteLLM, running your own relay service gets you three things:

  1. You hold the data - no third party in the request path
  2. No rate markup - you pay the official price
  3. Full control - auth, quotas and logs are all yours to define

All three are genuine value. But the price of them is routinely underestimated.

Visible costs

ItemRough order of magnitude
ServerA lightweight cloud instance, a few hundred CNY a year
Domain and certificateTens to hundreds of CNY a year
Upstream API spendAt the official price; this is where you save the rate markup

Looks modest. The real cost comes next.

Hidden costs (this is the important part)

One: obtaining upstream keys

Self-hosting means registering with each vendor's platform yourself, completing identity checks and attaching a payment method.

How hard that is varies by vendor: some want an overseas credit card, some want company credentials. If the reason you went to a relay service in the first place was "I have no way to pay overseas", self-hosting stalls right here.

Two: the cost of designing for high availability

A single-instance gateway that dies takes everything down. High availability means dealing with:

  • Multiple instances plus load balancing
  • High availability for the database (keys, quotas, logs)
  • Health checks and failover across several upstream channels

This is not the complexity of "run one Docker container and you are done".

Three: ongoing maintenance

Upstream interfaces change. Vendors ship new models, adjust protocols, change parameters - and the gateway has to follow. Open-source projects do not always keep pace.

This is a recurring commitment, not a one-off job.

Four: troubleshooting

When something breaks you have to work out yourself whether it is:

  • The gateway
  • The network on your server
  • The upstream

With a relay service there is at least a support desk to ask. When you self-host, there is only you.

The cost boundary

Converting the above into time (at a developer's hourly rate):

Self-hosted cost / month  ~ server cost + upstream API spend + maintenance hours x hourly rate
Relay service cost / month ~ usage x official price x rate

A rough guide:

Monthly API spendRecommendation
Below 1,000 CNYUse a relay service. Self-hosting costs far more in maintenance than the rate markup saves
1,000 - 5,000 CNYDepends on the team. If someone can maintain it, self-host; otherwise stay on a relay service
Above 5,000 CNYSelf-hosting starts to have a clear edge; the absolute size of the markup is now large

The decisive variable is whether anyone can maintain it. Without a dedicated person, the hidden costs of self-hosting overtake the benefit quickly.

A middle path

A self-hosted gateway on top of official upstreams, doing only unified auth and quotas - no complex routing:

your app -> self-hosted gateway (One API etc.) -> vendor official APIs

Benefits:

  • Data and billing stay in your hands (no third-party relay in between)
  • Complexity stays manageable (single instance plus regular backups is acceptable)
  • The team shares one key-management setup

Costs:

  • No alternative channel when an upstream wobbles (if the official side rate-limits you, you wait)
  • You have to track interface changes yourself

This suits teams with moderate data sensitivity and some technical capacity.

When not to self-host

  • Nobody on the team can maintain it over time
  • Obtaining upstream keys is itself blocked (no way to pay overseas, for example)
  • Usage is small enough that the savings do not cover the investment
  • What you need is to validate an idea quickly, not long-term infrastructure

That last one is very common: self-hosting a gateway before the product is validated puts your time in the wrong place.

Related reading

  • Official API vs relay service: where the difference really lies
  • Who handles your request: the data boundaries inside a relay chain
  • Specialist vs aggregator relay services: when a specialist is the better deal

Was this useful? If you have run into something the article does not cover, tell us and we will verify it and update the text.

Related articles

Video generation behind a relay: three API shapes, four billing traps, one acceptance checklist

2026-10-19

MCP through a relay: what works, what never will, and how to test it in ten minutes

2026-10-19

A relay selection decision tree: working back from your scenario to a site

2026-10-07

Logging and reconciliation: attributing token spend to the project level

2026-10-06

Migrating suppliers gradually: replacing an API site without interrupting service

2026-10-06

Build your own probe: twenty lines of script to monitor your API suppliers

2026-10-06

Read on: a few of the services we list

This article does not point at a specific model family, so here are a few of the highest-scoring services we list, in case you want to read on. They are ordered by score and uptime and are not a recommendation.

See the full list in the directory, or browse by model family.