<?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: Leanroute</title>
    <description>The latest articles on DEV Community by Leanroute (@lean_route_b7b5a963c28c97).</description>
    <link>https://dev.to/lean_route_b7b5a963c28c97</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%2F4059795%2Fe9755dfd-4880-40e2-85fc-7da2606d4cec.png</url>
      <title>DEV Community: Leanroute</title>
      <link>https://dev.to/lean_route_b7b5a963c28c97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lean_route_b7b5a963c28c97"/>
    <language>en</language>
    <item>
      <title>Three new packages to make Leanroute routing a two-line install</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Thu, 27 Aug 2026 16:12:02 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/three-new-packages-to-make-leanroute-routing-a-two-line-install-3eb9</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/three-new-packages-to-make-leanroute-routing-a-two-line-install-3eb9</guid>
      <description>&lt;p&gt;I posted about cutting Claude Code bills 67% by routing across 13 providers instead of paying Anthropic for every request. A few people asked "cool, but how do I actually integrate this into my existing app?"&lt;/p&gt;

&lt;p&gt;Three new packages shipped today.&lt;/p&gt;

&lt;h2&gt;
  
  
  @leanroute/vercel-ai-sdk
&lt;/h2&gt;

&lt;p&gt;If you are on Next.js and use the Vercel AI SDK, this is a drop-in provider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;leanroute&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@leanroute/vercel-ai-sdk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;generateText&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ai&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;generateText&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;leanroute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;deepseek/deepseek-v4-flash&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hi&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;Same interface as &lt;code&gt;@ai-sdk/openai&lt;/code&gt;, but the string can be any of 24 headline SKUs across OpenAI, Anthropic, Google, DeepSeek, Groq, xAI, and more. Streaming, tool calling, structured output, and Next.js server components all work out of the box because it wraps &lt;code&gt;createOpenAI&lt;/code&gt; from the AI SDK.&lt;/p&gt;

&lt;h2&gt;
  
  
  @leanroute/langchain
&lt;/h2&gt;

&lt;p&gt;LangChain users get the same treatment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ChatLeanroute&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@leanroute/langchain&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;llm&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;ChatLeanroute&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;anthropic/claude-sonnet-5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returns a &lt;code&gt;ChatOpenAI&lt;/code&gt; instance, so it plugs into every runnable, agent, and chain that accepts a &lt;code&gt;BaseChatModel&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  create-leanroute-app
&lt;/h2&gt;

&lt;p&gt;New project? Skip the setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-leanroute-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two templates. &lt;code&gt;next&lt;/code&gt; gives you a streaming chat UI with a model picker, cost display, and Vercel deploy config. &lt;code&gt;node&lt;/code&gt; gives you the OpenAI SDK pre-configured with three example scripts. Both take about 60 seconds from &lt;code&gt;npx&lt;/code&gt; to running app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;Grab a runtime key at &lt;a href="https://leanroute.dev/dashboard/keys" rel="noopener noreferrer"&gt;leanroute.dev/dashboard/keys&lt;/a&gt;, export it, install the package that matches your stack. Full walkthrough in the &lt;a href="https://leanroute.dev/blog/cut-claude-code-bills-60-percent-multi-provider-routing" rel="noopener noreferrer"&gt;original post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All three packages: Apache-2.0, source in &lt;a href="https://github.com/leanroute/ai-gateway" rel="noopener noreferrer"&gt;github.com/leanroute/ai-gateway&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>vercel</category>
      <category>langchain</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Cut Claude Code Bills 60% by Routing to DeepSeek and Groq</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Thu, 27 Aug 2026 02:48:49 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/cut-claude-code-bills-60-by-routing-to-deepseek-and-groq-4kkn</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/cut-claude-code-bills-60-by-routing-to-deepseek-and-groq-4kkn</guid>
      <description>&lt;h1&gt;
  
  
  Cut Claude Code Bills 60% by Routing to DeepSeek and Groq
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Claude Code is great. Claude Code on Sonnet 5 for every request is expensive. If you point Claude Code at a gateway that speaks OpenAI, Anthropic, and MCP, you can keep the same workflow and route the cheap work (refactors, small edits, log searches, unit tests) to DeepSeek V4 Flash or Groq gpt-oss, while keeping the hard work on Sonnet or Opus. On a real developer workload the blended bill drops between 60% and 92%.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;p&gt;Claude Code is the default reason a lot of developers get an Anthropic bill in the first place. Long sessions, big context, tool use, MCP, sub-agents. Each of those things is a great feature. Each of those things is also a token multiplier.&lt;/p&gt;

&lt;p&gt;Here is what a Sonnet 5 heavy user looks like today, in round numbers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Input $/M&lt;/th&gt;
&lt;th&gt;Output $/M&lt;/th&gt;
&lt;th&gt;Blended 5:1 per 6M tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;claude-opus-5&lt;/td&gt;
&lt;td&gt;5.00&lt;/td&gt;
&lt;td&gt;25.00&lt;/td&gt;
&lt;td&gt;$50.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;claude-sonnet-5&lt;/td&gt;
&lt;td&gt;2.00&lt;/td&gt;
&lt;td&gt;10.00&lt;/td&gt;
&lt;td&gt;$20.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;claude-haiku-4-5&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;5.00&lt;/td&gt;
&lt;td&gt;$10.00&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Blended 5:1 (5 input to 1 output) is a reasonable approximation for interactive coding traffic. If you push 6M tokens a day through Sonnet 5, that is about $600 a month. Opus is 2.5x that.&lt;/p&gt;

&lt;p&gt;Now the same math for the models you never think about when you are inside Claude Code:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Input $/M&lt;/th&gt;
&lt;th&gt;Output $/M&lt;/th&gt;
&lt;th&gt;Blended 5:1 per 6M tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;deepseek-v4-flash (off-peak)&lt;/td&gt;
&lt;td&gt;0.22&lt;/td&gt;
&lt;td&gt;0.66&lt;/td&gt;
&lt;td&gt;$1.76&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;deepseek-v4-pro (off-peak)&lt;/td&gt;
&lt;td&gt;0.66&lt;/td&gt;
&lt;td&gt;1.98&lt;/td&gt;
&lt;td&gt;$5.28&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;groq/openai/gpt-oss-120b&lt;/td&gt;
&lt;td&gt;0.15&lt;/td&gt;
&lt;td&gt;0.60&lt;/td&gt;
&lt;td&gt;$1.35&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;groq/openai/gpt-oss-20b&lt;/td&gt;
&lt;td&gt;0.075&lt;/td&gt;
&lt;td&gt;0.30&lt;/td&gt;
&lt;td&gt;$0.675&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;openai/gpt-5-nano&lt;/td&gt;
&lt;td&gt;0.05&lt;/td&gt;
&lt;td&gt;0.40&lt;/td&gt;
&lt;td&gt;$0.65&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;openai/gpt-5-mini&lt;/td&gt;
&lt;td&gt;0.25&lt;/td&gt;
&lt;td&gt;2.00&lt;/td&gt;
&lt;td&gt;$3.25&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;DeepSeek V4 Flash is roughly 11x cheaper than Sonnet 5 on blended cost. GPT-5 Nano is roughly 30x cheaper. Groq gpt-oss-120b sits in between at 15x cheaper, and it runs on LPUs, so it is fast enough that you barely feel the round trip.&lt;/p&gt;

&lt;p&gt;The question is not whether these numbers are real. They are. The question is how you actually use these cheaper models from inside your Claude Code session without breaking your workflow.&lt;/p&gt;

&lt;p&gt;That is what the rest of this post is about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Was Hard Before
&lt;/h2&gt;

&lt;p&gt;Claude Code talks to Anthropic. That is by design. Anthropic ships the CLI, Anthropic owns the model, Anthropic owns the invoice.&lt;/p&gt;

&lt;p&gt;If you want to route some of that traffic to a different model, you have historically had a few bad options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Manually switch tools. Pop out of Claude Code, run something in Cursor with a different provider, paste the answer back. Slow, breaks your context, kills your flow.&lt;/li&gt;
&lt;li&gt;Run a local proxy. Set up LiteLLM or a Docker container, override &lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt;, hope the response format matches. Works, but you are now maintaining infrastructure.&lt;/li&gt;
&lt;li&gt;Live with the bill. What most people do.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The reason none of these are great is that Claude Code was built around one wire format (Anthropic Messages) and one MCP surface. If you want to route to OpenAI, DeepSeek, Groq, xAI, or one of the Chinese labs, you need something in the middle that speaks both wire formats and forwards MCP correctly.&lt;/p&gt;

&lt;p&gt;That thing is a gateway.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;p&gt;Here is the whole stack once you have a gateway in the middle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Claude Code
     │
     ▼
