How to build a self-hosted LLM API, from GPU to customer
A model on your own graphics card can answer your team or paying customers through an API, with a key for each of them, a price per token and a stop when the credit runs out, while the card itself never gets an address on the internet. A handful of open-source tools and a payment provider make that

Posted on Nov 22 • Originally published at blixild.com
A model on your own graphics card can answer your team or paying customers through an API, with a key for each of them, a price per token and a stop when the credit runs out, while the card itself never gets an address on the internet. A handful of open-source tools and a payment provider make that possible, and each of them has a setting that is easy to get wrong.
This post goes through them in the order to build them, as they run behind Blixild AI, our self-hosted LLM API for open models on RTX 3090s and RTX 5090s in our own servers in Poland. At each stop of a request I say what the tool does, why I chose it and what to take care of.
Along the way the post shows where a card had a quarter less room for conversations than our own calculator estimated, and why a model server's own key check does not protect it. It explains why a long prompt can stall where short requests pass and why every payment arrives twice. It ends with what a setup for one person or one company can leave out, and with the six steps of the build.
I wrote it for engineers who want to put an open model behind an API, for their own company or for customers. An earlier post explains why we serve Arete 27B this way.
Serving software loads a model onto a graphics card (GPU) and answers requests. A service needs more than that. Somebody has to know who is asking, count the tokens, put a price on them and stop when the credit runs out. Customers need a way to sign in and to pay, and I need to know that all of it works.
I followed one rule: a ready-made tool for every job, and my own code only where the tools meet. The figure shows the result along the path of one request. A small server in Helsinki is the only machine the internet can reach, and the cards sit behind it. The sections below take the stops in the order I built them, from the cards outwards: the card and its model server, the gate in front of it, the gateway that charges for tokens, the portal where customers sign in, and the checks that hold them together.
The figure shows the path of one request and the tool at each stop. It is an illustration, not a measurement.
The first stop is the card, and the first question is whether the model fits on it and how fast it will answer. Our LLM GPU Token Speed Calculator estimates both before anything is loaded. It takes the card, the model, the size of its weights and the number of requests at once. It returns the memory left for conversations, the time to the first token and the tokens per second each user gets.
For this post I entered the RTX 3090's setup with Arete 27B and wrote the results down before I compared them with the measurements. The table shows both.
The speeds fell inside the calculator's range, and the first token came 2% later than the range's upper end. The room for conversations did not match: the endpoint had about a quarter less than the lowest estimate. The serving software's start-up log shows where the difference lies. The software reserved about three times the working memory that the calculator assumed for a text-only model.
The calculator's practical estimate now counts that larger working memory. For the same setup it gives about 96,000 to 105,000 tokens, just below the endpoint's 109,000.
The figure is a screenshot of the calculator's Memory step for Arete 27B in 4 bits on an RTX 3090, with an 8-bit conversation memory, text only and a 98.9% memory share. It shows the estimate as the calculator gives it since the comparison above.
An estimate chooses the card. It does not set the service's limits. Those come from a run with every slot busy and the longest prompts the model accepts, because that run shows the memory left at the worst moment. Neither the estimate nor these measurements say how well the model answers.
With the card chosen, the next choice is the software that loads the model onto it and answers requests. I use vLLM, because it answers several requests at once from one card and speaks the same format as OpenAI's API. One vLLM process serves one model, so a card holds one model: Arete 27B runs on an RTX 3090 and Bielik 11B v3.1 on an RTX 5090.
Each model has to fit its card. Bielik fits the 5090's 32 GB with its weights stored in 8 bits each. Arete 27B at full precision needs more than twice the 3090's 24 GB, so that card runs a 4-bit build. A 4-bit build can cost some accuracy, and I have not yet measured how much for Arete.
What the weights leave free holds the conversations in progress. On the 3090, storing that conversation memory in 8 bits and leaving out the model's image input about doubled the room. vLLM can also draft several tokens per step, which on that card was about one and a half times faster for a single request and cost 60% of that room. I chose the room, because long documents and agents need it.
With these settings the model answers anyone who can reach its port. The next stop decides who can.
vLLM can check an API key itself, but that option guards only some of its addresses. Others on the same port answer without a key, among them one that generates text. vLLM's own documentation says not to rely on the option alone and to put a reverse proxy in front.
I put nginx there as a key gate, the same on every GPU server. It passes requests under /v1 that carry a known key and refuses everything else. vLLM listens only on the machine itself, so the gate is the only way in.
Only one machine needs to reach the gate: the gateway server in Helsinki. It connects over Tailscale, a private encrypted network between our machines. The network's access policy lets the gateway reach that one port on each GPU server and nothing else, and the policy has tests that fail if a change opens more. Check the plan before a service depends on it: Tailscale's free plan is for non-commercial use.
The gate only decides who gets in. It holds no budgets and counts no tokens, and that is the gateway's job.
The gateway is LiteLLM, an open-source proxy for model APIs. Each model is one entry in its config, with the address and the key of the server that runs it, so a request that names Bielik goes to a 5090 and one that names Arete to a 3090.
LiteLLM issues the keys customers use, counts each request's tokens, charges them against the customer's budget and refuses requests when the budget is spent, and it limits how many requests a key runs at once. Caddy, a web server, stands in front of it, obtains the TLS certificates and forwards only the /v1 addresses. Both run in containers on the gateway server, next to a PostgreSQL database. The gateway and the portal have a server to themselves.
LiteLLM does not load or swap models, and it does not sign anyone in or take a payment. Something has to create each customer and raise the budget when they pay, and that is the portal.
The portal at ai.blixild.com is the part I wrote: a Next.js application with Better Auth for sign-in. Customers sign in with Google or GitHub only, so the portal stores no passwords and every email address arrives verified. On the first visit it creates the customer in LiteLLM with a key and $1 of credit.
Credit is a ledger of grants in the portal's own database, and each grant sets the customer's budget in LiteLLM to the sum of the ledger. Customers add credit by paying through Stripe, which acts as merchant of record: it sells the credit in its own name, works out and pays the buyer's VAT or sales tax and sends the receipt.
The portal sells prepaid credit only. It has no subscriptions and issues no invoices of its own.
That completes the path, from the portal's sign-in to the card. Each tool on it passes its own tests, and the service can still fail between them. So one check runs the whole path against the real models, through the public address. It signs up a throwaway customer and makes a paid request. It verifies that the charge matches the published price, that requests stop at $0 and that a deleted key no longer works. Last, it confirms that the logs do not hold the prompt. The privacy promise rests on settings, and this check proves them after every change.
In operation, the gateway keeps sending a short real request to each model, along the path customers use. A model that stops answering triggers an email, sent from the gateway's side, so the alert does not depend on the machine it reports on.
One detail deserves a deliberate test. A restart rule that waits for an error code misses a model server that shuts down cleanly after its engine has died. I found this by stopping the engine on purpose, and the containers now restart whenever they stop.
None of these checks measures how good the answers are. That takes tests of the model itself, on the work it will be used for.
Blixild AI sells access to people I have never met, so it needs every stop above. A setup with fewer strangers needs fewer stops, and the same order tells which ones.
The path of this post is also the path of a build, from the card outwards, with each step proved before the next. How far you follow it depends on who will call the model. One person needs steps 1 to 3, a company serving its own staff needs steps 1 to 4, and a public service needs all of them. Step 6 belongs to every size.
Each further card repeats steps 1 to 3 and adds one entry to the gateway's config.
To see the result from the customer's side, sign in at ai.blixild.com with Google or GitHub. The key comes with $1 of credit and no card is needed, and any OpenAI client library works with api.blixild.com/v1.
If you want this stack on your own premises or in your own cloud account, with the model of your choice, our AI workload hosting sets it up and runs it for you.