Anthropic 模型支持
要使用 Anthropic 的模型,您需要通过以下方式提供 Anthropic API 密钥:
- 设置
ANTHROPIC_API_KEY
环境变量 - 或使用
--anthropic-api-key
命令行参数
首先安装 aider:
python -m pip install aider-install
aider-install
然后配置您的 API 密钥:
export ANTHROPIC_API_KEY=<密钥> # Mac/Linux
setx ANTHROPIC_API_KEY <密钥> # Windows,执行 setx 后需重启终端
开始在您的代码库中使用 aider 和 Anthropic:
# 切换到您的代码库目录
cd /到/您的/项目
# aider 默认使用 Claude 3.7 Sonnet 模型
aider
# 列出 Anthropic 提供的可用模型
aider --list-models anthropic/
Anthropic 的 API 调用频率限制非常严格。 您可以通过以下方式访问所有 Anthropic 模型:
- OpenRouter
- 或 Google Vertex AI 这些平台提供更宽松的调用限制。
您可以使用 aider --model <模型名称>
来指定其他 Anthropic 模型。
例如,如果想使用特定版本的 Opus 模型,可以执行:
aider --model claude-3-opus-20240229
思考令牌 (Thinking Tokens)
Aider 支持与 Sonnet 3.7 的新思考令牌功能协同工作,但默认情况下不会要求 Sonnet 使用思考令牌。
目前启用思考功能需要手动配置。您需要在 .aider.model.settings.yml
模型设置文件 中添加以下内容。通过调整 budget_tokens
值可以修改目标思考令牌数量。
- name: anthropic/claude-3-7-sonnet-20250219
edit_format: diff
weak_model_name: anthropic/claude-3-5-haiku-20241022
use_repo_map: true
examples_as_sys_msg: true
use_temperature: false
extra_params:
extra_headers:
anthropic-beta: prompt-caching-2024-07-31,pdfs-2024-09-25,output-128k-2025-02-19
max_tokens: 64000
thinking:
type: enabled
budget_tokens: 32000 # 可调整此数值
cache_control: true
editor_model_name: anthropic/claude-3-7-sonnet-20250219
editor_edit_format: editor-diff
更简化的支持方案即将推出。