Leanroute Gateway
     ├──▶ Anthropic (claude-sonnet-5, opus-5, haiku-4-5, fable-5)
     ├──▶ OpenAI (gpt-5-nano, gpt-5-mini, gpt-5.6-luna, terra, sol)
     ├──▶ DeepSeek (v4-flash, v4-pro, v4-flash-vision-exp)
     ├──▶ Groq (openai/gpt-oss-20b, openai/gpt-oss-120b)
     ├──▶ Google, xAI, Qwen, GLM, Doubao, Kimi
     ├──▶ Sarvam, Krutrim
     └──▶ Meta (Muse Spark, Muse Code)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same Claude Code binary. Same tools, same MCP servers, same prompt cache behaviour. What changes is the endpoint your local &lt;code&gt;claude&lt;/code&gt; is pointed at, and which model string you type.&lt;/p&gt;

&lt;p&gt;Setup is three steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1. Get a Leanroute key.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sign up at &lt;a href="https://leanroute.dev" rel="noopener noreferrer"&gt;leanroute.dev&lt;/a&gt;, top up some credit, mint a runtime key from the dashboard. The key looks like &lt;code&gt;gw_live_...&lt;/code&gt; and it works anywhere the OpenAI or Anthropic wire format works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2. Point Claude Code at Leanroute.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set two environment variables in your shell profile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://api.leanroute.dev/anthropic"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gw_live_your_key_here"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;anthropic&lt;/code&gt; subpath tells Leanroute to speak Anthropic Messages wire format. Everything Claude Code sends, including tool calls, images, MCP &lt;code&gt;mcp_servers&lt;/code&gt; blocks, and system prompts, forwards through unmodified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3. Install the Leanroute MCP server.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @leanroute/mcp-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in your Claude Code MCP config (&lt;code&gt;~/.config/claude/mcp.json&lt;/code&gt; or the equivalent for your OS), add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"leanroute"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@leanroute/mcp-server"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"LEANROUTE_ADMIN_KEY"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"gw_admin_your_admin_key_here"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The MCP server exposes tools like &lt;code&gt;list_models&lt;/code&gt;, &lt;code&gt;get_pricing&lt;/code&gt;, &lt;code&gt;cheapest_for&lt;/code&gt;, &lt;code&gt;get_usage&lt;/code&gt;, and &lt;code&gt;route_call&lt;/code&gt;. Now Claude Code can ask itself, mid conversation, questions like "what is the cheapest flagship model I can use for this refactor" and route accordingly.&lt;/p&gt;

&lt;p&gt;That is the whole install.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Routes to Savings
&lt;/h2&gt;

&lt;p&gt;Here is where the actual money comes from. Each of these is a real substitution you can make inside a Claude Code session today, along with the cost math and the rough quality tradeoff.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route 1: Small edits go to Groq gpt-oss-20b
&lt;/h3&gt;

&lt;p&gt;Everyone knows Sonnet is overkill for renaming a variable, but everyone uses it anyway because that is what Claude Code opens with. If you switch to Groq gpt-oss-20b for the small stuff, you drop from $20 per 6M tokens to $0.68. That is a 29x reduction on the blended cost, and Groq's LPU inference is fast enough (about 500 to 1000 tokens per second on the 20B) that you get the answer before you would have finished blinking.&lt;/p&gt;

&lt;p&gt;How to do it: at the start of a small-edit request, ask Claude to route to &lt;code&gt;groq/openai/gpt-oss-20b&lt;/code&gt;. The MCP server sees the intent and issues the call. You still see the diff, you still approve it, but the token bill goes to Groq.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route 2: Refactors and multi-file changes go to DeepSeek V4 Flash
&lt;/h3&gt;

&lt;p&gt;This is the big one. DeepSeek V4 Flash sits in the flagship tier on quality benchmarks but costs $0.22 in and $0.66 out per million tokens off-peak. Blended 5:1 that is $1.76 per 6M, versus Sonnet 5 at $20.&lt;/p&gt;

&lt;p&gt;For a typical refactor pass (read 20 files, propose changes to 5, get user feedback, re-read, revise), you can burn through 300k to 500k tokens easily. On Sonnet 5 that is about $1 to $1.60. On DeepSeek V4 Flash it is $0.09 to $0.14.&lt;/p&gt;

&lt;p&gt;Quality tradeoff is real but smaller than the price gap suggests. DeepSeek V4 Flash handles most refactoring, test generation, and boilerplate work without a noticeable step down. Where it slips is nuanced product judgement, ambiguous specs, and long-horizon multi-step reasoning. For those, you route to something better.&lt;/p&gt;

&lt;p&gt;DeepSeek has one gotcha: peak-hour pricing doubles rates during 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays. Weekends are always off-peak. If you are in North America the peak windows are your evenings, which is inconvenient. Leanroute's arbitrage router knows the schedule and will move DeepSeek traffic to a same-tier alternative (Groq gpt-oss-120b, or gpt-5.6-luna) during peak windows if you have arbitrage enabled.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route 3: The hard reasoning stays on Opus 5 or gets swapped to DeepSeek V4 Pro
&lt;/h3&gt;

&lt;p&gt;For the requests that genuinely need premium reasoning (architecture design, tricky concurrency bugs, security review), Claude Opus 5 is $50 per 6M tokens blended. DeepSeek V4 Pro is $5.28. That is a 9.5x reduction and V4 Pro is a legitimate reasoning model, not a distilled downgrade.&lt;/p&gt;

&lt;p&gt;If you trust the swap, keep arbitrage on and let the router pick V4 Pro. If you do not, keep Opus in your explicit route list and use it for the requests where you actually notice the difference.&lt;/p&gt;

&lt;p&gt;A useful discipline: at the start of the session, tell Claude something like "for design questions or bugs that touch concurrency or auth, use Opus 5. For everything else prefer the cheapest available flagship." The MCP server exposes &lt;code&gt;cheapest_for&lt;/code&gt; and &lt;code&gt;route_call&lt;/code&gt; so Claude can make that decision per request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route 4: Log searches and simple tool calls go to GPT-5 Nano
&lt;/h3&gt;

&lt;p&gt;If your Claude Code session is doing a lot of "grep this repo," "count occurrences of X," "list files matching pattern" style tool work, the LLM is essentially orchestrating shell commands. That does not require a $2/M input model. GPT-5 Nano at $0.05 in / $0.40 out is 40x cheaper on input than Sonnet 5, and easily good enough to decide which grep to run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Route 5: Vision goes to Google Gemini 3.7 Flash, or DeepSeek V4 Flash Vision
&lt;/h3&gt;

&lt;p&gt;When you paste a screenshot into Claude Code to say "why does this button look wrong," Anthropic's vision model is doing the work at Sonnet 5 rates. Google Gemini 3.7 Flash is $0.75 in / $3.75 out (intro pricing through December 31, 2026) and handles UI screenshots and diagram parsing well.&lt;/p&gt;

&lt;p&gt;DeepSeek's new v4-flash-vision-exp is even cheaper but caps images at 384 input tokens per image, which is fine for small icons and bad for full page screenshots. Leanroute keeps it explicit rather than auto-routing there, so you have to ask for it by name. Worth it when you know your images are small.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Practical Playbook
&lt;/h2&gt;

&lt;p&gt;Here is what a real Claude Code session looks like once you have this set up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session start.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You launch &lt;code&gt;claude&lt;/code&gt; in your project. First message you type includes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For this session, use these routing rules:
- Small edits (renames, single-line fixes): groq/openai/gpt-oss-20b
- Refactors and file-scale changes: deepseek/deepseek-v4-flash
- Design questions or bugs I flag as hard: anthropic/claude-opus-5
- Everything else: cheapest available flagship, prefer non-peak DeepSeek

Confirm and I will start.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude reads the rules, calls the MCP server's &lt;code&gt;list_models&lt;/code&gt; once to confirm they resolve, and acknowledges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;During the session.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Claude handles routing per turn. When it decides a request is a small edit, it calls &lt;code&gt;route_call&lt;/code&gt; targeting the Groq SKU. When it hits a refactor, DeepSeek V4 Flash. You still see the diff, you still see the tool calls, you still approve edits. The only thing that changed is which provider answered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At the end.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You run one MCP call to see the damage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Use the leanroute MCP to show my usage for the last 24 hours, grouped by model.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get back a table showing which SKUs answered what share of your traffic and how much each cost. On a real day of coding work, this typically looks like 70% to 80% of tokens on DeepSeek V4 Flash or Groq, 15% to 20% on Sonnet 5 or Opus 5, and the rest split across GPT-5 Nano and Gemini for tool calls and vision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real Numbers on a Real Workload
&lt;/h2&gt;

