Aider is a CLI pair-programmer that edits files in your repo via LLM round-trips. It supports any OpenAI-compatible endpoint viaDocumentation Index
Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
--openai-api-base, which is exactly what the LangWatch AI Gateway exposes.
Setup
litellm under the hood — it will route anthropic/claude-* model names through its Anthropic handler, which uses ANTHROPIC_BASE_URL:
/v1/messages endpoint, which is Anthropic-native and preserves cache_control blocks byte-for-byte (load-bearing for Aider’s repo-map caching — see below).
Cache-aware repo maps
Aider sends your repo map as a long system prompt (often 20–50k tokens). Anthropic caches the repo map withcache_control: {type: "ephemeral"}, giving a 90% discount on cache hits. The gateway preserves these cache markers on /v1/messages, so your Aider session pays full price once and discounted price on every follow-up in the 5-minute cache window.
For this to work:
- Use
/v1/messages(Anthropic shape), not/v1/chat/completions. - Set VK
cache.mode: respect(the default). Do NOT usecache.mode: disablewith Aider — it 10×s your Claude bill.
Trace propagation
Aider doesn’t natively emit a trace, but you can thread one manually:OPENAI_EXTRA_HEADERS passthrough works with openai Python SDK ≥ v1.30. Aider versions pinned to older SDKs ignore it.Governance recipes
Per-engineer Aider budget
- Scope:
principal, target: the engineer. - Window:
day, limit:$25. on_breach:block(Aider errors out cleanly — better than a $400 mistake).
Block destructive tools
Aider uses a tool-based interface for applying diffs. If you want to route Aider through a read-only VK (for demo purposes):- VK
policy_rules.tools:["shell", "run"].
/run command returns 403 tool_not_allowed and the agent surfaces the error.
Fallback to a cheaper model on 429
Chain:openai-primary → openai-cheap-backup (same provider, different-region key with a lower quota).
When OpenAI rate-limits your primary, Aider keeps working at slightly degraded quality instead of erroring. See Fallback Chains.
Troubleshooting
- Aider complains “invalid_api_key” — verify you exported
OPENAI_API_KEYwith the VK value, not your real OpenAI key. ANTHROPIC_BASE_URLignored — Aider’s litellm handler needs litellm ≥ v1.40; earlier versions hardcodeapi.anthropic.com.- Cache misses on repo maps — confirm your model is
anthropic/*(uses/v1/messages) and VKcache.modeisrespect.disabledefeats the Anthropic discount. - Gateway returns
413 payload_too_large— Aider can send 100k+ token prompts on large repos. Check the gateway’sLW_GATEWAY_MAX_BODY_BYTESsetting (default 10MB).