How running out of API credits taught us to put every LLM call behind one gateway
This is a story about a failure that never showed up as an error. Our LLM credits ran out at one provider, nothing crashed, and users got stuck in a loop we didn't know about. Fixing it led us to route every model call through a single gateway, OpenRouter. Soon after that move we found a second sil

This is a story about a failure that never showed up as an error. Our LLM credits ran out at one provider, nothing crashed, and users got stuck in a loop we didn't know about. Fixing it led us to route every model call through a single gateway, OpenRouter. Soon after that move we found a second silent failure: prompt caching wasn't working at all.
If you call more than one LLM provider in production, or you rely on prompt caching to keep costs down, I hope this saves you from both mistakes.
I'm the founder of CV by JD. People upload their resume, paste a job description, and we rewrite the resume for that job. Then a separate scoring step gives the new resume a match score from 0 to 100, with tips on what's still missing.
Behind one "optimize" click there are several separate model calls:
Here's how those calls reached the models before the change, and after it:
Before After ────── ───── Our server ──▶ OpenAI Our server ──▶ OpenRouter ──▶ OpenAI ──▶ Google Vertex AI ──▶ DeepSeek hosts ──▶ OpenRouter ──▶ others ──▶ Qwen hosts (a key, a bill and an error format (one key, one bill, one error format) for each provider) Enter fullscreen mode Exit fullscreen mode A provider is a company that runs models and sells access to them, such as OpenAI. A gateway like OpenRouter sits in front of many providers and gives you one API for all of them.
For most of these calls we keep an ordered list of models, cheapest first. If the first model fails, the next one tries. I'll call that list the ladder and each model on it a tier.
Model names in this post reflect our setup in November 2026. We change models often as we learn what works, so treat them as examples, not recommendations.
The setup grew one feature at a time. Each time we added a step, we picked whichever model looked best for it and added that provider's client library (SDK). After a few months, our server talked to OpenAI directly, to Google's Vertex AI directly, and to OpenRouter for a few tiers.
Each provider came with its own API key, its own way of authenticating, its own billing page and its own error format. Most steps had backup models from other providers, so they could survive one provider failing. Two steps had no backup at all: pulling requirements out of the job description, and writing resume-specific tips. Both used a single OpenAI model, and together they produce the tips users see next to their score.
The two single-model steps started failing. The code around them handled the failure the way it was written to: it fell back to generic tips. Those tips looked like this:
The "Fix this" button sends the tip to the model that rewrote the resume and asks it to apply the change. But "Improve your keywords" doesn't name any specific missing requirement, so applying it changed nothing the score looks at. The score stayed flat, the same tip came back, and the user could click it again, and again.
From the user's side, the product looked broken. From our side, everything looked fine. There were no 500s and no error pages, and no alert fired, because a billing failure at one provider wasn't wired to any alert. We found out from user feedback.
The real problem was that billing failures were invisible. We had several providers, several dashboards and no alert.
We went through every model call in the codebase and asked three questions of each one:
We moved every call to OpenRouter. For us it was the simplest way to get down to one key, one bill and one error format without running another service ourselves, and we already depended on it for the fact-checking model. The ladder still uses models from several vendors (DeepSeek, Qwen and OpenAI), but all of them are reached through one API.
Then we fixed the things that had let the failure go unnoticed:
We accepted one real trade-off. OpenRouter is now a single point of failure. If it goes down, every tier goes down together. Before, we looked redundant, but two steps had no backup, so one provider failing could still break the product without anyone hearing about it. A single dependency we alert on has been easier to live with than several we didn't.
Our chat system prompt is over 20,000 tokens and identical on every request. Providers such as DeepSeek cache a prompt prefix they've seen recently and charge much less to reuse it. With a prompt this large, caching makes up a big part of the cost of every request.
After consolidating, we made DeepSeek V4.1 Flash the first model on the ladder, partly because its cached input is so cheap.
We record the number of cached prompt tokens on every request, and it was close to zero. We were paying full price for the same 20,000 tokens on every call.
OpenRouter's documentation on provider routing explained it. A model whose weights are public, like this one, is served by many different hosting companies, about 50 when we checked, and each host keeps its own cache. By default OpenRouter spreads requests across them, so consecutive requests usually landed on different hosts, and each one found a cold cache.
Here's a simple way to picture it. Imagine 50 coffee shops that each remember your order, but only if you go back to the same shop. If you're sent to a random shop every morning, nobody ever remembers you.
Our big, expensive prefix is the system prompt, and it's the same for every user. Pinning gives everyone the same warm cache, so we chose that:
Here, deepinfra/fp8 is one hosting company's build of the model, and deepseek is DeepSeek's own API:
modelKwargs: { provider: { order: [ 'deepinfra/fp8', 'deepseek' ], allow_fallbacks: true, }, }, Enter fullscreen mode Exit fullscreen mode On the next request, 22,272 of the roughly 22,400 prompt tokens (about 99%) came from the cache instead of being billed at full price. At DeepSeek's cached-token price, that made input on our most common call roughly ten times cheaper.
If you run production traffic through a model gateway, I'm curious how you handle that single point of failure. Did you find a setup that was worth the extra complexity?