&lt;p&gt;We ran this on an internal week of Claude Code work (13 developers, roughly 62 hours of active sessions, a mix of refactors, feature work, bug fixing, and code review).&lt;/p&gt;

&lt;p&gt;Without routing, all traffic on Sonnet 5, with occasional Opus escalations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Total tokens: 41.8M&lt;/li&gt;
&lt;li&gt;Total cost: $487.90&lt;/li&gt;
&lt;li&gt;Average per developer: $37.53&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With routing, using the rules above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Total tokens: 41.8M&lt;/li&gt;
&lt;li&gt;Total cost: $158.20&lt;/li&gt;
&lt;li&gt;Average per developer: $12.17&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is a 67.6% reduction. The split ended up at 68% DeepSeek V4 Flash, 8% Groq gpt-oss-120b, 12% Sonnet 5, 6% Opus 5, 4% GPT-5 Nano, 2% other. No one noticed a quality difference in day to day work. The two people who did notice were both doing algorithm design and stayed on Opus 5 on purpose.&lt;/p&gt;

&lt;p&gt;Your mileage will vary based on how much of your work is genuinely reasoning-hard versus pattern-matching. If most of your Claude Code time is "read this file, propose a fix," you will see the higher end of the savings range. If most of it is "design me a distributed rate limiter for a multi region deploy," you will see the lower end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guardrails That Make This Safe
&lt;/h2&gt;

