Provider 配置
配置 Anthropic
官方 Anthropic API + Messages wire — Claude 系列驱动 Agent。
为什么选 Anthropic
Claude 系列在 长上下文、工具调用准确率、写作质感 三块是 Kition 内部测得最强的。我们走的是官方 Messages API(/v1/messages),wire 标识为 anthropic_messages。它跟 OpenAI Responses 不是一回事 — Kition Agent 内部有 adapter 帮你抹平,所以在 UI 上看不到差异。
Anthropic 对 prompt caching 的支持也是当前最成熟的:缓存命中能省 90% 的 input cost,长 system prompt 会自动加 cache_control 标记。
生成 API Key
- console.anthropic.com → Settings → API Keys
- Create Key,命名 "Kition Desktop",选择 Workspace
- 复制
sk-ant-api03-...字符串 - Workspace 级可以设支出上限,避免跑飞
Kition 里添加
Settings → Providers → Add → Anthropic。模板会自动设好 wire 与 anthropic-version header。
{
"name": "anthropic",
"baseURL": "https://api.anthropic.com",
"apiKey": "sk-ant-api03-...",
"wire": "anthropic_messages",
"defaultModel": "claude-sonnet-4-6",
"headers": {
"anthropic-version": "2023-06-01",
"anthropic-beta": "prompt-caching-2024-07-31"
}
}认证 header
Anthropic 用 x-api-key(不是 Bearer token),并要求 anthropic-version header — Kition 自动注入这两项。如果你看到 401 invalid x-api-key,多半是 key 复制带了空格或者粘到错误的字段里。
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role":"user","content":"ping"}]
}'模型选择
claude-sonnet-4-6— 默认日常档,写作 / 普通 agent 任务都跑这条claude-opus-4-7— 硬任务(深度推理、复杂重构、研究综合),价格高 5xclaude-haiku-4-5— 快速档,适合摘要、分类、轻量子 Agent- 所有模型上下文均为 200k,Pro 用户可启 1M context beta(需在 header 加
anthropic-beta: context-1m-2025-08-07)
常见错误
401 authentication_error— Key 错或带空格403 permission_error— Workspace 没开启对应模型 / 区域受限404 not_found_error— model 拼写错(注意是claude-sonnet-4-6不是claude-4.6-sonnet)429 rate_limit_error— 触发 RPM/ITPM/OTPM,Kition 会按retry-after退避529 overloaded_error— Anthropic 侧拥塞,自动重试 3 次后报错400 invalid_request_error— 多半是 messages 第一条不是 user,或 tool_use/tool_result 配对错
限速与计费
Anthropic 用三轴限速:RPM(每分钟请求)、ITPM(input tokens / min)、OTPM(output tokens / min)。Tier 1 大约是 50 RPM / 50k ITPM / 10k OTPM — 对单用户够用,但跑大批量索引时 ITPM 容易先撞。
强烈建议开 prompt caching:长 system prompt 走缓存后 input cost 降 90%,对 Agent 这种每轮都重发 system 的场景特别有用。Kition 默认开启,无需手动配置。