--- title: Aider on a budget: point it at a cheap OpenAI-compatible endpoint slug: aider-cheap-inference canonical_url: https://blog.juscode.co/aider-cheap-inference published_at: 2026-05-26T00:00:00+00:00 author: jusCode tags: aider, openai-compatible, cost-optimization, custom-base-url, ai-pair-programming tldr: Set OPENAI_API_BASE=https://api.juscode.co/v1 and OPENAI_API_KEY=jcg_... then run `aider --model openai/jusCode-auto`. Aider's per-turn full-context re-send pattern means it benefits more than most agents from per-call model routing: typical savings 60-80% with no quality regression. key_takeaways: - Aider works with any OpenAI-compatible endpoint via aider --model openai/jusCode-auto. - Set base_url to https://api.juscode.co/v1 and use a jcg_ token with model jusCode-auto. - Aider re-sends full file context every turn, so per-call routing saves 60-80%. --- # Aider on a budget: cut your bill 70% with one env var [Aider](https://aider.chat) is among the best command-line pair-programmers on the planet. It's also expensive to run on default settings because its design (*re-send the relevant repo context every turn*) burns tokens. This post shows how to route Aider through a cheaper inference endpoint without changing anything about how you use it. ## The two env vars that change everything Aider respects the standard OpenAI env vars. Set these in your shell: ```sh export OPENAI_API_BASE="https://api.juscode.co/v1" export OPENAI_API_KEY="jcg_your_key_here" ``` Then run Aider with an explicit model name so it knows to use the OpenAI provider path: ```sh aider --model openai/jusCode-auto ``` That's it. Aider now sends every call to jusCode, which routes per-call to the cheapest capable model. Average bill drops 60-80% on a typical refactor session. ## Why Aider gets expensive Aider operates by sending **the entire content of every file you've added to the chat** with every turn. This is correct behavior: the model needs context. But it means: - A 5-turn refactor on three 300-line files = ~30k prompt tokens × 5 turns = 150k tokens just in repeated context. - At Sonnet 4.5 rates that's $0.45 in *prompt-only* spend per session. - Multiply by 30 sessions/day × 4 weeks = $540/month per engineer. jusCode's mitigation isn't magic. It's that **most of those turns don't need Sonnet**. A "fix this lint error" turn that comes after a successful "implement feature X" turn can route to an 8B-parameter model for 1/50th the price. The next turn ("now add tests") can route back up. You don't pick; we do. ## Pinning a model when you need to Sometimes you want a specific model for a session, say, you're doing a tricky algorithmic refactor and you want Sonnet end-to-end. Pass it explicitly: ```sh aider --model openai/anthropic/claude-sonnet-4.5 # or aider --model openai/openai/gpt-5 ``` jusCode normalizes the provider prefix, so you don't need accounts at each upstream. The `openai/` outer prefix tells Aider to use the OpenAI client path (which then hits jusCode). The inner `anthropic/...` or `openai/...` is the model id we route to. ## Verifying it works After a session, run: ```sh aider --usage ``` You'll see token counts. Cross-reference against your jusCode dashboard at [juscode.co/developer → Usage tab](https://juscode.co/developer). The numbers should match within a token or two (Aider counts client-side; jusCode counts server-side; they diverge only on streamed responses with mid-stream cutoffs). ## What works, what to watch for | Feature | Works? | Notes | |---|---|---| | `/add` files | ✅ | normal repo-context flow | | `/drop` files | ✅ | | | `/diff` edits | ✅ | Aider's "diff" edit format works because models we route to all support it | | `/ask` mode | ✅ | reads files, doesn't propose edits | | `/code` mode | ✅ | | | Voice mode | ✅ | uses Aider's Whisper integration; transcription stays local | | Git auto-commits | ✅ | unrelated to inference | | Custom edit formats | ✅ | `--edit-format diff` and `udiff` both work | | Repo map | ✅ | the auto-generated repo map gets included in context | | Image inputs | ✅ | auto-routes to a vision-capable model | | Architect mode (`--architect`) | ✅ | uses two models (architect + editor); both go through jusCode | ## Architect mode + cost Aider's `--architect` mode is great for big features (architect proposes, editor implements). On default settings it uses Sonnet for both, which doubles cost. Aider lets you specify them separately: ```sh aider --architect \ --architect-model openai/anthropic/claude-sonnet-4.5 \ --editor-model openai/qwen3-coder-480b ``` This pattern (frontier model for planning, cheap model for execution) typically halves architect-mode cost with no quality regression on the architect's output. ## Cache-aware modes If you're on a model that supports prompt caching (Sonnet 4.5, GPT-5), Aider passes the cache-control hints through. jusCode forwards them. Your second turn in a session uses cached context, which is up to 90% cheaper. Watch your dashboard to verify cache hits land: the savings show as a separate line on the usage breakdown. ## Setup checklist 1. Install Aider: `pipx install aider-install && aider-install` 2. Mint a jusCode key at [juscode.co/developer](https://juscode.co/developer) → Keys tab. 3. Set the env vars above in `~/.zshrc` or `~/.bashrc`. 4. `source ~/.zshrc` 5. `cd` into your repo and run `aider --model openai/jusCode-auto`. 6. Use Aider normally for a day. Check spend on the [dashboard](https://juscode.co/developer). ## Related reading - [OpenAI-compatible drop-in (full reference for every harness)](/docs/openai-drop-in/) - [The cheapest LLM API for coding agents in 2026](/blog/cheapest-llm-api-for-coding-2026/) - [Use jusCode with Claude Code](/docs/claude-code/) - [Use jusCode with OpenCode](/docs/opencode/) --- *Raw markdown: [/blog/aider-cheap-inference.md](/blog/aider-cheap-inference.md)* ## FAQ ### How do I point Aider at a cheaper endpoint? Use aider --model openai/jusCode-auto: base_url https://api.juscode.co/v1, a jcg_ token, and model jusCode-auto. Behavior is unchanged. ### Does Aider lose any features on a custom endpoint? No. Tool use, edits, and memory keep working; only the model selection moves behind the gateway. ### How much does per-call routing save? Typically 60-80% on real coding-agent workloads, because most steps do not need a frontier model.