Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.
Rust ai-agentsai-gatewayclaude-codecodexcoding-agentcost-optimizationdeepseekllm-gatewayllm-routerlocal-firstmodel-routingrusttask-routingtauri
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 500" role="img"><title>切换一次,损失会被后续调用摊薄</title><rect width="1000" height="500" rx="20" fill="#eef2fa"/><g font-family="system-ui,sans-serif" fill="#192439"><text x="32" y="46" font-size="24" font-weight="700">切换一次,损失会被后续调用摊薄</text><text x="32" y="76" font-size="15" fill="#536079">示例:10 万 token 旧对话 + 新消息,切换后第一次请求完全没有缓存</text><path d="M 96 390.0 H 950" stroke="#d3d9e8"/><text x="86.0" y="395.0" font-size="13" font-weight="400" text-anchor="end" fill="#536079">0%</text><path d="M 96 320.0 H 950" stroke="#d3d9e8"/><text x="86.0" y="325.0" font-size="13" font-weight="400" text-anchor="end" fill="#536079">25%</text><path d="M 96 250.0 H 950" stroke="#d3d9e8"/><text x="86.0" y="255.0" font-size="13" font-weight="400" text-anchor="end" fill="#536079">50%</text><path d="M 96 180.0 H 950" stroke="#d3d9e8"/><text x="86.0" y="185.0" font-size="13" font-weight="400" text-anchor="end" fill="#536079">75%</text><path d="M 96 110.0 H 950" stroke="#d3d9e8"/><text x="86.0" y="115.0" font-size="13" font-weight="400" text-anchor="end" fill="#536079">100%</text><text x="96.0" y="414.0" font-size="13" font-weight="400" text-anchor="middle" fill="#536079">1</text><text x="275.8" y="414.0" font-size="13" font-weight="400" text-anchor="middle" fill="#536079">5</text><text x="500.5" y="414.0" font-size="13" font-weight="400" text-anchor="middle" fill="#536079">10</text><text x="680.3" y="414.0" font-size="13" font-weight="400" text-anchor="middle" fill="#536079">14</text><text x="950.0" y="414.0" font-size="13" font-weight="400" text-anchor="middle" fill="#536079">20</text><text x="523.0" y="436.0" font-size="14" font-weight="400" text-anchor="middle" fill="#536079">这一轮的调用次数</text><polygon points="96.0,112.8 140.9,114.1 185.9,114.5 230.8,114.7 275.8,114.8 320.7,114.8 365.7,114.9 410.6,114.9 455.6,114.9 500.5,114.8 545.5,114.8 590.4,114.8 635.4,114.8 680.3,114.7 725.3,114.7 770.2,114.7 815.2,114.6 860.1,114.6 905.1,114.6 950.0,114.6 950.0,126.2 905.1,127.0 860.1,127.8 815.2,128.7 770.2,129.8 725.3,130.9 680.3,132.3 635.4,133.8 590.4,135.6 545.5,137.7 500.5,140.3 455.6,143.4 410.6,147.3 365.7,152.2 320.7,158.9 275.8,168.1 230.8,182.0 185.9,205.1 140.9,251.4 96.0,390.0" fill="#f4c7a5" opacity=".55"/><polyline points="96.0,112.8 140.9,114.1 185.9,114.5 230.8,114.7 275.8,114.8 320.7,114.8 365.7,114.9 410.6,114.9 455.6,114.9 500.5,114.8 545.5,114.8 590.4,114.8 635.4,114.8 680.3,114.7 725.3,114.7 770.2,114.7 815.2,114.6 860.1,114.6 905.1,114.6 950.0,114.6" fill="none" stroke="#5564bd" stroke-width="3"/><polyline points="96.0,390.0 140.9,251.4 185.9,205.1 230.8,182.0 275.8,168.1 320.7,158.9 365.7,152.2 410.6,147.3 455.6,143.4 500.5,140.3 545.5,137.7 590.4,135.6 635.4,133.8 680.3,132.3 725.3,130.9 770.2,129.8 815.2,128.7 860.1,127.8 905.1,127.0 950.0,126.2" fill="none" stroke="#d0652a" stroke-width="3"/><circle cx="96.0" cy="390.0" r="5" fill="#d0652a"/><text x="108.0" y="378.0" font-size="13" font-weight="700" text-anchor="start" fill="#9c4317">差 99.0 个百分点</text><circle cx="275.8" cy="168.1" r="5" fill="#d0652a"/><text x="287.8" y="190.1" font-size="13" font-weight="700" text-anchor="start" fill="#9c4317">差 19.0 个百分点</text><circle cx="680.3" cy="132.3" r="5" fill="#d0652a"/><text x="692.3" y="154.3" font-size="13" font-weight="700" text-anchor="start" fill="#9c4317">差 6.3 个百分点</text><circle cx="950.0" cy="126.2" r="5" fill="#d0652a"/><text x="938.0" y="148.2" font-size="13" font-weight="700" text-anchor="end" fill="#9c4317">差 4.2 个百分点</text><path d="M 700 96 h 24" stroke="#5564bd" stroke-width="3"/><text x="732.0" y="101.0" font-size="14" font-weight="700" text-anchor="start" fill="#5564bd">不切换</text><path d="M 830 96 h 24" stroke="#d0652a" stroke-width="3"/><text x="862.0" y="101.0" font-size="14" font-weight="700" text-anchor="start" fill="#d0652a">切换一次</text><text x="32.0" y="484.0" font-size="13" font-weight="400" text-anchor="start" fill="#536079">整轮命中率 = 命中缓存的输入 ÷ 全部输入。规律:一轮调用 n 次,切换一次最多让命中率下降 1/n。</text></g></svg>