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
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
Tip: Always include the openai/ prefix (case-sensitive) before your model name.
This ensures Aider correctly routes requests to your AI/ML API endpoint.
Installation
✅ Prerequisites
AI/ML API key
Python 3.8–3.13 installed
Internet access to
api.aimlapi.comAider installed (Install Guide)
1️⃣ Install Aider
python -m pip install aider-install
aider-install
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 terminal3️⃣ Run Aider with AI/ML API
Move into your project directory:
cd /to/your/projectThen 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
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-latestopenai/meta-llama/Llama-3-70b-chat-hfopenai/deepseek/deepseek-chatopenai/anthropic/claude-3.7-sonnetopenai/google/gemini-1.5-pro
Example Aider Session
cd ~/workspace/myapp
aider --model openai/chatgpt-4o-latestAider will:
Load your project map.
Analyze the repo.
Apply AI-suggested edits.
Commit changes automatically.


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_BASEand your internet access
📚 References
Last updated
Was this helpful?