Skip to content

fallen-blossom/MaiBot-Anthropic-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MaiBot Anthropic API协议

为 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 的服务均可使用

Features | 功能

  • 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 统计

Installation | 安装

Option 1: Auto-install (Recommended) | 方式一:自动安装(推荐)

Navigate to the downloaded/cloned directory: | 先进入下载或 clone 的目录:

# e.g. / 例如
cd Desktop/MaiBot-Anthropic-Client
# then / 然后:
pip install anthropic
python install.py

Use python install.py --restore to rollback. | python install.py --restore 可恢复

Option 2: Manual | 方式二:手动

  1. Copy anthropic_client.py to | 复制到 MaiBot/src/llm_models/model_client/
  2. Edit | 编辑 __init__.py, add to _CLIENT_MODULE_BY_TYPE:
"anthropic": ".anthropic_client",
  1. pip install anthropic

Configuration | 配置

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"

Thinking/reasoning

extra_params = { thinking = { type = "enabled", budget_tokens = 1024 } }

Supported Providers | 支持的 Provider

Any Anthropic Messages API endpoint. | 任何实现 Anthropic Messages API 的服务

Type / 类型 base_url
Anthropic Official / 官方 https://api.anthropic.com
Third-party / 第三方兼容 https://your-api-endpoint.com

Unsupported APIs | 不支持的 API

  • Embedding (not available in Anthropic protocol) | Anthropic 协议无此端点
  • Audio Transcription / 音频转录

Compatibility | 兼容性

  • MaiBot >= 8.12.0 · Python >= 3.10 · anthropic >= 0.39.0

After Updating MaiBot | 更新 MaiBot 后

Re-run | 重新运行 python install.py.

License | 许可

MIT

About

为MaiBot 添加Anthropic API协议 | 支持 Claude / Qwen / DeepSeek-V4 等 Anthropic 兼容模型

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages