LiteLLM is free software that you run yourself; a hosted LLM gateway is a service someone else runs and you pay for through token rates or credit fees. Self-hosting wins when you already operate servers, need your own provider contracts or a private network path, or spend enough that a few percent of your bill is worth more than a few hours a month. A hosted key wins when you want one base URL working this afternoon.
What is the real difference between LiteLLM and a hosted gateway?
The difference is who runs the software, and everything else follows from that. LiteLLM’s own documentation describes the LiteLLM AI Gateway as a self-hosted server that gives applications one OpenAI-compatible endpoint for 100+ providers, MCP tools and agents. You start it with Docker, Helm or Terraform, connect a Postgres database, add the models you want to offer, and hand out virtual keys. A hosted gateway is the same idea with the server removed from your life: you get a base URL and a key, and the operator keeps the software running.
That sounds like a clean split between a free tool and a paid service. It is not quite that. LiteLLM’s repository README links a hosted proxy and an enterprise tier next to the open-source project, and hosted gateways differ widely in how they charge. OpenRouter’s FAQ describes a fee on credit purchases, Vercel’s AI Gateway says it adds no markup on tokens, and Cloudflare’s AI Gateway makes its core features free while charging a fee on its own credits. The honest framing is not “free versus paid”. It is “I pay in hours, or I pay in fees and margin”.
| Self-hosted LiteLLM | Hosted gateway (including us) | |
|---|---|---|
| Who runs the server | You | The operator |
| What you need first | A server, Postgres for virtual keys, a master key, TLS | A sign-up and a key |
| Provider accounts | One per provider you use, with your own keys | None: one balance pays for every listed model |
| Model list | Whatever providers you connect, 100+ supported per LiteLLM | What the operator lists: 47 free models plus the priced catalogue here |
| Your own provider contracts | Yes | No bring-your-own-key here (OpenRouter offers it) |
| Spend per key, team, user | Virtual keys with budgets and rate limits, tracked per key, team, user and tag | Per-key spend limit, expiry, model list and requests per minute here |
| Updates and security patches | You apply them | The operator applies them |
| Who is paged when it breaks | You | The operator, with no uptime guarantee from us |
| Cost shape | Servers plus time, and no gateway fee | Credit fee or margin in the token rate, no hours |
A third option sits between these two that people forget: a gateway that is open source but also offered as a service. Portkey’s open-source gateway is an example, and our Portkey comparison says where it is the better fit. Our companion posts cover the wider market: the guide to OpenRouter alternatives sets seven options side by side, and what an LLM gateway is explains the layer itself.
What do you actually have to run to self-host LiteLLM?
You run a proxy process, a Postgres database, a reverse proxy for TLS, and a way to notice when any of them stops. The first two come from LiteLLM’s documentation. The last two come from every production service, and they are the part people leave out of the cost estimate.
Start with what the virtual keys page lists under requirements: a Postgres database, a DATABASE_URL environment variable and a master key that begins with sk-. With those set, you create keys by calling the key-generation endpoint with the master key, and spend is recorded against each key, user and team in that database. A minimal configuration, shaped like the one in LiteLLM’s docs, looks like this.
# config.yaml: the shape LiteLLM's own docs show for a proxy with virtual keys
model_list:
- model_name: my-chat-model
litellm_params:
model: <provider>/<model-id>
api_key: os.environ/PROVIDER_API_KEY # one entry, and one provider account, per model you offer
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY # the admin key, must start with sk-
database_url: "postgresql://<user>:<password>@<host>:<port>/<dbname>" # virtual keys need PostgresFour things in that file are worth noticing. Every model you offer is a model_list entry that points at a provider with a key you hold. The master key is a secret you now guard, and the API key security guide applies to it with extra force, since it can mint other keys. The database holds your spend history, so it needs backups and a restore you have actually tried. And none of this includes the TLS certificate, the firewall rule, the deployment pipeline or the monitoring.
What a self-hosted stack involves
None of this is a criticism of LiteLLM. Its documentation is clear about the steps, and it explains when you should not bother: use the gateway if more than one application or person sends requests to models, or if you need virtual keys, spend tracking, central logs or guardrails, and use the Python SDK if one Python application needs none of that. Our point is only that “free” describes the licence, not the project. The vendor also quotes a low overhead figure in its README (a P95 latency of 8 ms at 1,000 requests a second); that is the vendor’s own benchmark and we have not measured it.
What does a hosted gateway take off your plate?
A hosted gateway takes the servers, the database, the patching and the provider accounts. You send a request in the OpenAI or Anthropic format, the gateway checks your key and balance, forwards the call, streams the answer back and writes one usage record. Our routing and privacy documentation walks through every step of that path, and the gateway page describes the product.
What a hosted stack involves for you
On our gateway, the pieces you would otherwise build are these. Keys carry a spend limit, an expiry date, a model allowlist and a requests-per-minute limit, and the authentication guide shows each. The gateway retries the model you named up to twice, and if the model is still failing (a usage limit or any other issue), fallback rules, presets and automatic routing move the request to another similar model. You can name up to three fallback ids in an X-Fallback-Models header, the free lane also retries a failing :free call on another model by itself, and only the attempt that answers is billed; the failover rules give the detail. Every request leaves a usage record you can read and export, and the billing documentation shows how a charge is computed so you can recompute one by hand. Our headers reference lists the extras.
Here is the other side, and it matters for this comparison. A hosted gateway gives you only the models it lists. We do not offer bring-your-own-key, so you cannot route through us with a provider contract you already negotiated. We have no teams or single sign-on. We do not let you run custom code in the request path. And we cannot promise uptime, which is exactly what our transparency page says about the models we do not host ourselves. If any of those is a requirement, self-hosting is not just cheaper in some scenarios, it is the only option.
import os
from openai import OpenAI
# Self-hosted LiteLLM: your server, a virtual key it issued
# client = OpenAI(base_url="http://localhost:4000", api_key=os.environ["LITELLM_VIRTUAL_KEY"])
# Hosted gateway: the same client, two values different
client = OpenAI(base_url="https://api.oneaiapikey.com/v1", api_key=os.environ["ONEAIAPIKEY_API_KEY"])
reply = client.chat.completions.create(
model="z-ai-glm-5.3:free", # the id comes from the gateway's own model list
max_tokens=100,
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(reply.choices[0].message.content)The code above is the point of the whole comparison, in miniature. Both options present an OpenAI-format endpoint, so the application does not care which one it is talking to. That is also why this is a reversible decision, a point we return to below.
What does each option cost, and where do they break even?
Self-hosting costs a fixed monthly amount that does not grow with your usage. A hosted gateway usually costs a percentage that does. The break-even point is the monthly spend where the two are equal, and it is easy to compute once you are honest about the hours.
The percentage side has published numbers. OpenRouter’s pricing page and FAQ describe a 5.5% fee, with a $0.80 minimum, on credit purchases and 5% on crypto, with inference passed through at the provider’s price. Vercel’s pricing page says there is no markup and no platform fee on tokens, including when you bring your own key, though you pay payment-processing fees. Cloudflare’s pricing page lists analytics, caching and rate limiting as free on all plans and a 5% fee on Unified Billing credits. All three were read on 26 November 2026, and our guide to gateway fees lays them out in one place.
Ours is different in shape, and we would rather say so than hide it. There is no fee when you add credit: the amount you add is the amount you receive. The money we earn sits inside the per-token rate, which our transparency page describes as what upstream providers charge us plus a margin. For some models our rate is below the maker’s list price during a promotion, and the discounted models page shows which. So for us the “fee” is not one percentage, it is a gap between our rate and a rate you could get elsewhere, and it can be positive or negative per model. To compare fairly, take a model’s rate on its page and the same model’s price from the provider you would otherwise use, compute the gap on your monthly tokens, and enter that gap as a percentage below.
Self-host or hosted: where is the break-even?
- Self-hosting, monthly cost
- $280.00
- Hosted overhead at your spend
- $165.00
- Cheaper at this spend
- Hosted
- Break-even monthly spend
- $5,090.91
- Above this, the percentage costs more than the fixed bill.
- Most hours a month self-hosting can take and still cost less
- 2.08
Every default is a placeholder to replace with your own numbers, not a quote from any vendor. The 5.5% is OpenRouter's published credit fee, read on 26 November 2026. It ignores free tiers, volume terms, provider discounts you might hold directly and the cost of an outage.
Try the defaults and one change at a time. At $3,000 a month of tokens and a 5.5% overhead, the hosted bill is $165. Self-hosting at $40 of infrastructure plus four hours at $60 is $280. The hosted route is cheaper by $115. Raise spend to $6,000 and the percentage is $330, which is more than $280, so self-hosting starts to win. Set the hours to zero and it wins at a much lower spend. That is the trap: most people price their own time at zero, and then self-hosting looks free.
Break-even monthly spend at a 5.5% overhead
- No hours counted$727$40 of infrastructure only
- 2 hours a month$2,909$40 plus 2 hours at $60
- 4 hours a month$5,091$40 plus 4 hours at $60
- 10 hours a month$11,636$40 plus 10 hours at $60
Two lessons come out of that chart. The first is that a small team spending a few hundred dollars a month is nowhere near break-even unless it counts its own time as free, which is a fair choice for a hobby and a poor one for a company. The second is that the number only grows with the hours you honestly expect to spend. An unexpected upgrade, a certificate that lapses on a Sunday or a database that fills up all take hours you did not plan. If you want to see what your tokens cost before any gateway, the cost calculator turns token counts into dollars, and the guide to estimating a monthly LLM bill walks through three examples. Cutting the token bill itself usually beats shaving the gateway percentage, and ten ways to reduce LLM API costs ranks the tactics, while the per-million rates of cheap open models show how wide the gap between models is.
One more cost belongs in the sum, and it points the other way. Self-hosting lets you pay each provider directly, so you keep whatever volume terms or credits you hold with them. If you spend very large amounts, or have negotiated rates, that is a real advantage a hosted gateway cannot match. If you spend modest amounts, the same arrangement means five invoices, five sets of rate limits and five accounts to keep funded, which is its own tax on attention. Our guide to prepaid credits covers the funding side.
Who gets paged when it breaks?
With self-hosting, you do. With a hosted gateway, the operator does, and you find out from a status page or from your own errors. Neither option makes the underlying model providers any more reliable.
LiteLLM’s documentation lists load balancing, fallbacks and retries among the gateway’s reliability features, which means it can move traffic between deployments when a provider has a problem. That is useful, and it is also software you configure and test. If the proxy itself stops, or the database behind it fills up, every application that points at it stops with it, which makes a self-hosted gateway a single point of failure until you run more than one copy. Google’s SRE book frames this as a trade, not a rule: its chapter on embracing risk treats reliability targets as a cost decision, because each extra step of availability costs more than the last.
On a hosted gateway, we run the proxy, the database and the pager, and we say plainly that we do not guarantee uptime. The terms of service state that, and what we publish instead is evidence: the status page probes every listed model every few minutes, and each model page carries a 24-hour uptime strip. A model that answers nothing for a week comes off the list. When a request fails before answering, the gateway retries the named model twice and then fallback rules, presets and automatic routing can move it to another similar model, the same layer that handles 429 errors from a provider. Our guide to LLM API uptime and fallbacks shows the arithmetic of how much a second route is worth, and it applies equally to a LiteLLM setup.
The honest comparison is this. A hosted gateway has a team behind the pager, but the team is us, a small independent platform, and we are not a cloud provider. A self-hosted gateway has exactly the reliability you build. If you have an operations team and runbooks, yours may well be better than ours. If you do not, ours is probably better than yours would be on day one, and the free lane is a cheap way to find out whether it is good enough for you. Any middleman can be wrong about what it serves, us included, which is why the reseller risks research is worth reading before you trust a cheap hosted route.
How do keys, budgets and spend tracking compare?
LiteLLM is richer here, and this is where a team that needs structure should lean toward it. Its virtual keys documentation describes keys with their own models, budgets and rate limits, owned by users and teams, with spend tracked per key, per user, per team and per end user, plus an admin interface for generating and editing keys with single sign-on. The same page also spells out how a key inherits settings from its owner, which is a sign of how much structure is available, and how much there is to configure correctly.
Ours is a smaller, simpler set, built for individual developers and small teams. A key can carry a spend limit, an expiry date, a model allowlist and a requests-per-minute limit, and there is a per-end-user budget for apps that serve other people. Usage records show the request, key, model, tokens, cost and request id, with date ranges and CSV export. The guide to one key per project with spend limits shows the pattern, and the cost-control documentation lists habits that keep a bill predictable.
| Control | LiteLLM virtual keys | Our keys |
|---|---|---|
| Spend limit | Budget per key, user or team | Spend limit per key |
| Model access | Models per key and per team | Model allowlist per key |
| Rate limits | Per key and per owner | Requests per minute per key |
| Who owns a key | User or team, with inheritance rules | The account |
| Expiry | Keys can expire | Expiry date per key |
| Per end user | Customer and end-user tracking | Spend per end user on a key |
| Admin screens | Admin UI with single sign-on | Console for one account |
| Where the data lives | Your Postgres database | Our usage records, tokens and cost only |
If your table needs rows we do not have, such as teams, owners and inheritance, that is a real reason to self-host. If it does not, the extra structure is cost you pay in setup, and in the risk of a misconfigured key that quietly has more access than you meant. Our authentication guide explains how we keep the model simple.
What about privacy and control of your data?
Self-hosting gives you control over what your own proxy logs, and it does not change what the model provider sees. In both cases the full prompt travels to the provider that runs the model, under that provider’s terms. The difference is whether a second company handles the request on the way.
With LiteLLM you decide what is logged, where logs go and who can read them, and its documentation lists guardrails such as content filters and PII masking among the gateway’s features. That control is real, and it comes with a duty: your Postgres database and your logs are now data you protect. On our side, by default what you send is not stored: prompts and answers pass through and are not kept. We keep counts (tokens, cost, timing, model, key name and request id), never content, we do not train on your data, and protecting your data is our top priority. Prompt logging is an opt-in per key, X-No-Log: true opts one call out, and content is captured only if you ask us to troubleshoot a request or we investigate abuse. The privacy policy has the full list, the routing documentation shows the record fields, and our guide to what a gateway sees and stores goes through the trade-offs.
If you want content checks before a request leaves, we offer per-key guardrails and PII redaction. They are simpler than what a self-hosted stack can be configured to do. For regulated data, or a contract that names a vendor, the safest answer is the one we give on the transparency page: use that vendor directly, with or without a gateway in front.
Can you start hosted and move to self-hosting later?
Yes, and that is the argument for starting hosted. Both options present an OpenAI-format endpoint, so the code that talks to one talks to the other. The things that tie you down are not the URL. They are model ids, the features you built on the proxy, and any budgets or keys stored in it.
Keep three values in configuration and nowhere else: the base URL, the key and the model id. The switching guide shows the environment variables for the OpenAI SDK, and the 12-factor config rule of keeping settings in the environment is the habit that makes the move cheap. Our migration guide covers the exact changes when you arrive, and the post on migrating from OpenRouter walks through them for another gateway.
The reverse also works. A team that starts with self-hosted LiteLLM and finds the hours are not worth it can move to a hosted gateway by changing the same values, then read one entry on the usage page to confirm the request landed. The only thing to carry across by hand is the rate card in your head: model ids differ between gateways, and a cheap model on one list may not exist on another.
Are you ready to run your own gateway?
0 of 8 ticked
Start hosted
Nothing here argues for running your own. Use a hosted key, keep the base URL in config, and revisit when one of these changes.
Which one should you pick for your situation?
Pick by the thing that hurts most today. The panel below gives a direct answer for four common situations, and none of them pretends the other side has no merits.
What describes you best?
One developer, a few projects
A startup shipping an AI feature
X-Fallback-Models and read the uptime guide. Revisit when spend passes your break-even.A company with an ops team and provider contracts
A team with strict data rules
For the wider decision across all gateway types, the 12-point provider checklist is the hub of this series, and the comparison page puts the main options side by side with dated sources.
What would we do?
We would start hosted, spend a week with real traffic, and only then decide. Self-hosting is a fine answer to a clear need, but it is a poor answer to a vague feeling that “free is cheaper”. We have a stake in that advice, since we run a hosted gateway, so here is how to check us rather than trust us.
- Read the numbers. Plug your real spend and an honest number of hours into the calculator above. If self-hosting wins at your volume, believe it.
- Test the free lane. Send the same prompts to two or three of the free ids on the free models list, and read the usage record for each request. It costs nothing, needs no balance and takes an afternoon. The six checks show how to confirm the model you named is the one that answered.
- Check what we cannot do. If you need bring-your-own-key, teams or an uptime guarantee, you have your answer and we would rather lose the sign-up than waste your week.
- Keep the exit open. Put the base URL, key and model id in configuration so either choice can be reversed in minutes.
The transparency page is where we say what we monitor and what we cannot see. On money, the policy is plain: once a key is created and its usage is consumed we do not give money back, and if the key does not work or there is a technical problem on our side, contact support at somdutt777@gmail.com with a genuine concern. The terms hold the wording, and the money-back terms checklist shows what to compare in any provider. A hosted gateway is a trade, and we would rather you make it knowing the terms. If you want an outside read of us first, the One AI API Key review is written in the same plain tone.
Try the hosted route before you build the self-hosted one
$10 sign-up credit, 47 free models sharing 100 requests and 3,000,000 tokens a day, no card.
The LiteLLM comparison sets the two side by side with dated sources, and the OpenRouter, Vercel and Cloudflare pages cover the other hosted options.
Frequently asked questions
Is LiteLLM free?
Do I need a database to run LiteLLM?
DATABASE_URL as requirements, plus a master key. A single script with a handful of models and no per-key controls is a smaller job. The moment you want a key per project with a budget, the database is part of the system and needs backups like any other.