<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: YaFei</title>
    <description>The latest articles on DEV Community by YaFei (@xuanyi).</description>
    <link>https://dev.to/xuanyi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4070815%2F359798fd-5fbd-443e-a2f1-61f978fdc0dd.png</url>
      <title>DEV Community: YaFei</title>
      <link>https://dev.to/xuanyi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xuanyi"/>
    <language>en</language>
    <item>
      <title>How we cut our LLM bill 40% with multi-provider routing</title>
      <dc:creator>YaFei</dc:creator>
      <pubDate>Mon, 10 Aug 2026 08:31:12 +0000</pubDate>
      <link>https://dev.to/xuanyi/how-we-cut-our-llm-bill-40-with-multi-provider-routing-44l7</link>
      <guid>https://dev.to/xuanyi/how-we-cut-our-llm-bill-40-with-multi-provider-routing-44l7</guid>
      <description>&lt;p&gt;&lt;em&gt;Running LLM features in production is expensive in ways the pricing page doesn't show. Here's what actually moved the needle for us.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We ship LLM features to production. For the first few months, our bill looked reasonable — until it didn't. The model call price was never the problem. The problem was everything around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The real cost isn't the happy path
&lt;/h2&gt;

&lt;p&gt;When a provider starts rate-limiting or flaking, two things happen that the naive cost estimate ignores:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Retry storms.&lt;/strong&gt; The same prompt gets hammered 3–5 times before anything gives up. Each retry is a full-price call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tail latency.&lt;/strong&gt; Requests queue behind slow providers, users time out, and you retry again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In one bad week, our effective cost per successful request was ~2.4× the listed price. Nobody budgets for that.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we changed
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Route across providers by latency + price
&lt;/h3&gt;

&lt;p&gt;Instead of pinning one model to one provider, we route each request to the cheapest healthy endpoint that meets our latency budget.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A request that needs a fast answer goes to the lowest-latency provider currently under quota.&lt;/li&gt;
&lt;li&gt;A batch job goes to the cheapest one.&lt;/li&gt;
&lt;li&gt;Same model family, different provider — the caller doesn't care.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This alone removed most of the "stuck behind a throttled provider" tax.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Cache embeddings and deterministic steps
&lt;/h3&gt;

&lt;p&gt;A surprising amount of our traffic re-embeds the same inputs. We added a cache layer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Embeddings for repeated prompts → served from cache.&lt;/li&gt;
&lt;li&gt;Deterministic pre/post-processing → computed once, reused.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That cut a meaningful chunk of repeat calls without touching quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Health-checked failover
&lt;/h3&gt;

&lt;p&gt;We keep a health-checked pool of upstreams. A provider that returns N consecutive 5xx/429 gets pulled from rotation for ~60s. Retries use exponential backoff with jitter.&lt;/p&gt;

&lt;p&gt;Result: when one provider degrades, traffic moves before users notice. No dropped requests as long as one upstream is alive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Bill per successful request: down ~40%.&lt;/li&gt;
&lt;li&gt;Retry calls: down ~60%.&lt;/li&gt;
&lt;li&gt;2am incidents where we manually switched providers: roughly zero.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this required an exotic stack. It's routing, caching, and a health check — the boring infra stuff that nobody writes blog posts about until the bill arrives.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you're in the same boat
&lt;/h2&gt;

&lt;p&gt;Getting reliable, affordable model access set up for a team has its own headaches — provider quotas, region limits, payment friction. If any of that sounds familiar, I'm happy to compare notes. Find me here or DM me; no pitch, just war stories.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>devops</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
