How to Use Aider Chat with Any LLM & One Key
Aider is AI pair programming in your terminal — a command-line tool that edits code in your local git repository by talking to an LLM. Its best feature for anyone who juggles models is that it is model-agnostic: you pick the LLM with a single --model flag, hand it a key, and go. This guide shows how to install Aider, point it at any model — including an OpenAI-compatible endpoint so one key covers Claude, GPT-OSS, GLM and more — the in-chat /commands you will use every day, and a config table plus a command cheat sheet you can keep open while you work.
What Aider chat is
Aider is "AI pair programming in your terminal" — a command-line tool that works with an LLM to edit code in your local git repository. You launch it inside a git repo, add the files you want to work on, and describe the change in plain language. Aider sends the relevant code to the model, applies the edits it gets back, and commits them to git so every change is tracked and easy to undo. Because the model is chosen at runtime, Aider is deliberately model-agnostic: it is a front-end, and you decide which LLM sits behind it.
That makes the interesting question not "is Aider good" but "which model do I point it at, and how" — which is the rest of this guide. If you are comparing terminal agents, our Claude Code vs Cline breakdown covers the editor-integrated alternatives; Aider is the git-native, terminal-first option.
Install Aider
The recommended path is the aider-install bootstrapper; there are five documented ways in total. The bootstrapper sets Aider up in its own isolated environment so it does not collide with your project's Python packages:
python -m pip install aider-install
aider-install
Pick whichever of these fits your setup — all are from Aider's official install docs:
| Method | Command | When to use it |
|---|---|---|
| aider-install (recommended) | python -m pip install aider-install then aider-install | Default — isolated, no dependency clashes |
| uv | uv tool install --force --python python3.12 --with pip aider-chat@latest | If you already use uv for tools |
| pipx | pipx install aider-chat | If you keep CLIs in pipx |
| pip | python -m pip install -U --upgrade-strategy only-if-needed aider-chat | Manual control of the environment |
| One-line installer | macOS/Linux: curl -LsSf https://aider.chat/install.sh | sh | No Python set up yet |
On Windows, the one-line installer is a PowerShell command: powershell -ExecutionPolicy ByPass -c "irm https://aider.chat/install.ps1 | iex". Full details are in the Aider install docs.
Point Aider at a model
You choose the LLM with the --model flag — aider --model MODEL — and that is the main chat model. Aider also exposes two supporting model slots for people who want to tune cost and quality:
--model MODEL— the model used for the main chat (your primary reasoning + editing model).--weak-model— used for cheaper background tasks: commit messages and chat-history summarization.--editor-model— used for editor tasks (for example, the editor half of architect mode).
Every command-line flag has a matching AIDER_* environment variable, so --model is also settable as AIDER_MODEL and --openai-api-base as AIDER_OPENAI_API_BASE — handy for CI or a shared shell profile. Which model to actually pick is a separate question; our best coding LLM in 2026 comparison ranks the current options for exactly this kind of agentic editing.
Set your API key
Aider reads your key from any of four places — a flag, an environment variable, a .env file, or the YAML config. All four are documented; use whichever fits your workflow:
- Dedicated flags.
--openai-api-keyand--anthropic-api-keyfor those two providers; every other provider uses--api-key provider=<key>, e.g.--api-key gemini=xxx. - Environment variables.
OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,OPENROUTER_API_KEY,DEEPSEEK_API_KEY— these can live in a.envfile that Aider loads automatically. - YAML config. In
.aider.conf.ymluse keys likeopenai-api-key:/anthropic-api-key:, or anapi-key:list for other providers (e.g.- openrouter=bar).
A minimal .env for an Anthropic model looks like this:
# .env
ANTHROPIC_API_KEY=sk-ant-...
See the API-keys docs for the full matrix. Note that .env and .aider.conf.yml hold secrets — add them to .gitignore so they never get committed.
Use any OpenAI-compatible endpoint
Point Aider at any OpenAI-compatible provider by setting a base URL and key, then prefixing the model name with openai/. This is the path that matters if you want one key to front many models. Two environment variables and the prefix are all it takes:
export OPENAI_API_BASE=https://www.datallmlab.com/v1
export OPENAI_API_KEY=your-gateway-key
aider --model openai/anthropic/claude-opus-4.8
The openai/ prefix tells Aider to use the OpenAI-compatible transport; everything after it is the model name your endpoint expects. You can also set the base URL with the --openai-api-base VALUE flag instead of the env var — Aider's docs describe it simply as "Specify the api base url." Because this is standard OpenAI-compatible configuration, it works with any endpoint that speaks the OpenAI Chat Completions shape — see our OpenAI-compatible API guide for what that contract covers. Details: Aider OpenAI-compatible docs.
/model switches between them mid-session. Diagram: DataLLM Lab, July 2026.The /commands you actually use
Aider is driven by slash-commands typed into the chat — a handful cover almost everything. The core ones, straight from the usage docs:
- Files:
/add(add files so Aider can edit and review them),/drop(remove files from the chat to free context),/read-only(add files for reference only, not editing). - Working:
/ask(ask questions about the codebase without editing files),/code(ask for changes to your code),/architect(architect/editor mode using two different models). - Models & context:
/model(switch the main model to a new LLM),/run(run a shell command and optionally add its output to the chat; alias!),/web(scrape a webpage, convert to markdown, and send it in a message). - Git & session:
/diff(show diff since last message),/commit(commit edits made outside the chat),/undo(undo the last Aider-made git commit),/clear(clear chat history),/help(ask questions about Aider).
The workflow most people settle into: /add the two or three files that matter, /ask to explore before you change anything, /code to make the edit, /diff to review, and /undo if it went sideways. Full list in the Aider commands docs.
Config & command cheat sheet
Two tables to keep open while you work — the config surface, then the in-chat commands. First, where each setting lives and its environment-variable form:
| What | Flag | Env var | Notes |
|---|---|---|---|
| Main model | --model MODEL | AIDER_MODEL | Primary chat + editing model |
| Cheap helper model | --weak-model | AIDER_WEAK_MODEL | Commit messages, summaries |
| Editor model | --editor-model | AIDER_EDITOR_MODEL | Editor tasks / architect mode |
| OpenAI-compat base URL | --openai-api-base | AIDER_OPENAI_API_BASE / OPENAI_API_BASE | Point at a gateway |
| OpenAI key | --openai-api-key | OPENAI_API_KEY | Also used for compat endpoints |
| Anthropic key | --anthropic-api-key | ANTHROPIC_API_KEY | Dedicated Anthropic flag |
| Other provider key | --api-key provider=<key> | e.g. GEMINI_API_KEY | e.g. --api-key gemini=xxx |
Config can also live in .aider.conf.yml (YAML keys) or a .env file. And the in-chat commands:
| Command | Does |
|---|---|
/add | Add files so Aider can edit & review them |
/drop | Remove files from the chat to free context |
/read-only | Add files for reference only |
/ask | Ask about the codebase without editing |
/code | Ask for changes to your code |
/architect | Architect/editor mode using 2 models |
/model | Switch the main model to a new LLM |
/run (alias !) | Run a shell command, optionally add output |
/web | Scrape a page to markdown into the chat |
/diff | Show diff of changes since last message |
/commit | Commit edits made outside the chat |
/undo | Undo the last Aider-made git commit |
/clear | Clear chat history |
/help | Ask questions about Aider |
One key for every model
Because Aider accepts a custom base URL plus a key, an OpenAI-compatible gateway lets a single credential reach many models — and /model switches between them mid-session. Instead of managing an OpenAI key, an Anthropic key, a DeepSeek key and so on, you set one OPENAI_API_BASE and one OPENAI_API_KEY, launch with the openai/ prefix, and reach Claude, GPT-OSS, GLM and hundreds of others through the same endpoint. This is ordinary OpenAI-compatible configuration — there is no special "Aider integration" involved, just the base-URL contract Aider already supports.
The practical payoff is cost control: run a cheap model as your --weak-model for commit messages, a strong one for /architect, and switch the main model per task without re-plumbing keys. That routing-for-cost pattern is the subject of our guide to cutting token costs in coding agents.
Point Aider at 300+ models with one key
DataLLM Lab is an OpenAI-compatible endpoint. Set OPENAI_API_BASE=https://www.datallmlab.com/v1, launch aider --model openai/<model>, and reach Claude, GPT-OSS, GLM and more on a single key.
FAQ
What is Aider chat?
Aider is "AI pair programming in your terminal" — a command-line tool that works with an LLM to edit code in your local git repository. You add files, describe a change, and Aider edits and commits them. It is model-agnostic: you choose the LLM with --model.
How do I install Aider?
The recommended way is the bootstrapper: python -m pip install aider-install then aider-install. You can also use uv, pipx, plain pip, or the one-line curl -LsSf https://aider.chat/install.sh | sh (macOS/Linux) or PowerShell installer (Windows).
How do I choose which model Aider uses?
Pass --model MODEL for the main chat. There are also --weak-model (commit messages and summaries) and --editor-model (editor tasks). Every flag has a matching AIDER_* env var, e.g. AIDER_MODEL.
How do I set my API key in Aider?
Four ways: dedicated flags (--openai-api-key, --anthropic-api-key, or --api-key provider=<key>); env vars like OPENAI_API_KEY in a .env file; or the YAML config .aider.conf.yml.
Can Aider use an OpenAI-compatible endpoint?
Yes. Set OPENAI_API_BASE and OPENAI_API_KEY (or the --openai-api-base flag), then launch with the openai/ prefix: aider --model openai/<model-name>. That is the standard way to point Aider at any compatible gateway.
What are the core Aider commands?
/add, /drop, /read-only, /ask, /code, /architect, /model, /run (alias !), /web, /diff, /commit, /undo, /clear and /help.
Can I use one key across many models with Aider?
Yes — point Aider at an OpenAI-compatible gateway. A custom base URL plus one key lets a single credential reach Claude, GPT-OSS, GLM and more, with /model switching between them. Standard OpenAI-compatible config, not a special integration.
DataLLM Lab