Files
nexus/knowledgebase/Hermes Agent接入阿里云百炼Token Plan.md
2026-09-11 06:20:11 +08:00

8.0 KiB
Raw Blame History

title, source, author, published, created, description, tags
title source author published created description tags
更多工具 https://help.aliyun.com/zh/model-studio/hermes-agent?spm=a2c4g.11186623.help-menu-2400256.d_0_4_1.525b1fe88PXBk7 2026-09-03 除已列出的工具外,阿里云百炼还支持接入兼容 OpenAI / Anthropic API 协议且支持自定义服务端点的第三方编程工具。可通过按量计费、Coding Plan、Token Plan 个人版或 Token Plan 团队版接入。
clippings

#hermes #agents #阿里云百炼 #token-plan #coding-plan

Hermes Agent 是一款终端 AI 编程工具,可以通过按量计费、Coding Plan、Token Plan 个人版或 Token Plan 团队版接入阿里云百炼。

安装 Hermes Agent

  1. 在终端中执行以下命令安装 Hermes Agent,安装脚本会自动安装 Python、Git 等依赖。
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash

说明

Windows 不支持原生安装,请先安装 WSL2 ,在 WSL2 中运行以上命令。

  1. 安装完成后,重新加载终端环境。
source ~/.bashrc    # 如果使用 zsh,改为 source ~/.zshrc
  1. 运行以下命令验证安装。若有版本号输出,则表示安装成功。
hermes --version

配置环境变量

将 OPENAI_API_KEY 环境变量设置为 Token Plan 个人版专属 API Key。

  1. 在终端中执行以下命令,查看默认 Shell 类型。
echo $SHELL
  1. 根据 Shell 类型设置环境变量:
    # 将 YOUR_API_KEY 替换为 Token Plan 个人版 API Key
    echo 'export OPENAI_API_KEY="YOUR_API_KEY"' >> ~/.zshrc
    
    # 将 YOUR_API_KEY 替换为 Token Plan 个人版 API Key
    echo 'export OPENAI_API_KEY="YOUR_API_KEY"' >> ~/.bash_profile
    
  2. 执行以下命令使环境变量生效。
    source ~/.zshrc
    
    source ~/.bash_profile
    

配置接入凭证

通过 hermes config set 命令配置接入参数,根据所选方案填入对应的 Base URL 和 API Key:

  • Token Plan 个人版 :个人订阅,按 token 消耗抵扣 Credits。
  • Token Plan 团队版 :按坐席订阅,按 token 消耗抵扣 Credits。
  • Coding Plan :固定月费订阅,按模型调用次数计量。
  • 按量计费 :按实际调用量后付费。

说明

本文示例均使用 Anthropic 兼容协议 :Base URL 以 /apps/anthropic 结尾,并将 api_mode 设为 anthropic_messages 。Hermes Agent 同样支持 OpenAI 兼容协议 :将 Base URL 结尾的 /apps/anthropic 替换为 /compatible-mode/v1 ,并删除 api_mode 配置项即可。例如按量计费(华北2·北京)的 OpenAI 兼容 Base URL 为 https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 。

除命令行版外,Hermes Agent 还提供桌面版(Hermes Desktop)。可从 Hermes 官网 下载安装包,或在命令行版安装完成后运行 hermes desktop 启动。桌面版与命令行版共用同一份 ~/.hermes/config.yaml 配置文件,接入参数与本文一致;在桌面版中以自定义端点(Custom Endpoint)方式接入时,请使用上述 OpenAI 兼容 Base URL。

Token Plan 个人版

将 YOUR_API_KEY 替换为 Token Plan 个人版专属 API Key 。可用模型请参考 Token Plan 个人版 支持的模型 。

hermes config set model.provider custom
hermes config set model.base_url https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
hermes config set model.api_mode anthropic_messages
hermes config set model.api_key YOUR_API_KEY
hermes config set model.default qwen3.8-max

以上命令将配置写入 ~/.hermes/config.yaml 。也可以直接编辑该文件,写入以下内容:

config.yaml 配置示例

model:
  default: qwen3.8-max
  provider: custom
  base_url: https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
  api_mode: anthropic_messages
  api_key: YOUR_API_KEY

Token Plan 团队版

将 YOUR_API_KEY 替换为 Token Plan 团队版专属 API Key 。可用模型请参考 Token Plan 团队版 支持的模型 。

hermes config set model.provider custom
hermes config set model.base_url https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
hermes config set model.api_mode anthropic_messages
hermes config set model.api_key YOUR_API_KEY
hermes config set model.default qwen3.8-max

以上命令将配置写入 ~/.hermes/config.yaml 。也可以直接编辑该文件,写入以下内容:

config.yaml 配置示例

model:
  default: qwen3.8-max
  provider: custom
  base_url: https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
  api_mode: anthropic_messages
  api_key: YOUR_API_KEY

Coding Plan

将 YOUR_API_KEY 替换为 Coding Plan 专属 API Key 。可用模型请参考 Coding Plan 支持的模型 。

hermes config set model.provider custom
hermes config set model.base_url https://coding.dashscope.aliyuncs.com/apps/anthropic
hermes config set model.api_mode anthropic_messages
hermes config set model.api_key YOUR_API_KEY
hermes config set model.default qwen3.7-plus

以上命令将配置写入 ~/.hermes/config.yaml 。也可以直接编辑该文件,写入以下内容:

config.yaml 配置示例

model:
  default: qwen3.7-plus
  provider: custom
  base_url: https://coding.dashscope.aliyuncs.com/apps/anthropic
  api_mode: anthropic_messages
  api_key: YOUR_API_KEY

按量计费

将 YOUR_API_KEY 替换为 阿里云百炼 API Key 。可用模型请参考 Anthropic 兼容 API 。

base_url 按地域设置,API Key 需与所选地域对应,并将 WorkspaceId 替换为真实的 获取Workspace ID :

  • 华北2(北京): https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic
  • 新加坡: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic
hermes config set model.provider alibaba
hermes config set model.base_url https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic
hermes config set model.api_mode anthropic_messages
hermes config set model.api_key YOUR_API_KEY
hermes config set model.default qwen3.7-max

以上命令将配置写入 ~/.hermes/config.yaml 。也可以直接编辑该文件,写入以下内容:

config.yaml 配置示例

model:
  default: qwen3.7-max
  provider: alibaba
  base_url: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/apps/anthropic
  api_mode: anthropic_messages
  api_key: YOUR_API_KEY

验证配置

配置完成后,执行以下命令发送一条测试消息:

hermes chat -q "你好"

如果返回正常的回复,则配置成功。如需切换模型,通过 -m 参数指定:

hermes chat -m qwen3.7-max

常见问题

错误码

配置过程中遇到报错,请参考对应计费方案的常见问题文档:

Codex接入阿里云百炼Token Plan配置方法