Use Xantly with Aider (CLI)
Aider is a terminal pair-programmer with a clever main/editor/weak model split. One --openai-api-base flag points it at Xantly for 60-70% cost savings via role-split routing.
Aider is a terminal-native pair-programming tool, edit files directly from the command line, get a git commit per change. The simplest Xantly integration in the ecosystem: one flag.
Prerequisites
- Aider installed:
pipx install aider-chat(orpip install aider-chat) - A Xantly API key, create one
Setup
One flag:
aider \
--openai-api-base https://api.xantly.com/v1 \
--openai-api-key xantly_sk_... \
--model xantly/auto-quality
Or as environment variables (persistent across sessions):
export OPENAI_API_BASE=https://api.xantly.com/v1
export OPENAI_API_KEY=xantly_sk_...
export AIDER_MODEL=xantly/auto-quality
aider
Drop them in ~/.zshrc or .env in your project root.
Model roles
Aider uses three distinct model roles, you can point each at a different Xantly model for maximum cost/quality control:
aider \
--openai-api-base https://api.xantly.com/v1 \
--openai-api-key xantly_sk_... \
--model xantly/auto-quality \ # main, plans edits
--editor-model xantly/auto-value \ # applies diffs
--weak-model xantly/auto-speed # summaries, commit messages
- Main model: does the planning, reasoning. Needs quality.
- Editor model: applies the diffs. Value-tier is plenty.
- Weak model: generates commit messages, summarizes changes. Speed-tier is fine.
With this split, a typical Aider session costs 60-70% less than running everything on the main model, without losing quality.
Verify
cd any-git-repo
aider --openai-api-base https://api.xantly.com/v1 --openai-api-key xantly_sk_... --model xantly/auto-quality
# inside aider:
> add a README section explaining what this project does
Aider should propose a diff, you approve it, aider applies it and creates a git commit. Check your Xantly dashboard, you'll see the request logged with its cost.
What you get
- Cost savings via role split. Aider already supports "weak model" for non-critical calls; with Xantly you get another layer of savings via semantic cache and BaRP routing within each role.
- Waterfall fallback. Aider requests to Anthropic that fail (overloaded, etc.) silently fall back to OpenAI or another T1 model. Your session never stalls mid-edit.
- Memory. Aider's
--architectmode benefits from Xantly's memory layer remembering prior design decisions across sessions. Opt in viaX-Xantly-Memory-Mode: recallin your Aider config (coming soon as a native Aider setting). - Cost visibility. Every Aider turn shows up in your dashboard with model, cache status, cost, latency.
Gotchas
--openai-api-base must include /v1. Same rule as the OpenAI SDK. Don't use the bare hostname.
Aider supports Anthropic too. If you prefer the Messages API shape, use --anthropic-api-base https://api.xantly.com with ANTHROPIC_API_KEY=... once Xantly's /v1/messages ships (week 2 of the integrations rollout).
.env in project root overrides shell exports. If OPENAI_API_BASE is set in .env to the old value, shell exports won't help. Check .env first.
Next steps
- Claude Code, Anthropic's CLI, similar role split. Uses Xantly's
/v1/messagesendpoint. - OpenCode, sst/opencode, TypeScript-based CLI with the same BYO story.
- Cost-Optimized Routing, deep dive on how Xantly's BaRP routing keeps Aider cheap.