为 MaiBot 添加 Anthropic API协议支持 | Anthropic protocol client adapter for MaiBot
支持 Claude、Qwen、DeepSeek-V4 等所有 Anthropic 兼容模型。
Anthropic protocol client adapter for MaiBot | 为 MaiBot 添加 Anthropic 协议支持
Adds support for any API endpoint implementing the Anthropic Messages protocol. | 任何实现 Anthropic Messages API 的服务均可使用
- Full Anthropic Messages API (streaming + non-streaming) | 流式与非流式
- Tool calling | 工具调用
- Multimodal image input with auto format conversion (non-native → PNG) | 多模态图片自动转 PNG
- Thinking/reasoning extension | thinking 扩展
- Error snapshots | 错误快照
- KV Cache statistics | KV Cache 统计
Navigate to the downloaded/cloned directory: | 先进入下载或 clone 的目录:
# e.g. / 例如
cd Desktop/MaiBot-Anthropic-Client
# then / 然后:
pip install anthropic
python install.pyUse python install.py --restore to rollback. | python install.py --restore 可恢复
- Copy
anthropic_client.pyto | 复制到MaiBot/src/llm_models/model_client/ - Edit | 编辑
__init__.py, add to_CLIENT_MODULE_BY_TYPE:
"anthropic": ".anthropic_client",pip install anthropic
Add to | 添加到 MaiBot/config/model_config.toml:
[[model.providers]]
name = "MY_ANTHROPIC"
base_url = "https://your-api-endpoint.com"
api_key = "your-api-key"
client_type = "anthropic"
timeout = 60.0
[[model.models]]
name = "my-model"
model_identifier = "my-model-id"
provider = "MY_ANTHROPIC"extra_params = { thinking = { type = "enabled", budget_tokens = 1024 } }Any Anthropic Messages API endpoint. | 任何实现 Anthropic Messages API 的服务
| Type / 类型 | base_url |
|---|---|
| Anthropic Official / 官方 | https://api.anthropic.com |
| Third-party / 第三方兼容 | https://your-api-endpoint.com |
- Embedding (not available in Anthropic protocol) | Anthropic 协议无此端点
- Audio Transcription / 音频转录
- MaiBot >= 8.12.0 · Python >= 3.10 · anthropic >= 0.39.0
Re-run | 重新运行 python install.py.
MIT