Aider · Terminal coding agent

Aider + Leanroute

Aider lives in your terminal next to git. Its OpenAI provider speaks our wire format; we point it at us with two env vars and pick the model on the command line.

1. Get a gateway key

From /dashboard/keys create a key labeled "aider". If you run Aider in multiple repos with different cost expectations, consider one key per repo with its own daily spend cap.

2. Drop a .env in your repo

Aider auto-loads a .env from the working directory on startup. Add the two values:

OPENAI_API_BASE=https://api.leanroute.dev/v1
OPENAI_API_KEY=gw_live_YOUR_KEY

Add the line .env to your repo's .gitignore so the key never gets committed. (Alternative: export the vars in your shell rc and skip the file entirely.)

3. Run Aider with a Leanroute model

Aider's --model flag wants the provider family prefix (openai/) followed by our canonical provider/model name. The first openai/ is Aider's "use the OpenAI SDK" selector; the second segment is the model we route to.

# Sonnet via Leanroute
aider --model openai/anthropic/claude-sonnet-4-6

# DeepSeek-V3 (cheap flagship)
aider --model openai/deepseek/deepseek-v3

# GPT-4o
aider --model openai/openai/gpt-4o

4. Save typing with shell aliases

Once you settle on the two or three models you actually use:

# ~/.bashrc or ~/.zshrc
alias aider-sonnet='aider --model openai/anthropic/claude-sonnet-4-6'
alias aider-deepseek='aider --model openai/deepseek/deepseek-v3'
alias aider-gpt4o='aider --model openai/openai/gpt-4o'

Reload your shell. Now aider-sonnet kicks off a Sonnet session.

Optional: track per-repo cost

Aider doesn't know about Leanroute's request log, but every Aider session leaves a clean trail there. Filter /dashboard/logs by the API key you assigned per repo to see what each repo cost over a week. Configure a daily spend cap on that key if you want a hard wall at, say, $5/day.

Troubleshooting

  • Aider says "model not recognized": you almost certainly dropped the first openai/. Aider needs both segments — openai/anthropic/claude-sonnet-4-6, not anthropic/claude-sonnet-4-6.
  • Aider hangs on the first request: env vars aren't loaded. Confirm echo $OPENAI_API_BASE shows our URL. If the .env approach isn't working, export them in the shell instead.
  • 402 insufficient_credit: top up at /dashboard/billing. Aider surfaces the error in the terminal so it's hard to miss.
  • Want streaming off: add --no-stream to the Aider command. Our non-streaming path translates tool calls fully for every provider.