---
title: "Aider 中转配置：两个环境变量"
canonical: https://relayswitch.ai/zh/guides/aider
generated: 2026-11-12T04:32:51.239Z
source: https://api.relayswitch.io/v1/catalog
base_url: https://api.relayswitch.io/v1
---

配置教程 · 核对于 2026-10-28

# Aider 中转配置

两个环境变量加一个 --model 参数：Aider 把请求发到本站，一个密钥用模型页上任何编码模型。

## 配置步骤

1.  设置 `OPENAI_API_BASE` 为 `https://api.relayswitch.io/v1`，保留 `/v1`。
2.  设置 `OPENAI_API_KEY` 为完整密钥。
3.  启动时用 `--model openai/模型id`，例如 `openai/claude-sonnet-5-5`。`openai/` 前缀告诉 Aider 走 OpenAI 兼容接口，Claude 和其他模型的 id 也用这个前缀。
4.  Windows 用 `setx` 设置这两个变量，然后开一个新终端。
5.  想固定下来，就把同样的三项写进 `.aider.conf.yml`：`openai-api-base`、`openai-api-key`、`model`。`weak-model` 指定写提交信息用的小模型。
6.  Aider 提示不认识这个模型时照常可用：警告只说明它没有内置这个 id 的上下文和价格，计费按目录实时价。

bash

1`export OPENAI_API_BASE=https://api.relayswitch.io/v1`

2`export OPENAI_API_KEY=sk-relay-你的密钥`

3`aider --model openai/claude-sonnet-5-5`

4

5`# 或写进项目根目录的 .aider.conf.yml`

6`openai-api-base: https://api.relayswitch.io/v1`

7`openai-api-key: sk-relay-你的密钥`

8`model: openai/claude-sonnet-5-5`

9`weak-model: openai/claude-haiku-5-5`

资料来源：Aider 的 [OpenAI 兼容接口文档](https://aider.chat/docs/llms/openai-compat.html) 与 [配置文件文档](https://aider.chat/docs/config/aider_conf.html)（读取于 2026-10-28）。

## 推荐模型

id 照抄到模型字段。价格渲染时读取自目录；人民币为参考价，计费以美元为准。

| 模型 | 开发商 | 输入 / 百万 | 输出 / 百万 |
| --- | --- | --- | --- |
| [Claude Sonnet 5.5](https://relayswitch.ai/zh/models/claude-sonnet-5-5)claude-sonnet-5-5 | Anthropic | $1.20≈ ¥8.16 | $3.00≈ ¥20.41 |
| [Claude Opus 5.5](https://relayswitch.ai/zh/models/claude-opus-5-5)claude-opus-5-5 | Anthropic | $2.716≈ ¥18.48 | $9.70≈ ¥66.00 |
| [GPT-6.1 Sol](https://relayswitch.ai/zh/models/gpt-6.1-sol)gpt-6.1-sol | OpenAI | $0.582≈ ¥3.96 | $2.91≈ ¥19.80 |
| [DeepSeek V4 Pro 0813](https://relayswitch.ai/zh/models/deepseek-v4-pro-0813)deepseek-v4-pro-0813 | DeepSeek | $0.792≈ ¥5.39 | $1.188≈ ¥8.08 |
| [Gemini 3.1 Pro Preview](https://relayswitch.ai/zh/models/gemini-3.1-pro-preview)gemini-3.1-pro-preview | Google | $1.20≈ ¥8.16 | $7.20≈ ¥48.99 |
| [Kimi K2.7 Code](https://relayswitch.ai/zh/models/kimi-k2.7-code)kimi-k2.7-code | Moonshot AI | $0.426≈ ¥2.90 | $1.7936≈ ¥12.20 |

美元 / 百万 tokens，人民币参考价按 ECB 2026-11-11 汇率

## 一次会话多少钱

一次 40 轮的 Aider 任务：每轮发送 80,000 tokens 的缓存上下文、2,000 新输入 tokens，返回 1,500 输出 tokens。这个大小是假设；控制台的用量页显示每次请求的真实 tokens 和费用。

| 模型 | 一次会话 |
| --- | --- |
| DeepSeek V4 Pro 0813deepseek-v4-pro-0813 | $0.3346≈ ¥2.28 |
| GPT-6.1 Solgpt-6.1-sol | $0.4074≈ ¥2.77 |
| Kimi K2.7 Codekimi-k2.7-code | $0.4143≈ ¥2.82 |
| Claude Sonnet 5.5claude-sonnet-5-5 | $0.516≈ ¥3.51 |
| Gemini 3.1 Pro Previewgemini-3.1-pro-preview | $0.912≈ ¥6.21 |
| Claude Opus 5.5claude-opus-5-5 | $1.26≈ ¥8.61 |

按目录实时价计算；人民币参考价按 ECB 2026-11-11 汇率。

## 验证是否接通

先用 curl 列出密钥能调用的模型 id，再在工具里发第一条消息。

bash

1`curl https://api.relayswitch.io/v1/models \`

2 `-H "Authorization: Bearer sk-relay-你的密钥"`

再按工具发请求的方式发一条：

bash

1`curl -i https://api.relayswitch.io/v1/chat/completions \`

2 `-H "Authorization: Bearer sk-relay-你的密钥" \`

3 `-H "Content-Type: application/json" \`

4 `-d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "回复 ok"}]}'`

两条都通，剩下的问题就在工具的字段里。请求几秒内出现在控制台的用量页。

常见问题

## 常见问题

Aider 接入时最常见的五个问题。

打开控制台

一分钟内拿到密钥

[获取密钥](https://app.relayswitch.io/console?lang=zh)

或发邮件至 [hello@relayswitch.io](mailto:hello@relayswitch.io)

### 

### 

### 

### 

### 

相关页面

-   [全部配置教程](https://relayswitch.ai/zh/guides)
-   [文档](https://relayswitch.ai/zh/docs)
-   [充值](https://relayswitch.ai/zh/pay)
-   [每日真实模型检测](https://relayswitch.ai/zh/proof)
-   [模型与价格](https://relayswitch.ai/zh/models)
-   [English guide](https://relayswitch.io/guides/aider)

## 在 Aider 里用一个密钥调用全部模型

USDT 充值，按 token 预付，无订阅。Base URL https://api.relayswitch.io/v1。

[模型与价格](https://relayswitch.ai/zh/models)[获取密钥](https://app.relayswitch.io/console?lang=zh)

