<?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: Alex_wang</title>
    <description>The latest articles on DEV Community by Alex_wang (@alex_wang212).</description>
    <link>https://dev.to/alex_wang212</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%2F4023571%2F1d96d4c8-bbbd-4f67-9398-3648538df5aa.png</url>
      <title>DEV Community: Alex_wang</title>
      <link>https://dev.to/alex_wang212</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alex_wang212"/>
    <language>en</language>
    <item>
      <title>I Built a Drop-in AI API Caching Proxy — Save 70% on Inference Costs</title>
      <dc:creator>Alex_wang</dc:creator>
      <pubDate>Fri, 10 Jul 2026 06:17:02 +0000</pubDate>
      <link>https://dev.to/alex_wang212/i-built-a-drop-in-ai-api-caching-proxy-save-70-on-inference-costs-1ff1</link>
      <guid>https://dev.to/alex_wang212/i-built-a-drop-in-ai-api-caching-proxy-save-70-on-inference-costs-1ff1</guid>
      <description>&lt;p&gt;&lt;strong&gt;The TL;DR:&lt;/strong&gt; A caching proxy for OpenAI/Anthropic/OpenRouter that sits between your code and the provider. Change one line — &lt;code&gt;baseURL&lt;/code&gt; — and every duplicate request returns from cache at &amp;lt;1ms for $0. &lt;strong&gt;Pay 20% of what you save. Nothing if you save nothing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;→ Try it: &lt;strong&gt;&lt;a href="https://cachepilot.koaw.workers.dev" rel="noopener noreferrer"&gt;https://cachepilot.koaw.workers.dev&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I Built This
&lt;/h2&gt;

&lt;p&gt;I was burning ~$300/mo on Claude API calls. I checked my usage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;70% of requests were identical&lt;/strong&gt; — same system prompt, same few-shot examples, same context, repeated across sessions&lt;/li&gt;
&lt;li&gt;Every single one paid full price ($3/M input for Sonnet)&lt;/li&gt;
&lt;li&gt;I was paying ~$210/mo for the &lt;em&gt;exact same response&lt;/em&gt; over and over&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I threw together a simple cache. Bill dropped to $90.&lt;/p&gt;

&lt;p&gt;Then I realized: &lt;em&gt;every&lt;/em&gt; AI SaaS company has this problem. Every user session sends the same system prompt. Every background batch job re-requests identical completions. Multi-tenant apps repeat the same query across users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Helicone, Portkey, Langfuse&lt;/strong&gt; offer caching — but it's a sidebar feature. They charge per-request (even on cache hits!) and it's exact-match only.&lt;/p&gt;

&lt;p&gt;So I built the opposite: &lt;strong&gt;a product where caching is the only feature, and we only make money when you save money.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Architecture (Runs on Cloudflare Workers — Always On, $0)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your App → cachepilot.koaw.workers.dev
  │
  ├─ L0: In-Memory LRU (30s TTL, nanosecond lookup)
  ├─ L1: Cloudflare Edge Cache (1h TTL, tenant-isolated)
  ├─ L1.5: Normalizer (whitespace-blind cache keys)
  └─ L3: Provider Optimization (prompt cache markers)
       │
       └─ OpenAI / Anthropic / OpenRouter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;L0 — In-Memory:&lt;/strong&gt; Hot responses in process memory with LRU eviction. Sub-millisecond for frequent duplicates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L1 — Edge Cache:&lt;/strong&gt; Cloudflare Cache API stores full responses at the edge. Tenant-isolated by hashed API key. Millisecond lookup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L1.5 — Normalizer:&lt;/strong&gt; "Hello" and " hello " produce the same cache key. Whitespace, key ordering, formatting differences are ignored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;L3 — Provider Optimization:&lt;/strong&gt; Automatically injects Anthropic prompt caching markers on session boundaries. Detects multi-turn conversations without any developer configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Session-Aware" Differentiator
&lt;/h3&gt;

&lt;p&gt;This is what Helicone/Portkey don't do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turn 1:&lt;/strong&gt; Cache miss → forwarded to provider&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn 2:&lt;/strong&gt; Only the &lt;em&gt;new&lt;/em&gt; message is different. We detect it's a continuation and mark the stable prefix for prompt caching → 37-89% savings on input tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn 1 repeated:&lt;/strong&gt; L0 cache HIT → zero cost&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No headers. No SDK. No developer configuration.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It Right Now
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Go to &lt;a href="https://cachepilot.koaw.workers.dev" rel="noopener noreferrer"&gt;cachepilot.koaw.workers.dev&lt;/a&gt; → enter your email → get an API key&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Change the &lt;code&gt;baseURL&lt;/code&gt; in your AI client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Before&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sk-...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// After&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;openai&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;baseURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://cachepilot.koaw.workers.dev/v1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sk-cache-xxx-yyy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Make requests. Check your dashboard for savings. That's it.&lt;/p&gt;

&lt;p&gt;No SDK. No onboarding call. No credit card.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pricing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;20% of calculated savings. Nothing if you save nothing.&lt;/strong&gt; First 7 days free.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You Save&lt;/th&gt;
&lt;th&gt;You Pay Us&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$0&lt;/td&gt;
&lt;td&gt;$0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$100/mo&lt;/td&gt;
&lt;td&gt;$20/mo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$500/mo&lt;/td&gt;
&lt;td&gt;$100/mo&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Why I'm Building in Public
&lt;/h2&gt;

&lt;p&gt;Solo dev, $0 budget. No VC, no ads, no sales team.&lt;/p&gt;

&lt;p&gt;→ &lt;strong&gt;7 days free, no card: &lt;a href="https://cachepilot.koaw.workers.dev" rel="noopener noreferrer"&gt;https://cachepilot.koaw.workers.dev&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Questions? Drop a comment. I read every one.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>productivity</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
