Engineering Guide

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.

Aider chat setup — install it and point it at any LLM with one config

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:

MethodCommandWhen to use it
aider-install (recommended)python -m pip install aider-install then aider-installDefault — isolated, no dependency clashes
uvuv tool install --force --python python3.12 --with pip aider-chat@latestIf you already use uv for tools
pipxpipx install aider-chatIf you keep CLIs in pipx
pippython -m pip install -U --upgrade-strategy only-if-needed aider-chatManual control of the environment
One-line installermacOS/Linux: curl -LsSf https://aider.chat/install.sh | shNo 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:

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:

  1. Dedicated flags. --openai-api-key and --anthropic-api-key for those two providers; every other provider uses --api-key provider=<key>, e.g. --api-key gemini=xxx.
  2. Environment variables. OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY, DEEPSEEK_API_KEY — these can live in a .env file that Aider loads automatically.
  3. YAML config. In .aider.conf.yml use keys like openai-api-key: / anthropic-api-key:, or an api-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.

Aider (terminal)--model openai/… OPENAI_API_BASEone key · /v1 endpoint Claude Opus 4.8 GPT-OSS 120B GLM-5.2
One base URL + one key reaches every model behind an OpenAI-compatible gateway; /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:

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:

WhatFlagEnv varNotes
Main model--model MODELAIDER_MODELPrimary chat + editing model
Cheap helper model--weak-modelAIDER_WEAK_MODELCommit messages, summaries
Editor model--editor-modelAIDER_EDITOR_MODELEditor tasks / architect mode
OpenAI-compat base URL--openai-api-baseAIDER_OPENAI_API_BASE / OPENAI_API_BASEPoint at a gateway
OpenAI key--openai-api-keyOPENAI_API_KEYAlso used for compat endpoints
Anthropic key--anthropic-api-keyANTHROPIC_API_KEYDedicated Anthropic flag
Other provider key--api-key provider=<key>e.g. GEMINI_API_KEYe.g. --api-key gemini=xxx

Config can also live in .aider.conf.yml (YAML keys) or a .env file. And the in-chat commands:

CommandDoes
/addAdd files so Aider can edit & review them
/dropRemove files from the chat to free context
/read-onlyAdd files for reference only
/askAsk about the codebase without editing
/codeAsk for changes to your code
/architectArchitect/editor mode using 2 models
/modelSwitch the main model to a new LLM
/run (alias !)Run a shell command, optionally add output
/webScrape a page to markdown into the chat
/diffShow diff of changes since last message
/commitCommit edits made outside the chat
/undoUndo the last Aider-made git commit
/clearClear chat history
/helpAsk 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.

Written by
Kevin Fan

Founder of DataLLM Lab, the unified LLM gateway. Kevin tests models the boring way — same prompts, real costs, unedited outputs — and writes up what the runs actually show.

One API for every model

One API, every model.

Get a single API key for Claude Opus 4.7, GPT-5.4, and 300+ more — with automatic price comparison and routing to the best model for every request.