> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rixapi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Aider

> 在终端中使用 AI 进行结对编程，自动完成代码编写、测试和 Git 提交，通过 OpenAI 兼容接口接入 ePhone AI。

[Aider](https://aider.chat/) 是一款终端 AI 结对编程工具，可直接在本地代码库中完成代码修改并自动生成 Git 提交。

## 安装

```bash theme={null}
pip install aider-chat
```

或使用 pipx（推荐，避免依赖冲突）：

```bash theme={null}
pipx install aider-chat
```

## 配置与启动

### 方式一：环境变量（推荐，永久生效）

> [accordion] Mac / Linux (zsh)
>
> ```zsh theme={null}
> echo 'export OPENAI_API_KEY="sk-your-api-key"' >> ~/.zshrc
> echo 'export OPENAI_API_BASE="https://api.ephone.ai/v1"' >> ~/.zshrc
> source ~/.zshrc
> ```

> [accordion] Mac / Linux (bash)
>
> ```bash theme={null}
> echo 'export OPENAI_API_KEY="sk-your-api-key"' >> ~/.bashrc
> echo 'export OPENAI_API_BASE="https://api.ephone.ai/v1"' >> ~/.bashrc
> source ~/.bashrc
> ```

> [accordion] Windows (PowerShell)
>
> ```powershell theme={null}
> [Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-your-api-key", "User")
> [Environment]::SetEnvironmentVariable("OPENAI_API_BASE", "https://api.ephone.ai/v1", "User")
> ```

设置环境变量后，进入项目目录启动：

```bash theme={null}
cd your-project
aider --model gpt-4o
```

### 方式二：命令行参数（单次使用）

```bash theme={null}
aider \
  --openai-api-key sk-your-api-key \
  --openai-api-base https://api.ephone.ai/v1 \
  --model gpt-4o
```

### 使用 Anthropic 模型

```bash theme={null}
# 设置环境变量
export ANTHROPIC_API_KEY="sk-your-api-key"
export ANTHROPIC_BASE_URL="https://api.ephone.ai/anthropic"

# 启动
aider --model claude-opus-4-5-20251101
```

### 使用 `.aider.conf.yml` 配置文件

在项目根目录创建 `.aider.conf.yml`，避免每次手动传参：

```yaml theme={null}
openai-api-key: sk-your-api-key
openai-api-base: https://api.ephone.ai/v1
model: gpt-4o
```

## 常用命令

启动后，在 Aider 交互界面中可使用以下命令：

| 命令 | 说明 |
| - | - |
| `/add <文件>` | 将文件加入当前编辑上下文 |
| `/drop <文件>` | 从上下文中移除文件 |
| `/diff` | 查看当前会话产生的所有代码变更 |
| `/undo` | 撤销最近一次 AI 做出的 Git 提交 |
| `/commit` | 提交当前变更 |
| `/model <模型名>` | 切换模型 |
| `/exit` | 退出 Aider |

## 推荐模型

| 场景 | 推荐模型 |
| - | - |
| 通用编程 | `gpt-4o` |
| 复杂重构 | `claude-opus-4-5-20251101` |
| 快速迭代 | `gpt-4o-mini` |

> [!NOTE]
>
> Aider 默认会将所有修改自动提交到 Git，建议在干净的 Git 状态下使用，方便通过 `/undo` 回滚。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.