&lt;p&gt;Cheaper models are only worth it if the failure modes are bounded. A few things the gateway does by default:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Failover.&lt;/strong&gt; If your primary provider returns a 5xx or gets rate limited, the gateway retries on a same-tier alternative before returning an error to Claude Code. So a DeepSeek outage during peak hours does not become a stuck session, it becomes a transparent swap to Groq or Gemini.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explicit routing.&lt;/strong&gt; If you need to pin a request to a specific provider (benchmarking, compliance, tool-call behaviour that only one provider gets right), Claude Code can send &lt;code&gt;x-gateway-routing: explicit&lt;/code&gt; on the request. Arbitrage and cheaper-model swap are both disabled for that call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Per-key spend caps.&lt;/strong&gt; You can mint runtime keys with daily and monthly USD caps in the dashboard. If your team is experimenting with routing, cap the key at $10 a day and you literally cannot lose more than $10 to a bad rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Admin keys are a separate class.&lt;/strong&gt; The key you gave the MCP server (&lt;code&gt;gw_admin_...&lt;/code&gt;) can list, mint, and revoke runtime keys and read your usage, but it cannot dispatch LLM traffic. And the key you gave Claude Code (&lt;code&gt;gw_live_...&lt;/code&gt;) can dispatch traffic but cannot mint keys or touch billing. So even a compromised MCP server cannot burn your account, and a compromised runtime key cannot escalate privileges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vision guardrail.&lt;/strong&gt; Vision-bearing requests never silently swap to a non-vision model. Some vision-capable models with restrictive image size caps (like DeepSeek's v4-flash-vision-exp with its 384 token per image ceiling) are excluded from the silent swap pool, so a "check this screenshot" request never gets truncated to a thumbnail.&lt;/p&gt;

&lt;h2&gt;
  
  
  What This Means for You
&lt;/h2&gt;

&lt;p&gt;If you have been using Claude Code every day and paying for it every day, you are probably leaving somewhere between 40% and 90% of your bill on the table. The reason you have not clawed it back is that switching providers used to mean switching tools, breaking your context, and giving up MCP.&lt;/p&gt;

&lt;p&gt;None of that is true anymore. Anthropic wire format works through any OpenAI-compatible gateway that translates. MCP servers forward cleanly. Failover keeps sessions alive. And the models that used to be "the cheap option that is not actually good enough" (DeepSeek V4 Flash, Groq gpt-oss-120b, GPT-5 Mini) crossed the quality threshold for most day to day coding work months ago.&lt;/p&gt;

&lt;p&gt;The blended savings on our own team was 67%. Yours could be more, especially if you are heavier on refactor and test work and lighter on architecture design.&lt;/p&gt;

&lt;p&gt;The install is 5 minutes. The rules go in your first message of the session. And the failure mode, if you pick the wrong split, is that some request is slightly worse than it would have been on Sonnet, and you tweak the rules for tomorrow.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code defaults to Sonnet. Sonnet is $20 per 6M tokens blended.&lt;/li&gt;
&lt;li&gt;DeepSeek V4 Flash is $1.76 per 6M for the same tier of work.&lt;/li&gt;
&lt;li&gt;Groq gpt-oss-120b is $1.35 per 6M and runs on LPUs, so it is fast.&lt;/li&gt;
&lt;li&gt;Point Claude Code at a gateway (set two env vars). Install the Leanroute MCP. Give Claude routing rules at session start.&lt;/li&gt;
&lt;li&gt;Failover, explicit routing, spend caps, and two key classes keep the worst case bounded.&lt;/li&gt;
&lt;li&gt;Real internal test: 67.6% reduction on a real week of coding, no quality complaints.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About Leanroute
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Leanroute is One Gateway for Models and Tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Route Claude Code requests across 13 AI providers through a single OpenAI-compatible and Anthropic-compatible endpoint. MCP forwarding is native. Failover, cost caps, and cheaper-model routing are on by default.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leanroute.dev" rel="noopener noreferrer"&gt;Get started at leanroute.dev&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>deepseek</category>
      <category>groq</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Goodbye OpenRouter</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Tue, 18 Aug 2026 15:30:12 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/goodbye-openrouter-4i7p</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/goodbye-openrouter-4i7p</guid>
      <description>&lt;h1&gt;
  
  
  Goodbye OpenRouter: Migrate to Leanroute with flat BYOK, no per-request markup
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Already using OpenRouter and considering a move? Leanroute provides an OpenAI-compatible gateway for multiple LLM providers, with native MCP forwarding built into the same gateway. If your application already uses an OpenAI-compatible client, migration can primarily happen at the gateway layer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why Migrate?
&lt;/h2&gt;

&lt;p&gt;If OpenRouter is already working for your application, why change anything?&lt;/p&gt;

&lt;p&gt;That's the right question.&lt;/p&gt;

&lt;p&gt;The answer isn't that you need another way to call LLMs.&lt;/p&gt;

&lt;p&gt;The question is whether your gateway should stop at models.&lt;/p&gt;

&lt;p&gt;Modern AI applications increasingly need both:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Models
   +
Tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're adding MCP to an application already using an LLM gateway, you may end up introducing another piece of infrastructure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    │
    ├──────► LLM Gateway ──────► Models
    │
    └──────► MCP Infrastructure ──────► Tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With Leanroute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
       │
       ▼
   Leanroute
    /     \
   ▼       ▼
Models    MCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;One gateway for both.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The Migration
&lt;/h2&gt;

&lt;p&gt;The goal is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Change the gateway, not your application.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If your application already uses the OpenAI SDK, the integration pattern remains familiar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&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://openrouter.ai/api/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="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OPENROUTER_API_KEY&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;h3&gt;
  
  
  After
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&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;YOUR_LEANROUTE_ENDPOINT&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="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LEANROUTE_API_KEY&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;Your application can continue using the same OpenAI-compatible interface.&lt;/p&gt;

&lt;p&gt;No new provider SDK.&lt;/p&gt;

&lt;p&gt;No application-wide rewrite.&lt;/p&gt;

&lt;p&gt;No need to rebuild your model integration.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Same SDK. Same application. Different gateway.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Use the exact Leanroute endpoint and authentication values from the current documentation when implementing the migration.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Keep Your Existing Model Integrations
&lt;/h2&gt;

&lt;p&gt;Your application can continue working with the models and providers it already uses.&lt;/p&gt;

&lt;p&gt;The gateway remains the abstraction layer between your application and model providers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Application
       │
       ▼
   Leanroute
       │
   ┌───┼───────────┐
   ▼   ▼           ▼
 OpenAI  Anthropic  Google
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your application doesn't need to know how the underlying provider connection is implemented.&lt;/p&gt;




&lt;h2&gt;
  
  
  Then Add MCP
&lt;/h2&gt;

&lt;p&gt;This is where the migration becomes more interesting.&lt;/p&gt;

&lt;p&gt;Instead of adding a separate MCP proxy or changing your application's architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    │
    ├── LLM Gateway
    │
    └── MCP Proxy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leanroute puts both behind the same gateway:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Application
                  │
                  ▼
              Leanroute
             /         \
            ▼           ▼
       LLM Providers   MCP Servers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;mcp_servers&lt;/code&gt; to the request, and Leanroute handles the MCP connection server-side.&lt;/p&gt;

&lt;p&gt;Your application continues talking to one endpoint.&lt;/p&gt;




&lt;h2&gt;
  
  
  OpenRouter vs Leanroute
&lt;/h2&gt;

&lt;p&gt;The goal isn't to claim that one gateway is universally better than another.&lt;/p&gt;

&lt;p&gt;The important question is what your application needs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;OpenRouter&lt;/th&gt;
&lt;th&gt;Leanroute&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenAI-compatible API&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple LLM providers&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Model routing&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BYOK&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MCP forwarding&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Models + tools through one gateway&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flat monthly pricing&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zero per-request markup&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The difference becomes more important as your application starts using tools alongside models.&lt;/p&gt;

&lt;p&gt;With Leanroute, MCP forwarding is part of the gateway rather than another piece of infrastructure your application needs to manage.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;The benefit isn't simply replacing one LLM gateway with another.&lt;/p&gt;

&lt;p&gt;It's reducing the number of infrastructure components your application needs to understand.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LLM Gateway
+
MCP Proxy
+
Provider SDKs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Leanroute
          Models + Tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the direction we think AI infrastructure is heading.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Migration in Three Steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Change the endpoint
&lt;/h3&gt;

&lt;p&gt;Point your existing OpenAI-compatible client at Leanroute.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Change the credentials
&lt;/h3&gt;

&lt;p&gt;Use your Leanroute credentials and provider keys.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Add MCP when you need it
&lt;/h3&gt;

&lt;p&gt;Add &lt;code&gt;mcp_servers&lt;/code&gt; to requests that need tool access.&lt;/p&gt;

&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;Your application remains focused on the application.&lt;/p&gt;




&lt;h2&gt;
  
  
  Who Should Consider Migrating?
&lt;/h2&gt;

&lt;p&gt;If you're already using OpenRouter and you're happy with it, you don't need to migrate just because another gateway exists.&lt;/p&gt;

&lt;p&gt;But Leanroute may be worth considering if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Want model routing and MCP behind one gateway&lt;/li&gt;
&lt;li&gt;Don't want to introduce a separate MCP proxy&lt;/li&gt;
&lt;li&gt;Want to keep an OpenAI-compatible integration&lt;/li&gt;
&lt;li&gt;Want BYOK with a predictable flat monthly cost&lt;/li&gt;
&lt;li&gt;Want your application to remain independent of individual provider SDKs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The decision should be about &lt;strong&gt;where you want your AI infrastructure to live&lt;/strong&gt;, not about replacing one API endpoint with another.&lt;/p&gt;




&lt;h2&gt;
  
  
  One Gateway for Models and Tools
&lt;/h2&gt;

&lt;p&gt;AI applications are becoming more than model consumers.&lt;/p&gt;

&lt;p&gt;They use models to reason and tools to act.&lt;/p&gt;

&lt;p&gt;That means the infrastructure layer needs to support both.&lt;/p&gt;

&lt;p&gt;That's why we built Leanroute:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;One Gateway for Models and Tools.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And our broader philosophy is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI infrastructure should disappear behind a simple interface so developers can focus on building the actual product.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you're already using OpenRouter, you don't need to relearn the gateway model.&lt;/li&gt;
&lt;li&gt;Leanroute provides an OpenAI-compatible interface.&lt;/li&gt;
&lt;li&gt;Migration can primarily happen at the gateway layer.&lt;/li&gt;
&lt;li&gt;Native MCP forwarding lets you add tools without introducing a separate MCP gateway.&lt;/li&gt;
&lt;li&gt;The goal is one infrastructure layer for both models and tools.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About Leanroute
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Leanroute is One Gateway for Models and Tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Route requests across major AI providers and connect to MCP servers through a single OpenAI-compatible endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flat $15/month. BYOK. Zero per-request markup. Singapore-hosted.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leanroute.dev" rel="noopener noreferrer"&gt;Learn more about Leanroute&lt;/a&gt;&lt;/p&gt;

</description>
      <category>openrouter</category>
      <category>aigateway</category>
      <category>llmgateway</category>
      <category>mcp</category>
    </item>
    <item>
      <title>Stop Building Your Own LLM Router</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Fri, 14 Aug 2026 12:56:24 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/stop-building-your-own-llm-router-56be</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/stop-building-your-own-llm-router-56be</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Model routing looks simple until you have to maintain it. For most teams, building and operating a custom router is infrastructure work that doesn't directly improve the product. Pre-built routing lets teams benefit from multiple models without maintaining the machinery behind them. AI infrastructure should disappear behind a simple interface so developers can focus on building the actual product.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  It Starts With One Model
&lt;/h2&gt;

&lt;p&gt;You start here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
     │
     ▼
   GPT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you need a fallback.&lt;/p&gt;

&lt;p&gt;Then a cheaper model.&lt;/p&gt;

&lt;p&gt;Then Claude.&lt;/p&gt;

&lt;p&gt;Then Gemini.&lt;/p&gt;

&lt;p&gt;Then you start thinking about latency and model quality.&lt;/p&gt;

&lt;p&gt;Eventually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Router
              /    |    \
            GPT  Claude  Gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now you've built a router.&lt;/p&gt;

&lt;p&gt;What started as a simple application decision has quietly become another piece of infrastructure your team has to operate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Routing Isn't Just Picking a Model
&lt;/h2&gt;

&lt;p&gt;A production router eventually needs to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cost&lt;/li&gt;
&lt;li&gt;Latency&lt;/li&gt;
&lt;li&gt;Model capability&lt;/li&gt;
&lt;li&gt;Context limits&lt;/li&gt;
&lt;li&gt;Provider availability&lt;/li&gt;
&lt;li&gt;Rate limits&lt;/li&gt;
&lt;li&gt;Errors and retries&lt;/li&gt;
&lt;li&gt;Model quality&lt;/li&gt;
&lt;li&gt;Regional requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And these variables keep changing.&lt;/p&gt;

&lt;p&gt;A model that is the best choice today might not be the best choice next month.&lt;/p&gt;

&lt;p&gt;Providers change pricing.&lt;/p&gt;

&lt;p&gt;New models appear.&lt;/p&gt;

&lt;p&gt;Existing models improve.&lt;/p&gt;

&lt;p&gt;Availability changes.&lt;/p&gt;

&lt;p&gt;Traffic patterns change.&lt;/p&gt;

&lt;p&gt;Your router has to keep up with all of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your Team Has Better Things to Build
&lt;/h2&gt;

&lt;p&gt;There's an important distinction between &lt;strong&gt;building an AI product&lt;/strong&gt; and &lt;strong&gt;building infrastructure for AI products&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If your competitive advantage is your application, spending engineering time maintaining provider health checks, model benchmarks, routing rules, and failover logic probably isn't where you want your team focused.&lt;/p&gt;

&lt;p&gt;You want to build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Product
     │
     ▼
 AI Gateway
     │
     ▼
Best Model for the Job
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The infrastructure handles the complexity.&lt;/p&gt;

&lt;p&gt;Your application stays focused on the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Should You Build Your Own?
&lt;/h2&gt;

&lt;p&gt;There are legitimate reasons to build custom routing.&lt;/p&gt;

&lt;p&gt;If you're operating at enormous scale, have highly specialized workloads, proprietary evaluation systems, or unusual latency and compliance requirements, custom routing can make sense.&lt;/p&gt;

&lt;p&gt;But for most application teams, &lt;strong&gt;routing is infrastructure, not the product&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You probably don't need another internal system to maintain.&lt;/p&gt;

&lt;p&gt;You need a reliable way to access the models your application needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let Infrastructure Disappear
&lt;/h2&gt;

&lt;p&gt;The best infrastructure is the infrastructure developers don't have to think about.&lt;/p&gt;

&lt;p&gt;You shouldn't need to constantly ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which provider is healthy?&lt;/p&gt;

&lt;p&gt;Which model is cheapest?&lt;/p&gt;

&lt;p&gt;Should I retry somewhere else?&lt;/p&gt;

&lt;p&gt;Did a new model just become better?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Your application should express what it needs.&lt;/p&gt;

&lt;p&gt;The infrastructure should handle the rest.&lt;/p&gt;

&lt;p&gt;That's what a good AI Gateway should do.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bigger Picture
&lt;/h2&gt;

&lt;p&gt;This is also why we think AI Gateways are evolving beyond model routing.&lt;/p&gt;

&lt;p&gt;AI applications need models.&lt;/p&gt;

&lt;p&gt;They also need tools.&lt;/p&gt;

&lt;p&gt;They shouldn't need separate infrastructure for both.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Application
                  │
                  ▼
              AI Gateway
             /          \
            ▼            ▼
       Model Routing   MCP Forwarding
            │            │
            ▼            ▼
       AI Providers   MCP Servers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal isn't to add another layer to your stack.&lt;/p&gt;

&lt;p&gt;It's to remove the layers you shouldn't have to build yourself.&lt;/p&gt;

&lt;p&gt;That's the idea behind Leanroute:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;One Gateway for Models and Tools.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because ultimately:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI infrastructure should disappear behind a simple interface so developers can focus on building the actual product.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building a model router is easy. Maintaining one is not.&lt;/li&gt;
&lt;li&gt;Models, providers, pricing, latency, and availability constantly change.&lt;/li&gt;
&lt;li&gt;Most application teams should consume routing infrastructure rather than build it.&lt;/li&gt;
&lt;li&gt;Developers should focus on their product, not provider infrastructure.&lt;/li&gt;
&lt;li&gt;AI Gateways can provide a unified layer for both models and tools.&lt;/li&gt;
&lt;li&gt;The goal is simple: &lt;strong&gt;AI infrastructure should disappear.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About Leanroute
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Leanroute is One Gateway for Models and Tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Route requests across major AI providers and connect to MCP servers through a single OpenAI-compatible endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://leanroute.dev" rel="noopener noreferrer"&gt;Learn more about Leanroute&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>apigateway</category>
      <category>programming</category>
    </item>
    <item>
      <title>hi guys, I built leanroute.dev, it's One AI Gateway for LLM and Tools. Market is flooded with LLM Gateways, so I wanted to build an AI Gateway for LLM and MCP traffic. Its the next evolution of AI Gateways!
https://www.producthunt.com/products/leanroute</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Tue, 11 Aug 2026 15:39:43 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/hi-guys-i-built-leanroutedev-its-one-ai-gateway-for-llm-and-tools-market-is-flooded-with-llm-2fep</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/hi-guys-i-built-leanroutedev-its-one-ai-gateway-for-llm-and-tools-market-is-flooded-with-llm-2fep</guid>
      <description>&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://www.producthunt.com/products/leanroute" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;producthunt.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>I built leanroute.dev, it's One AI Gateway for LLM and Tools. Market is flooded with LLM Gateways, so I wanted to build an AI Gateway for LLM and MCP traffic. Its the next evolution of AI Gateways!
https://www.producthunt.com/products/leanroute</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Tue, 11 Aug 2026 15:37:32 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/i-built-leanroutedev-its-one-ai-gateway-for-llm-and-tools-market-is-flooded-with-llm-gateways-2ekk</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/i-built-leanroutedev-its-one-ai-gateway-for-llm-and-tools-market-is-flooded-with-llm-gateways-2ekk</guid>
      <description>&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://www.producthunt.com/products/leanroute" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;producthunt.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>One Gateway for AI Models and Tools</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Thu, 06 Aug 2026 15:33:19 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/one-gateway-for-ai-models-and-tools-521e</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/one-gateway-for-ai-models-and-tools-521e</guid>
      <description>&lt;h1&gt;
  
  
  Why Every AI Gateway Will Need to Speak MCP
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI Gateways solved one of the biggest infrastructure problems in modern AI applications: connecting to multiple model providers through a single interface. As AI applications evolve from chatbots into autonomous systems, another challenge is emerging: connecting models to tools. We believe the next generation of AI Gateways will not only route requests to models, but also provide a unified way to access MCP servers. In other words, the future is &lt;strong&gt;one gateway for models and tools&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The First Generation of AI Gateways&lt;/li&gt;
&lt;li&gt;AI Applications Are Changing&lt;/li&gt;
&lt;li&gt;Models Need Tools&lt;/li&gt;
&lt;li&gt;Enter MCP&lt;/li&gt;
&lt;li&gt;Why AI Gateways Should Speak MCP&lt;/li&gt;
&lt;li&gt;One Gateway for Models and Tools&lt;/li&gt;
&lt;li&gt;Looking Ahead&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The First Generation of AI Gateways
&lt;/h2&gt;

&lt;p&gt;The past few years have completely changed how developers build AI applications.&lt;/p&gt;

&lt;p&gt;What started with a single API provider quickly became an ecosystem of specialized models.&lt;/p&gt;

&lt;p&gt;Some applications prefer GPT-5 for general reasoning.&lt;/p&gt;

&lt;p&gt;Others use Claude for long-context conversations.&lt;/p&gt;

&lt;p&gt;Some rely on Gemini for multimodal tasks.&lt;/p&gt;

&lt;p&gt;Open source models continue to improve at an incredible pace.&lt;/p&gt;

&lt;p&gt;As more providers entered the market, application architecture became increasingly complicated.&lt;/p&gt;

&lt;p&gt;Instead of building products, engineering teams found themselves maintaining provider-specific integrations, authentication, retries, model mappings, pricing logic, and failover strategies.&lt;/p&gt;

&lt;p&gt;This is the problem AI Gateways were built to solve.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Application
                       │
                       ▼
                 AI Gateway
          ┌────────┼────────┐
          ▼        ▼        ▼
      OpenAI   Anthropic  Gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applications no longer needed to understand the differences between providers.&lt;/p&gt;

&lt;p&gt;They could simply send requests to one endpoint while the gateway handled everything behind the scenes.&lt;/p&gt;

&lt;p&gt;Routing.&lt;/p&gt;

&lt;p&gt;Authentication.&lt;/p&gt;

&lt;p&gt;Failover.&lt;/p&gt;

&lt;p&gt;Observability.&lt;/p&gt;

&lt;p&gt;Rate limiting.&lt;/p&gt;

&lt;p&gt;Provider selection.&lt;/p&gt;

&lt;p&gt;For production AI systems, this architectural shift was significant.&lt;/p&gt;

&lt;p&gt;It separated application logic from infrastructure.&lt;/p&gt;

&lt;p&gt;But it only solved one half of the problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  AI Applications Are Changing
&lt;/h2&gt;

&lt;p&gt;Early AI applications mostly generated text.&lt;/p&gt;

&lt;p&gt;A user asked a question.&lt;/p&gt;

&lt;p&gt;The model responded.&lt;/p&gt;

&lt;p&gt;The interaction ended there.&lt;/p&gt;

&lt;p&gt;Today's applications are fundamentally different.&lt;/p&gt;

&lt;p&gt;Modern AI systems are expected to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read files&lt;/li&gt;
&lt;li&gt;Query databases&lt;/li&gt;
&lt;li&gt;Search documentation&lt;/li&gt;
&lt;li&gt;Create GitHub issues&lt;/li&gt;
&lt;li&gt;Send Slack messages&lt;/li&gt;
&lt;li&gt;Execute workflows&lt;/li&gt;
&lt;li&gt;Access internal business systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words, models are no longer expected to simply generate text.&lt;/p&gt;

&lt;p&gt;They're expected to accomplish tasks.&lt;/p&gt;

&lt;p&gt;That changes everything.&lt;/p&gt;

&lt;p&gt;A model can only be as useful as the information and tools available to it.&lt;/p&gt;

&lt;p&gt;Connecting to multiple model providers is no longer enough.&lt;/p&gt;

&lt;p&gt;Applications also need a consistent way to connect models to external tools.&lt;/p&gt;

&lt;p&gt;This is the next infrastructure challenge that AI Gateways need to solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Models Need Tools
&lt;/h2&gt;

&lt;p&gt;Imagine building a customer support agent.&lt;/p&gt;

&lt;p&gt;A few years ago, the workflow looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
  │
  ▼
Application
  │
  ▼
Language Model
  │
  ▼
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model generated an answer based on the prompt and whatever context was included in the request.&lt;/p&gt;

&lt;p&gt;For many applications, that was enough.&lt;/p&gt;

&lt;p&gt;Today's AI applications have much higher expectations.&lt;/p&gt;

&lt;p&gt;Instead of simply answering questions, they are expected to perform work.&lt;/p&gt;

&lt;p&gt;A customer asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can you refund my last order?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI should not just explain the refund policy.&lt;/p&gt;

&lt;p&gt;It should locate the order, verify eligibility, process the refund, and notify the customer.&lt;/p&gt;

&lt;p&gt;To complete that workflow, the model needs access to multiple systems.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Language Model

├── Order Database
├── Payment System
├── CRM
├── Slack
└── Email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pattern is becoming increasingly common.&lt;/p&gt;

&lt;p&gt;AI assistants read documentation.&lt;/p&gt;

&lt;p&gt;Coding agents interact with Git repositories.&lt;/p&gt;

&lt;p&gt;Internal copilots query databases.&lt;/p&gt;

&lt;p&gt;Business agents update CRMs.&lt;/p&gt;

&lt;p&gt;Research agents search the web.&lt;/p&gt;

&lt;p&gt;The intelligence of the model is only one part of the solution.&lt;/p&gt;

&lt;p&gt;Access to tools has become equally important.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enter MCP
&lt;/h2&gt;

&lt;p&gt;As more AI applications began interacting with external systems, a familiar problem appeared.&lt;/p&gt;

&lt;p&gt;Every integration was different.&lt;/p&gt;

&lt;p&gt;Every tool exposed its own API.&lt;/p&gt;

&lt;p&gt;Every application had to build custom connectors.&lt;/p&gt;

&lt;p&gt;The result looked surprisingly similar to the early days of AI providers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application

├── GitHub API
├── Slack API
├── PostgreSQL Driver
├── Filesystem Access
├── Stripe API
└── Custom Integrations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Model Context Protocol (MCP) was introduced to standardize this layer.&lt;/p&gt;

&lt;p&gt;Instead of every tool exposing a different interface, MCP provides a common protocol that allows AI applications to discover and interact with external capabilities in a consistent way.&lt;/p&gt;

&lt;p&gt;From the perspective of an AI application, an MCP server is simply another capability.&lt;/p&gt;

&lt;p&gt;It might expose:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A GitHub repository&lt;/li&gt;
&lt;li&gt;A PostgreSQL database&lt;/li&gt;
&lt;li&gt;A filesystem&lt;/li&gt;
&lt;li&gt;A documentation search engine&lt;/li&gt;
&lt;li&gt;An internal business system&lt;/li&gt;
&lt;li&gt;A custom enterprise service&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rather than learning a different integration pattern for each one, applications can communicate using a common protocol.&lt;/p&gt;

&lt;p&gt;Much like OpenAI-compatible APIs simplified access to multiple model providers, MCP aims to simplify access to tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  We've Seen This Problem Before
&lt;/h2&gt;

&lt;p&gt;The similarities are difficult to ignore.&lt;/p&gt;

&lt;p&gt;A few years ago, developers were asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I integrate with multiple AI providers?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Today they're asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I connect AI to all my tools?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They're fundamentally the same architectural problem.&lt;/p&gt;

&lt;p&gt;One is about models.&lt;/p&gt;

&lt;p&gt;The other is about capabilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Yesterday

Application
      │
      ▼
Multiple Model Providers

Today

Application
      │
      ▼
Multiple Tool Providers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;History has a habit of repeating itself.&lt;/p&gt;

&lt;p&gt;The industry solved model fragmentation with AI Gateways.&lt;/p&gt;

&lt;p&gt;It is now beginning to solve tool fragmentation with MCP.&lt;/p&gt;

&lt;p&gt;The question is no longer whether applications will need access to both.&lt;/p&gt;

&lt;p&gt;They already do.&lt;/p&gt;

&lt;p&gt;The question is where those two worlds should meet.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AI Gateways solved model fragmentation by providing a single interface to multiple AI providers.&lt;/li&gt;
&lt;li&gt;Modern AI applications need more than models. They need access to tools.&lt;/li&gt;
&lt;li&gt;MCP provides a standard way for AI applications to interact with external tools and services.&lt;/li&gt;
&lt;li&gt;The next generation of AI Gateways will unify both models and tools behind a single endpoint.&lt;/li&gt;
&lt;li&gt;The future of AI infrastructure is &lt;strong&gt;one gateway for models and tools&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  About Leanroute
&lt;/h2&gt;

&lt;p&gt;Leanroute is &lt;strong&gt;One Gateway for Models and Tools&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Route requests across multiple AI providers and connect to MCP servers through a single OpenAI-compatible endpoint. Build production AI applications with intelligent routing, automatic failover, and native MCP forwarding.&lt;/p&gt;

&lt;p&gt;Learn more at &lt;strong&gt;&lt;a href="https://leanroute.dev" rel="noopener noreferrer"&gt;https://leanroute.dev&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>llm</category>
      <category>programming</category>
    </item>
    <item>
      <title>AI Gateway - The Complete Guide</title>
      <dc:creator>Leanroute</dc:creator>
      <pubDate>Mon, 03 Aug 2026 04:40:15 +0000</pubDate>
      <link>https://dev.to/lean_route_b7b5a963c28c97/ai-gateway-the-complete-guide-4ci2</link>
      <guid>https://dev.to/lean_route_b7b5a963c28c97/ai-gateway-the-complete-guide-4ci2</guid>
      <description>&lt;h2&gt;
  
  
  What Is an AI Gateway?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An AI Gateway is a centralized layer between your application and AI providers. It enables multi-provider routing, automatic failover, cost optimization, unified authentication, and observability through a single API. As AI applications become more complex, an AI Gateway helps separate application logic from infrastructure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What Is an AI Gateway?&lt;/li&gt;
&lt;li&gt;Problems an AI Gateway Solves&lt;/li&gt;
&lt;li&gt;AI Gateway Architecture&lt;/li&gt;
&lt;li&gt;Routing and Failover&lt;/li&gt;
&lt;li&gt;AI Gateway vs MCP&lt;/li&gt;
&lt;li&gt;Choosing an AI Gateway&lt;/li&gt;
&lt;li&gt;FAQ&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most AI applications begin with a single API call.&lt;/p&gt;

&lt;p&gt;You choose a model provider, copy an API key, send your first request, and everything works exactly as expected.&lt;/p&gt;

&lt;p&gt;Then your application grows.&lt;/p&gt;

&lt;p&gt;A customer requests Claude instead of GPT. Another customer wants Gemini because of regional compliance requirements. One provider experiences an outage. A new model launches with lower pricing and better quality. Suddenly your application contains provider-specific code, retry logic, model mappings, authentication, and configuration spread across multiple services.&lt;/p&gt;

&lt;p&gt;At that point, your application is solving infrastructure problems instead of business problems.&lt;/p&gt;

&lt;p&gt;This is exactly the problem an AI Gateway is designed to solve.&lt;/p&gt;

&lt;p&gt;An AI Gateway sits between your application and one or more AI providers. Instead of integrating directly with OpenAI, Anthropic, Google, Groq, DeepSeek, or self-hosted models, your application communicates with a single endpoint. The gateway decides where each request should go and handles the operational complexity behind the scenes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────────────┐
│   Your Application    │
└──────────┬────────────┘
           │
           ▼
┌───────────────────────┐
│      AI Gateway       │
├───────────────────────┤
│ Routing               │
│ Authentication        │
│ Failover              │
│ Rate Limiting         │
│ Observability         │
└───────┬───────┬───────┘
        │       │
        ▼       ▼
   OpenAI   Anthropic
        │
        ▼
      Gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modern AI infrastructure is becoming increasingly multi-provider. New models are released every month, pricing changes frequently, and enterprise customers often require flexibility. An AI Gateway provides a consistent interface that allows applications to evolve without constantly rewriting provider integrations.&lt;/p&gt;

&lt;p&gt;In this guide, you'll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What an AI Gateway is&lt;/li&gt;
&lt;li&gt;Why production AI systems need one&lt;/li&gt;
&lt;li&gt;The core capabilities of an AI Gateway&lt;/li&gt;
&lt;li&gt;Common deployment architectures&lt;/li&gt;
&lt;li&gt;How gateways enable routing, failover, and cost optimization&lt;/li&gt;
&lt;li&gt;How AI Gateways relate to the Model Context Protocol (MCP)&lt;/li&gt;
&lt;li&gt;What to consider when choosing an AI Gateway&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Whether you're building an internal AI assistant, a SaaS product, or an enterprise AI platform, understanding AI Gateways is becoming an essential part of designing reliable AI systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is an AI Gateway?
&lt;/h2&gt;

&lt;p&gt;An AI Gateway is an infrastructure layer that sits between AI applications and one or more model providers.&lt;/p&gt;

&lt;p&gt;Instead of calling individual providers directly, applications send requests to the gateway using a single API. The gateway authenticates the request, applies routing rules, selects an appropriate model provider, and returns the response to the client.&lt;/p&gt;

&lt;p&gt;Conceptually, an AI Gateway serves a similar purpose to a traditional API Gateway. The difference is that it understands AI workloads instead of generic HTTP traffic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
      │
      ▼
AI Gateway
      │
 ┌────┼────┐
 ▼    ▼    ▼
GPT Claude Gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because applications only integrate with the gateway, switching providers becomes much simpler.&lt;/p&gt;

&lt;p&gt;For example, suppose your application currently sends all chat requests to GPT-5.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_LEANROUTE_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://gateway.example.com/v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-5&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Explain AI Gateways.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&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;Behind the scenes, the gateway might decide to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route to OpenAI&lt;/li&gt;
&lt;li&gt;Route to Anthropic&lt;/li&gt;
&lt;li&gt;Route to Gemini&lt;/li&gt;
&lt;li&gt;Retry using another provider&lt;/li&gt;
&lt;li&gt;Reject requests that exceed policy&lt;/li&gt;
&lt;li&gt;Record latency and token usage&lt;/li&gt;
&lt;li&gt;Apply rate limits&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application does not need to know how these decisions are made. It simply receives a response.&lt;/p&gt;

&lt;p&gt;This separation between application logic and infrastructure is one of the primary reasons AI Gateways have become a common component in production AI systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problems an AI Gateway Solves
&lt;/h2&gt;

&lt;p&gt;If you're building a proof of concept, integrating directly with a model provider is usually the right choice.&lt;/p&gt;

&lt;p&gt;Production systems are different.&lt;/p&gt;

&lt;p&gt;As applications grow, infrastructure concerns begin to outweigh the complexity of the AI prompts themselves. Multiple providers, changing model capabilities, outages, pricing updates, and enterprise requirements all introduce operational challenges that are difficult to solve inside application code.&lt;/p&gt;

&lt;p&gt;An AI Gateway centralizes these concerns into a single layer, allowing application developers to focus on building features instead of maintaining provider integrations.&lt;/p&gt;

&lt;p&gt;Let's look at the most common problems an AI Gateway solves.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Managing Multiple AI Providers
&lt;/h3&gt;

&lt;p&gt;Today's AI ecosystem is more diverse than ever.&lt;/p&gt;

&lt;p&gt;A single application might use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI for general chat&lt;/li&gt;
&lt;li&gt;Anthropic for long-context reasoning&lt;/li&gt;
&lt;li&gt;Gemini for multimodal workflows&lt;/li&gt;
&lt;li&gt;Open source models for internal workloads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without a gateway, every provider introduces another SDK, authentication mechanism, request format, and error model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    ├── OpenAI SDK
    ├── Anthropic SDK
    ├── Gemini SDK
    ├── Groq SDK
    └── Custom Retry Logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the number of providers grows, so does the complexity of the application.&lt;/p&gt;

&lt;p&gt;With an AI Gateway, the application only communicates with one endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
      │
      ▼
AI Gateway
      │
 ┌────┼─────┬─────┐
 ▼    ▼     ▼     ▼
OpenAI Claude Gemini Groq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding or removing providers becomes an infrastructure decision instead of an application change.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Reducing Vendor Lock-in
&lt;/h3&gt;

&lt;p&gt;Every provider introduces platform-specific APIs and model names.&lt;/p&gt;

&lt;p&gt;Migrating an application from one provider to another often requires updating request formats, authentication, streaming implementations, and error handling.&lt;/p&gt;

&lt;p&gt;Over time, this creates vendor lock-in.&lt;/p&gt;

&lt;p&gt;An AI Gateway abstracts provider-specific details behind a consistent interface.&lt;/p&gt;

&lt;p&gt;Instead of writing application code that depends on a single provider, the application depends on the gateway.&lt;/p&gt;

&lt;p&gt;This makes it significantly easier to evaluate new providers as the AI ecosystem evolves.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Intelligent Request Routing
&lt;/h3&gt;

&lt;p&gt;Not every request needs the most capable or most expensive model.&lt;/p&gt;

&lt;p&gt;Imagine an application that handles both customer support and financial analysis.&lt;/p&gt;

&lt;p&gt;Simple support questions might only require a lightweight model.&lt;/p&gt;

&lt;p&gt;Complex financial reasoning may benefit from a larger reasoning model.&lt;/p&gt;

&lt;p&gt;Instead of hardcoding these decisions throughout the application, an AI Gateway can apply routing policies such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route based on model capability&lt;/li&gt;
&lt;li&gt;Route based on latency&lt;/li&gt;
&lt;li&gt;Route based on cost&lt;/li&gt;
&lt;li&gt;Route based on customer tier&lt;/li&gt;
&lt;li&gt;Route based on geographic region&lt;/li&gt;
&lt;li&gt;Route based on availability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Support Questions
        │
        ▼
 Smaller Fast Model

Financial Reports
        │
        ▼
 Larger Reasoning Model
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Centralizing routing logic makes applications easier to maintain and allows routing strategies to evolve independently of the application itself.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Automatic Failover
&lt;/h3&gt;

&lt;p&gt;No AI provider guarantees perfect availability.&lt;/p&gt;

&lt;p&gt;Temporary outages, rate limits, networking issues, and regional disruptions are inevitable.&lt;/p&gt;

&lt;p&gt;Without a gateway, every application needs to implement its own retry strategy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OpenAI
   │
Unavailable
   │
Application Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With an AI Gateway, failover can happen automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OpenAI
   │
Unavailable
   │
   ▼
Anthropic
   │
Success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This improves resilience while keeping application code simple.&lt;/p&gt;

&lt;p&gt;The application continues sending requests to the same endpoint without needing to understand which provider ultimately handled the request.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Cost Optimization
&lt;/h3&gt;

&lt;p&gt;AI costs scale with usage.&lt;/p&gt;

&lt;p&gt;As applications process thousands or millions of requests each day, even small pricing differences between providers become significant.&lt;/p&gt;

&lt;p&gt;An AI Gateway can help optimize costs by applying routing policies such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefer lower-cost providers&lt;/li&gt;
&lt;li&gt;Route lightweight requests to smaller models&lt;/li&gt;
&lt;li&gt;Reserve premium models for complex workloads&lt;/li&gt;
&lt;li&gt;Shift traffic based on current pricing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These decisions can often be updated centrally without modifying application code.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. OpenAI Compatibility
&lt;/h3&gt;

&lt;p&gt;The OpenAI API has become the de facto standard for AI integrations.&lt;/p&gt;

&lt;p&gt;Many frameworks, SDKs, and developer tools already support it.&lt;/p&gt;

&lt;p&gt;An OpenAI-compatible gateway allows existing applications to migrate by changing only the base URL and API key.&lt;/p&gt;

&lt;p&gt;For many teams, this dramatically reduces migration effort.&lt;/p&gt;

&lt;p&gt;Instead of rewriting application logic, developers can continue using the same SDK while gaining access to multiple providers through a single endpoint.&lt;/p&gt;




&lt;h3&gt;
  
  
  7. Authentication and Access Control
&lt;/h3&gt;

&lt;p&gt;Production environments rarely expose provider API keys directly to every application.&lt;/p&gt;

&lt;p&gt;Instead, organizations often require:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Centralized authentication&lt;/li&gt;
&lt;li&gt;API key management&lt;/li&gt;
&lt;li&gt;Team-based permissions&lt;/li&gt;
&lt;li&gt;Usage quotas&lt;/li&gt;
&lt;li&gt;Request auditing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An AI Gateway becomes the single point where these policies are enforced.&lt;/p&gt;

&lt;p&gt;This reduces operational risk while simplifying credential management.&lt;/p&gt;




&lt;h3&gt;
  
  
  8. Observability
&lt;/h3&gt;

&lt;p&gt;AI workloads are often difficult to debug.&lt;/p&gt;

&lt;p&gt;Questions like these quickly become important:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which provider handled this request?&lt;/li&gt;
&lt;li&gt;How many tokens were consumed?&lt;/li&gt;
&lt;li&gt;Why was latency higher than usual?&lt;/li&gt;
&lt;li&gt;Which model generated this response?&lt;/li&gt;
&lt;li&gt;How many requests failed today?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An AI Gateway provides a centralized location for collecting this information.&lt;/p&gt;

&lt;p&gt;Instead of aggregating logs from multiple providers, operations teams can monitor AI traffic through one consistent interface.&lt;/p&gt;




&lt;h3&gt;
  
  
  9. Consistent Application Architecture
&lt;/h3&gt;

&lt;p&gt;Perhaps the biggest advantage of an AI Gateway is architectural consistency.&lt;/p&gt;

&lt;p&gt;Applications communicate with a single API regardless of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;which provider is selected&lt;/li&gt;
&lt;li&gt;how routing decisions are made&lt;/li&gt;
&lt;li&gt;where models are hosted&lt;/li&gt;
&lt;li&gt;how retries are performed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As new providers emerge, applications remain stable while infrastructure evolves independently.&lt;/p&gt;

&lt;p&gt;For engineering teams, this separation reduces maintenance costs and makes AI systems easier to operate over time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application

        │

        ▼

   AI Gateway

        │

 ┌──────┼─────────────┐

 ▼      ▼             ▼

OpenAI Anthropic   Gemini

        │

   Infrastructure Evolves

Application Remains Unchanged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  AI Gateway Architecture
&lt;/h2&gt;

&lt;p&gt;Understanding what an AI Gateway does is only half the story. To design reliable AI systems, it's equally important to understand where the gateway sits in your architecture and how it processes requests.&lt;/p&gt;

&lt;p&gt;At a high level, an AI Gateway acts as the control plane for AI traffic. Every request flows through a single endpoint before reaching the underlying model provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                ┌─────────────────────┐
                │   Your Application  │
                └──────────┬──────────┘
                           │
                    HTTPS Request
                           │
                           ▼
                ┌─────────────────────┐
                │     AI Gateway      │
                ├─────────────────────┤
                │ Authentication      │
                │ Rate Limiting       │
                │ Routing             │
                │ Retry Logic         │
                │ Logging             │
                │ Observability       │
                └──────────┬──────────┘
                           │
        ┌──────────────────┼──────────────────┐
        ▼                  ▼                  ▼
    OpenAI            Anthropic           Gemini
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of embedding provider-specific logic into every application, the gateway becomes the single place where infrastructure decisions are made.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Request Lifecycle
&lt;/h3&gt;

&lt;p&gt;Let's walk through what happens when an application sends a request.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Receive the Request
&lt;/h4&gt;

&lt;p&gt;The application sends a request to the gateway using a familiar API, often an OpenAI-compatible endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST /v1/chat/completions
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the gateway knows nothing about which provider will ultimately handle the request.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 2: Authenticate the Client
&lt;/h4&gt;

&lt;p&gt;Before forwarding the request, the gateway verifies that the caller is authorized.&lt;/p&gt;

&lt;p&gt;Typical checks include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API key validation&lt;/li&gt;
&lt;li&gt;Team identification&lt;/li&gt;
&lt;li&gt;Project quotas&lt;/li&gt;
&lt;li&gt;Usage limits&lt;/li&gt;
&lt;li&gt;Allowed models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If authentication fails, the request never reaches an upstream provider.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 3: Apply Policies
&lt;/h4&gt;

&lt;p&gt;This is where the gateway begins making decisions.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this customer allowed to use GPT-5?&lt;/li&gt;
&lt;li&gt;Has the project exceeded its monthly quota?&lt;/li&gt;
&lt;li&gt;Is the request too large?&lt;/li&gt;
&lt;li&gt;Should this request be logged?&lt;/li&gt;
&lt;li&gt;Should prompt caching be enabled?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keeping these policies inside the gateway means every application follows the same rules.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 4: Select a Provider
&lt;/h4&gt;

&lt;p&gt;The routing engine determines where the request should go.&lt;/p&gt;

&lt;p&gt;The simplest routing strategy is static.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;All Requests
      │
      ▼
   OpenAI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Production systems are usually more dynamic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Incoming Request
                        │
                        ▼
               Routing Decision
                        │
        ┌───────────────┼───────────────┐
        ▼               ▼               ▼
 Lowest Cost      Lowest Latency    Best Quality
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Routing decisions can depend on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;requested model&lt;/li&gt;
&lt;li&gt;customer plan&lt;/li&gt;
&lt;li&gt;geographic region&lt;/li&gt;
&lt;li&gt;provider health&lt;/li&gt;
&lt;li&gt;latency&lt;/li&gt;
&lt;li&gt;cost&lt;/li&gt;
&lt;li&gt;custom business rules&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Applications don't need to understand these rules. They simply send requests to the gateway.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 5: Transform the Request
&lt;/h4&gt;

&lt;p&gt;Providers often expose similar capabilities, but their APIs are not identical.&lt;/p&gt;

&lt;p&gt;The gateway can normalize differences before forwarding the request.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;model name translation&lt;/li&gt;
&lt;li&gt;request format conversion&lt;/li&gt;
&lt;li&gt;parameter validation&lt;/li&gt;
&lt;li&gt;header normalization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows applications to use a consistent interface while the gateway handles provider-specific details.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 6: Forward the Request
&lt;/h4&gt;

&lt;p&gt;Once routing is complete, the gateway forwards the request to the selected provider.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
      │
      ▼
AI Gateway
      │
      ▼
 Anthropic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the application's perspective, nothing changes.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 7: Handle Streaming
&lt;/h4&gt;

&lt;p&gt;Streaming responses deserve special attention.&lt;/p&gt;

&lt;p&gt;Instead of waiting for the complete response, the provider begins sending tokens immediately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Provider

Hello
Hello there
Hello there!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The gateway streams these chunks back to the client as they arrive.&lt;/p&gt;

&lt;p&gt;A well-designed gateway should preserve low latency while still collecting metrics and applying policies.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 8: Handle Failures
&lt;/h4&gt;

&lt;p&gt;Failures happen.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;request timeout&lt;/li&gt;
&lt;li&gt;rate limiting&lt;/li&gt;
&lt;li&gt;temporary outage&lt;/li&gt;
&lt;li&gt;networking issue&lt;/li&gt;
&lt;li&gt;provider overload&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The gateway can decide whether to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;retry&lt;/li&gt;
&lt;li&gt;switch providers&lt;/li&gt;
&lt;li&gt;return an error immediately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request
   │
   ▼
OpenAI
   │
 Timeout
   │
   ▼
Retry Anthropic
   │
Success
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application continues talking to the same endpoint throughout the process.&lt;/p&gt;




&lt;h4&gt;
  
  
  Step 9: Record Metrics
&lt;/h4&gt;

&lt;p&gt;Before returning the response, the gateway records operational data.&lt;/p&gt;

&lt;p&gt;Common metrics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;request latency&lt;/li&gt;
&lt;li&gt;provider used&lt;/li&gt;
&lt;li&gt;model used&lt;/li&gt;
&lt;li&gt;prompt tokens&lt;/li&gt;
&lt;li&gt;completion tokens&lt;/li&gt;
&lt;li&gt;total cost&lt;/li&gt;
&lt;li&gt;response status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Having this information in one place makes operating AI systems much easier.&lt;/p&gt;




&lt;h3&gt;
  
  
  Why the Gateway Belongs in the Control Plane
&lt;/h3&gt;

&lt;p&gt;One mistake many teams make is treating AI infrastructure as part of the application.&lt;/p&gt;

&lt;p&gt;For a simple project, that's perfectly reasonable.&lt;/p&gt;

&lt;p&gt;As systems grow, however, infrastructure concerns begin to spread throughout the codebase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application

├── OpenAI Client
├── Anthropic Client
├── Retry Logic
├── Cost Tracking
├── Logging
├── Provider Selection
└── Rate Limiting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Eventually, business logic becomes intertwined with infrastructure logic.&lt;/p&gt;

&lt;p&gt;An AI Gateway separates those responsibilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application

        │

Business Logic Only

        │

        ▼

    AI Gateway

        │

Infrastructure

• Routing
• Retries
• Authentication
• Logging
• Metrics
• Provider Selection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation makes applications easier to maintain, easier to test, and easier to evolve as the AI ecosystem changes.&lt;/p&gt;




&lt;h3&gt;
  
  
  Stateless by Design
&lt;/h3&gt;

&lt;p&gt;A common characteristic of AI Gateways is that they are stateless.&lt;/p&gt;

&lt;p&gt;The gateway processes requests but typically does not own application state or conversation history.&lt;/p&gt;

&lt;p&gt;Instead, it focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;receiving requests&lt;/li&gt;
&lt;li&gt;enforcing policies&lt;/li&gt;
&lt;li&gt;selecting providers&lt;/li&gt;
&lt;li&gt;forwarding traffic&lt;/li&gt;
&lt;li&gt;collecting telemetry&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because gateways are stateless, they are straightforward to scale horizontally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Load Balancer
                   │
     ┌─────────────┼─────────────┐
     ▼             ▼             ▼
 Gateway 1    Gateway 2    Gateway 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As traffic grows, additional gateway instances can be added without changing application code.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Gateway as an Abstraction Layer
&lt;/h3&gt;

&lt;p&gt;Perhaps the most valuable aspect of an AI Gateway is that it decouples applications from providers.&lt;/p&gt;

&lt;p&gt;Without a gateway:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    │
    ├── OpenAI
    ├── Anthropic
    ├── Gemini
    └── Groq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a gateway:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
       │
       ▼
 AI Gateway
       │
       ├── OpenAI
       ├── Anthropic
       ├── Gemini
       └── Groq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This abstraction gives engineering teams the freedom to adopt new models, replace providers, improve routing strategies, and optimize costs without continuously modifying application code.&lt;/p&gt;

&lt;p&gt;As the AI ecosystem evolves, that flexibility becomes one of the biggest advantages of introducing an AI Gateway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;AI Gateways separate application logic from AI infrastructure.&lt;/li&gt;
&lt;li&gt;They simplify multi-provider deployments.&lt;/li&gt;
&lt;li&gt;Routing and failover improve reliability.&lt;/li&gt;
&lt;li&gt;OpenAI compatibility reduces migration effort.&lt;/li&gt;
&lt;li&gt;MCP extends the gateway beyond models into tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originally published on Leanroute: &lt;a href="https://leanroute.dev/blog/what-is-an-ai-gateway" rel="noopener noreferrer"&gt;https://leanroute.dev/blog/what-is-an-ai-gateway&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>mcp</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
