Using Routic with Aider
Switch Aider's AI backend to Routic and use Claude, GPT-4o, and more at a lower cost.
How it works
Aider supports --openai-api-base for any OpenAI-compatible endpoint and --anthropic-api-base for Anthropic-compatible endpoints. Routic supports both formats.
Prerequisites
- Aider installed (
pip install aider-installorpip install aider-chat) - A Routic Base URL and Virtual Key
Setup
Option 1: Command-line flags (quick test)
aider \
--openai-api-key YOUR_ROUTIC_VIRTUAL_KEY \
--openai-api-base https://YOUR_GATEWAY_HOST/v1 \
--model YOUR_MODEL_NAME
Example with Claude Sonnet:
aider \
--openai-api-key sk-tb-xxxx \
--openai-api-base https://api.yourdomain.com/v1 \
--model claude-3-5-sonnet-20241022
Note:
--openai-api-basemust include the/v1suffix.
Option 2: .aider.conf.yml (recommended for daily use)
Create in your project root or ~/.aider.conf.yml:
openai-api-key: YOUR_ROUTIC_VIRTUAL_KEY
openai-api-base: https://YOUR_GATEWAY_HOST/v1
model: YOUR_MODEL_NAME
After this, run aider from the project directory without any extra flags.
Option 3: Environment variables
export OPENAI_API_KEY="YOUR_ROUTIC_VIRTUAL_KEY"
export OPENAI_BASE_URL="https://YOUR_GATEWAY_HOST/v1"
Older Aider versions may read
OPENAI_API_BASE(without_URL). Check your version's docs.
Using Anthropic format (Claude models)
To use Anthropic's native message format instead:
export ANTHROPIC_BASE_URL="https://YOUR_GATEWAY_HOST"
aider \
--anthropic-api-key YOUR_ROUTIC_VIRTUAL_KEY \
--model claude-3-5-sonnet-20241022
ANTHROPIC_BASE_URLshould not include/v1— Aider appends the path automatically.
Verify
aider --message "reply with pong" --no-git
A normal response confirms everything is working.
Choosing a model
The --model value must exactly match a name in the Routic catalog.
Suggested models (verify against current catalog):
| Use case | Model |
|---|---|
| Everyday coding (speed/cost balance) | claude-3-5-sonnet-20241022 or equivalent |
| Complex refactors / long context | Claude Opus series |
| Fast small edits | gpt-4o-mini or equivalent |
Troubleshooting
Model ... not found
Use the full catalog name — shorthand like sonnet won't work.
Aider warns about missing function calling support
Switch to a catalog model that supports function calling.
Different models per project
Create a .aider.conf.yml in each project root; project-level config overrides ~/.aider.conf.yml.
Routic