🪟 Windows TippsAndroid 17: Neue Version ist hier – Das ist alles neu(16.09.2026 um 11:40 Uhr)
🕵️ Hacking12 Best CASB Solutions Compared (2026): Features & Pricing(16.09.2026 um 09:31 Uhr)
🕵️ Hacking12 Best CIEM Tools Compared (2026): Features & Pricing(16.09.2026 um 09:37 Uhr)
🪟 Windows TippsAndroid 17: Neue Version ist hier – Das ist alles neu(16.09.2026 um 11:40 Uhr)
🕵️ Hacking12 Best CASB Solutions Compared (2026): Features & Pricing(16.09.2026 um 09:31 Uhr)
🕵️ Hacking12 Best CIEM Tools Compared (2026): Features & Pricing(16.09.2026 um 09:37 Uhr)

🔧 Programmierung 🕛 vor 3 Monaten 7 Min Lesezeit
0

How I Cut Aider's Token Bill 80%: Prompt Caching, MCP Code Mode, and Tier Routing

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Aider is the best terminal AI coding tool I've used. But by default it sends every diff through your OpenAI or Anthropic key, which gets expensive fast on real refactors — a single 100-file repo map can torch a few dollars before Aider even reads your prompt.



This post shows how to run Aider against any LLM provider — Ollama for free local runs, OpenRouter for mixed-provider routing, AWS Bedrock for the enterprise plate — through a single OpenAI-compatible endpoint, with prompt caching and MCP Code Mode layered on top to slash the bill further. I'll use puts GPT-4o and Claude 3.5 Sonnet at the top. But you don't need a $3-per-million-tokens model to rename a variable. You need it for the architecture decisions.



Lynkr's tier routing splits the work by prompt complexity:




























Aider call type Routes to Cost
Repo map summarization
qwen2.5-coder:7b (Ollama, local)
$0
File edits, single-function diffs
gemini-flash-1.5 (OpenRouter)
~$0.075/M
Architecture / multi-file refactors
claude-3.5-sonnet (Anthropic)
$3/M





CODE
# .env additions
TIER_SIMPLE=ollama:qwen2.5-coder:7b
TIER_MEDIUM=openrouter:google/gemini-flash-1.5
TIER_COMPLEX=openrouter:anthropic/claude-3.5-sonnet
TIER_REASONING=openrouter:anthropic/claude-opus-4






Then point Aider at --model lynkr-auto and Lynkr scores each prompt before picking the tier.






Stacking the three levers



Each lever on its own is meaningful. Stacked, they compound:





  • Caching alone: ~70% input-token cut on a stable session


  • + Tier routing: another ~40% by pushing routine calls to Flash/Ollama


  • + MCP Code Mode (if you compose with other MCP tools): another 5–15x on tool-plumbing tokens



In my own Aider workflow — heavy refactors against a 200k-LOC monorepo — this combination has dropped a session that used to cost ~$8 in Claude calls down to under $1.50. Not because Claude got cheaper. Because most of the work is now happening on cached prefixes, free local models, or in-sandbox code execution.






Configuration walkthrough






Step 1 — Install and start Lynkr






CODE
npx lynkr@latest






First run creates a .env file. Minimal config:




CODE
MODEL_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...
PROMPT_CACHE=true
PORT=8081






For full local + free:




CODE
MODEL_PROVIDER=ollama
OLLAMA_ENDPOINT=http://localhost:11434
OLLAMA_MODEL=qwen2.5-coder:latest
PORT=8081






Then ollama pull qwen2.5-coder:latest.






Step 2 — Point Aider at the gateway






CODE
export OPENAI_API_BASE=http://localhost:8081/v1
export OPENAI_API_KEY=dummy






Drop those in your shell rc file.






Step 3 — Pick a model (or let Lynkr pick)






CODE
# Direct pass-through
aider --model openai/gpt-4o

# Or let Lynkr tier-route
aider --model lynkr-auto









Step 4 — Verify






CODE
curl -s http://localhost:8081/v1/models | python3 -m json.tool | head






Start Lynkr with LOG_LEVEL=info and watch the cache-hit lines on your second Aider request — that's where the savings show up.






Aider-specific gotchas



Weak model for commits / summarization. Aider uses a cheaper model for non-code calls; default is gpt-4o-mini. Override to a free local one:




CODE
aider --model openai/gpt-4o --weak-model ollama/qwen2.5-coder:7b






Long context. Local Ollama models will OOM on 200k+ token repo maps. Either set --map-tokens 0, or route long-context calls to Gemini Flash 1M-token contexts via the TIER_REASONING line above.



Streaming. Aider expects streaming responses. Lynkr streams by default. If you're on a non-streaming Databricks endpoint, set STREAM_PASSTHROUGH=false and Lynkr buffers + simulates.



Cache hit rate. Prompt caching only fires when the prefix is byte-identical across requests. If your repo map changes (you edit a /added file), the cache for that block invalidates and rebuilds. Lynkr logs cache-hit ratios per session — watch them; if hit rate is below 60% something in your workflow is busting the prefix.






Quickref
































Aider env var Lynkr role
OPENAI_API_BASE=http://localhost:8081/v1 Where Lynkr listens
OPENAI_API_KEY=dummy Required by Aider, ignored by Lynkr
--model openai/gpt-4o Forwarded as-is to the configured upstream
--model lynkr-auto Triggers Lynkr's complexity-based tier routing
--weak-model ollama/qwen2.5-coder:7b Free local model for commit messages





TL;DR



The default Aider setup pays full price for the same repo-map bytes on every turn. The fix isn't "use a cheaper model" — it's:





  1. Cache the repetitive prefix (prompt caching).


  2. Collapse tool plumbing into one call (MCP Code Mode).


  3. Match model size to task complexity (tier routing).



Stacked, those three levers have taken my Aider sessions from ~$8 to ~$1.50 without changing how I work. Lynkr is one gateway that does all three; it's Apache 2.0, single Node binary, drop-in OpenAI base URL.



Aider's GitHub: — star to follow next integration writeups (OpenHands, Vercel AI SDK, Open Interpreter queued).

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Build Anything with DeepSeek V4.1 Flash, Here's How..
1 Quelle
Followership, CyberSecurity Leadership, and Judgement as a Defining Skill - BSW #465
1 Quelle
Amazon Blitzangebote: MacBook Neo, Powerbanks, EcoFlow + Zendure, Mähroboter und mehr
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How I Cut Aider's Token Bill 80%: Prompt Caching, MCP Code Mode, and Tier Routing

Thematisch verwandte Begriffe: Aiders, Token, Bill, Prompt · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...