Aider

About

Aider is a command-line pair programming tool that connects to OpenAI-compatible APIs. It lets you chat with models to edit your codebase, auto-commit changes, and build software collaboratively from the terminal.

This guide explains how to connect AI/ML API to Aider using the OpenAI-compatible flow. You’ll get a clean setup with one endpoint, support for slashes in model names, and full compatibility with all chat-completion models.


Quick Setup

Field
Value

Base URL

https://api.aimlapi.com/v1

API Key

Your AI/ML API key (create at aimlapi.com/app/keys)

Model

openai/meta-llama/Llama-3-70b-chat-hf (openai/<your_full_model_id>)

Command Example

aider --model openai/chatgpt-4o-latest


Installation

✅ Prerequisites

  • AI/ML API key

  • Python 3.8–3.13 installed

  • Internet access to api.aimlapi.com

  • Aider installed (Install Guide)


1️⃣ Install Aider

python -m pip install aider-install
aider-install
Install Aider via terminal

2️⃣ Configure AI/ML API credentials

Mac/Linux

export OPENAI_API_BASE=https://api.aimlapi.com/v1
export OPENAI_API_KEY=<your_aimlapi_key>

Windows (PowerShell)

setx OPENAI_API_BASE https://api.aimlapi.com/v1
setx OPENAI_API_KEY <your_aimlapi_key>
# restart your terminal

3️⃣ Run Aider with AI/ML API

Move into your project directory:

cd /to/your/project

Then launch Aider with your preferred model:

# GPT-4o (OpenAI)
aider --model openai/chatgpt-4o-latest

# Meta Llama 3 70B Chat
aider --model openai/meta-llama/Llama-3-70b-chat-hf

# DeepSeek Chat V3
aider --model openai/deepseek/deepseek-chat

# Claude 3.7 Sonnet
aider --model openai/anthropic/claude-3.7-sonnet

# Gemini 1.5 Pro
aider --model openai/google/gemini-1.5-pro
Running Aider with AI/ML API model
Running Aider with AI/ML API model

4️⃣ Model Prefix Rule

Aider automatically routes requests to your OPENAI_API_BASE. To connect to AI/ML API, always prefix your model with openai/.

Pattern:

openai/<provider>/<model-name>

Examples:

  • openai/chatgpt-4o-latest

  • openai/meta-llama/Llama-3-70b-chat-hf

  • openai/deepseek/deepseek-chat

  • openai/anthropic/claude-3.7-sonnet

  • openai/google/gemini-1.5-pro


Example Aider Session

cd ~/workspace/myapp
aider --model openai/chatgpt-4o-latest

Aider will:

  1. Load your project map.

  2. Analyze the repo.

  3. Apply AI-suggested edits.

  4. Commit changes automatically.

Aider researching your repo
Aider researching your repo
Aider working on code changes
Aider working on code changes

Common Pitfalls

  • Bad request – check parameters → verify the model name and prefix

  • Unknown model → confirm it exists in AI/ML API Models

  • Invalid API key → re-copy from AI/ML API Dashboard

  • No response → check OPENAI_API_BASE and your internet access


📚 References

Last updated

Was this helpful?