---
title: "Aider integration"
description: "Settings for using Aider with MiniRouter."
canonical_url: "https://minirouter.sh/docs/integrations/aider"
markdown_url: "https://minirouter.sh/docs/integrations/aider.md"
last_updated: "2026-09-26"
---

# Aider

Pair program in your terminal with any model in the MiniRouter catalog.

[Get a key](https://minirouter.sh/key)

[Aider](https://aider.chat) is a terminal pair programmer that edits files in your git repo and commits each change. Point its OpenAI-compatible mode at MiniRouter to use any model in the [catalog](https://minirouter.sh/models), or a [router](https://minirouter.sh/docs/auto-router), with one balance and per-key [spend limits](https://minirouter.sh/docs/rate-limits).

> **Note:** Prefix every model with `openai/`. Aider strips it and sends the rest, so `openai/zai/glm-5.3-flash` reaches `zai/glm-5.3-flash`.

## Quick start

### 1. Install Aider

**macOS / Linux**

```sh
curl -LsSf https://aider.chat/install.sh | sh
```

**Windows**

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://aider.chat/install.ps1 | iex"
```

### 2. Create a key

[Create a key](https://minirouter.sh/key) for Aider.

> **Tip:** Give Aider its own key, so its spend shows separately in [Usage](https://minirouter.sh/dashboard/usage) and a limit stops only Aider.

### 3. Point Aider at MiniRouter

**macOS / Linux**

```sh
export OPENAI_API_BASE=https://api.minirouter.sh/v1
export OPENAI_API_KEY=mr-live-YOUR-KEY-HERE
aider --model openai/zai/glm-5.3-flash
```

**Windows**

```powershell
setx OPENAI_API_BASE https://api.minirouter.sh/v1
setx OPENAI_API_KEY mr-live-YOUR-KEY-HERE
```

Open a new shell, then run `aider --model openai/zai/glm-5.3-flash`.

### 4. Send a prompt

Ask for one change, then open [Activity](https://minirouter.sh/dashboard/activity). The request lists its model, tokens and exact cost.

## Switch models

Keep the `openai/` prefix in flags and in chat.

| Command | Does |
| --- | --- |
| `/model openai/openai/gpt-5.6-sol` | Switches the main model mid-chat to [GPT 5.6 Sol](https://minirouter.sh/models/openai/gpt-5.6-sol). |
| `/weak-model openai/minirouter/auto:cheap` | Commit messages and history summaries. |
| `--model openai/minirouter/auto:code` | Lets [Auto](https://minirouter.sh/docs/auto-router) pick a coding model. |
| `--model openai/@preset/your-slug` | Runs a saved [preset](https://minirouter.sh/docs/presets). |

## Save the setup

Put the endpoint and models in `.aider.conf.yml`, and the key in `.env`.

**.aider.conf.yml**

```yaml
openai-api-base: https://api.minirouter.sh/v1
model: openai/zai/glm-5.3-flash
weak-model: openai/minirouter/auto:cheap
```

**.env**

```sh
OPENAI_API_KEY=mr-live-YOUR-KEY-HERE
```

Aider loads both from your home directory, the git root, then the current directory. Later files win.

> **Warning:** Add `.env` to `.gitignore` before saving the key in a repo.

## Run headless

`--message` sends one instruction, applies the edits and exits.

```sh
aider --model openai/zai/glm-5.3-flash \
  --yes-always \
  --message "Add type hints to utils.py" utils.py
```

| Flag | Does |
| --- | --- |
| `--message` | Runs one instruction, then exits. |
| `--yes-always` | Answers yes to every confirmation. |

- [Own key](https://minirouter.sh/dashboard/keys): Give scripts and CI their own key.
- [Spend cap](https://minirouter.sh/docs/rate-limits): Daily or monthly cap on that key.

## Recommended models

| Model | Why |
| --- | --- |
| [`zai/glm-5.3-flash`](https://minirouter.sh/models/zai/glm-5.3-flash) | Best current balance of coding ability, agentic performance, context and cost. |
| [`openai/gpt-5.6-sol`](https://minirouter.sh/models/openai/gpt-5.6-sol) | Higher-intelligence option when task quality matters more than spend. |
| [`spacexai/grok-4.6`](https://minirouter.sh/models/spacexai/grok-4.6) | Strong agentic alternative with a 500K-token window. |
| [`google/gemini-3.8-flash`](https://minirouter.sh/models/google/gemini-3.8-flash) | Multimodal coding alternative with a 1M-token window. |

Browse every model in the [catalog](https://minirouter.sh/models).

## Troubleshooting

### Aider warns the model is unknown and guesses a context window

Expected for custom endpoints — Aider's local metadata does not know our ids. The warning is cosmetic; requests still work.

### 404, HTML, or a parse error on every request

Almost always the base URL. Use https://api.minirouter.sh/v1 — the bare host without /v1 also works, but never append /chat/completions to the base URL field; the client adds that path itself.

Error: [400 `invalid_request`](https://minirouter.sh/docs/errors#invalid_request).

### 401 on every request

Wrong or rotated key. Keys start with mr-live-; after a rotation the old key keeps working for 24 hours, then dies.

Error: [401 `invalid_api_key`](https://minirouter.sh/docs/errors#invalid_api_key).

### 402 before any tokens arrive

Balance below the estimated cost of the request. Top up (from $0.50 with direct Solana payments) — and watch the x-minirouter-balance-usd header, the low-balance signal every response carries.

Error: [402 `insufficient_credits`](https://minirouter.sh/docs/errors#insufficient_credits).

Every error code, with its fix: [Errors](https://minirouter.sh/docs/errors).

## Next steps

- [Presets](https://minirouter.sh/docs/presets): Save a model and its settings under one name.
- [Guardrails](https://minirouter.sh/docs/guardrails): Budgets and model lists per key.
- [Auto router](https://minirouter.sh/docs/auto-router): Let MiniRouter pick the model.
