AI Pair Programming with Aider and Antbase
ยท5 min read
๐Ÿ‘ฅ

AI Pair Programming with Aider and Antbase

Configure Aider to use Antbase for AI pair programming with intelligent model routing and cost optimization.

aidercodingcli

Aider is one of the most effective AI coding tools available โ€” it reads your codebase, makes multi-file edits, and commits them to git automatically. But it is also one of the most expensive to run. A typical Aider session sends the full content of every file in context with every prompt, which means a single "fix this bug" command might burn 50K tokens. Multiply that by a day of active pair programming and you are looking at serious costs, even on GPT-4o-mini.

The thing is, not every Aider command needs the same level of intelligence. When Aider reads a file to understand its structure, that is a simple parsing task. When it generates a commit message, that is boilerplate. When it plans a complex refactor across five files โ€” that is where you actually need a premium model. But with a static model configuration, every single one of those operations hits the same endpoint at the same price.

Antbase brings per-request routing to Aider sessions. Each API call gets independently classified: simple operations go to fast free models, complex code generation goes to premium ones. The result is Aider sessions that feel just as capable but cost a fraction of what they used to. And because Antbase has fallover across providers, your pair programming session does not crash if OpenAI has a hiccup โ€” it just routes to another capable model and keeps going.

Aider is a command-line AI coding assistant that edits files in your git repo. It supports multi-file edits, automatic git commits, and works with any OpenAI-compatible API. Connecting it to Antbase gives you intelligent routing โ€” complex refactors get premium models, simple edits get fast ones.

Setup

bash
pip install aider-chat

# Set environment variables
export OPENAI_API_BASE=https://antbase.ai/v1
export OPENAI_API_KEY=ant_your-api-key

Running Aider

bash
# Use auto-routing
aider --model openai/auto

# Or pin a specific model
aider --model openai/gpt-4o

# Add files to the chat context
aider --model openai/auto src/auth.ts src/middleware.ts

Persistent Configuration

Create a .aider.conf.yml in your project root for persistent settings:

yaml
# .aider.conf.yml
model: openai/auto
openai-api-base: https://antbase.ai/v1
openai-api-key: ant_your-api-key
auto-commits: true
gitignore: true

Tips

  • โ€ขAider sends the full file content as context. For large files, Antbase may route to a model with a bigger context window automatically.
  • โ€ขUse /tokens in the Aider chat to see token usage. Antbase shows per-request routing details in the dashboard.
  • โ€ขAider supports architect mode (--architect) where one model plans and another executes. You can use Antbase for both or mix providers.
  • โ€ขIf Aider reports model errors, ensure you prefix the model name with openai/ so Aider uses the OpenAI-compatible provider.

Try ANT routing today

Drop-in OpenAI-compatible API. Change your base URL and every request gets intelligent routing across 30+ providers.