词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
AIAgent 调用。每个内置提供商(OpenRouter、Anthropic、GMI、DeepSeek、Nvidia……)都以此类插件形式提供。第三方可通过在 $HERMES_HOME/plugins/model-providers/ 下放置一个目录来添加自己的提供商,无需对仓库做任何修改。providers/__init__.py._discover_providers() 在任何代码首次调用 get_provider_profile() 或 list_providers() 时懒加载执行。发现顺序:<repo>/plugins/model-providers/<name>/ — 随 Hermes 一同发布$HERMES_HOME/plugins/model-providers/<name>/ — 放入任意目录;后续会话无需重启即可生效<repo>/providers/<name>.py — 为树外可编辑安装提供向后兼容register_provider() 采用后写者优先策略。放入 $HERMES_HOME/plugins/model-providers/gmi/ 目录即可替换内置 GMI profile,无需修改仓库。plugins/model-providers/my-provider/
├── __init__.py # 在模块级别调用 register_provider(profile)
├── plugin.yaml # kind: model-provider + 元数据(可选但推荐)
└── README.md # 安装说明(可选)__init__.py。plugin.yaml 供 hermes plugins 用于自省,以及供通用 PluginManager 将插件路由到正确的加载器;若缺少该文件,通用加载器会回退到源码文本启发式检测。| 集成点 | 位置 | 获得的能力 |
|---|---|---|
| 凭据解析 | hermes_cli/auth.py | PROVIDER_REGISTRY["acme-inference"] 从 profile 填充 |
--provider CLI 标志 | hermes_cli/main.py | 接受 acme-inference |
hermes model 选择器 | hermes_cli/models.py | 出现在 CANONICAL_PROVIDERS 中,从 {base_url}/models 获取模型列表 |
hermes doctor | hermes_cli/doctor.py | 对 ACME_API_KEY 及 {base_url}/models 进行健康检查 |
hermes setup | hermes_cli/config.py | ACME_API_KEY 出现在 OPTIONAL_ENV_VARS 和设置向导中 |
| URL 反向映射 | agent/model_metadata.py | 主机名 → 提供商名称,用于自动检测 |
| 辅助模型 | agent/auxiliary_client.py | 使用 default_aux_model 进行压缩/摘要 |
| 运行时解析 | hermes_cli/runtime_provider.py | 返回正确的 base_url、api_key、api_mode |
| 传输层 | agent/transports/chat_completions.py | Profile 路径通过 prepare_messages / build_extra_body / build_api_kwargs_extras 生成 kwargs |
providers/base.py。最常用的字段:| 字段 | 类型 | 用途 |
|---|---|---|
name | str | 规范 ID——与 config.yaml 中的 model.provider 及 --provider 标志匹配 |
aliases | tuple[str, ...] | 由 get_provider_profile() 解析的别名(如 grok → xai) |
api_mode | str | chat_completions | codex_responses | anthropic_messages | bedrock_converse |
display_name | str | 在 hermes model 选择器中显示的人类可读标签 |
description | str | 选择器副标题 |
signup_url | str | 首次运行设置时显示("在此获取 API key") |
env_vars | tuple[str, ...] | 按优先级排列的 API key 环境变量;最后一个 *_BASE_URL 条目用作用户 base URL 覆盖 |
base_url | str | 默认推理端点 |
models_url | str | 显式目录 URL(回退到 {base_url}/models) |
auth_type | str | api_key | oauth_device_code | oauth_external | copilot | aws_sdk | external_process |
fallback_models | tuple[str, ...] | 实时目录获取失败时显示的精选列表 |
default_headers | dict[str, str] | 随每个请求发送(如 Copilot 的 Editor-Version) |
fixed_temperature | Any | None = 使用调用方的值;OMIT_TEMPERATURE 哨兵值 = 完全不发送 temperature(Kimi) |
default_max_tokens | int | None | 提供商级别的 max_tokens 上限(Nvidia:16384) |
default_aux_model | str | 用于辅助任务(压缩、视觉、摘要)的廉价模型 |
ProviderProfile:| 插件 | 参考原因 |
|---|---|
plugins/model-providers/openrouter/ | 带 provider preferences 的聚合器,公开模型目录 |
plugins/model-providers/gemini/ | thinking_config 转换(原生 + OpenAI 兼容嵌套形式) |
plugins/model-providers/kimi-coding/ | OMIT_TEMPERATURE、extra_body.thinking、顶层 reasoning_effort |
plugins/model-providers/qwen-oauth/ | 消息规范化、cache_control 注入、VL 高分辨率 |
plugins/model-providers/nous/ | 归因标签、"禁用时省略 reasoning" |
plugins/model-providers/custom/ | Ollama 的 num_ctx + think: false 特殊处理 |
plugins/model-providers/bedrock/ | api_mode="bedrock_converse",fetch_models 返回 None(无 REST 端点) |
gmi 指向私有测试端点进行测试。创建 ~/.hermes/plugins/model-providers/gmi/__init__.py:get_provider_profile("gmi").base_url 将返回测试 URL。无需打补丁,无需重新构建。由于用户插件在内置插件之后被发现,用户的 register_provider() 调用会胜出。config.yaml 中设置了 model.api_mode)opencode_model_api_mode)/anthropic 后缀 → anthropic_messages,api.openai.com → codex_responses,api.x.ai → codex_responses,Kimi 域名上的 /coding → chat_completionsapi_mode 作为 URL 检测无结果时的回退chat_completionsprofile.api_mode 设置为你的提供商默认使用的值——它作为提示使用。用户 URL 覆盖仍然优先。auth_type | 含义 | 使用者 |
|---|---|---|
api_key | 单个环境变量携带静态 API key | 大多数提供商 |
oauth_device_code | 设备码 OAuth 流程 | — |
oauth_external | 用户在其他地方登录,token 存入 auth.json | Anthropic OAuth、MiniMax OAuth、Gemini Cloud Code、Qwen Portal、Nous Portal |
copilot | GitHub Copilot token 刷新周期 | 仅 copilot 插件 |
aws_sdk | AWS SDK 凭据链(IAM role、profile、env) | 仅 bedrock 插件 |
external_process | 认证由 agent 启动的子进程处理 | 仅 copilot-acp 插件 |
auth_type 控制哪些代码路径将你的提供商视为"简单 api-key 提供商"——若不是 api_key,PluginManager 仍会记录 manifest,但 Hermes CLI 层面的自动化(doctor 检查、--provider 标志、设置向导委托)可能会跳过它。get_provider_profile() 或 list_providers() 触发。实际上这在启动早期就会发生(auth.py 模块加载时会主动扩展 PROVIDER_REGISTRY)。若需验证插件是否已加载,运行:auth_type="api_key" profile 会出现在 Provider Connectivity 部分,并附带 /models 探测结果。HERMES_HOME 指向临时目录,避免污染真实配置:PluginManager(即 hermes plugins 操作的对象)能看到模型提供商插件,但不会导入它们——providers/__init__.py 负责管理其生命周期。Manager 记录 manifest 用于自省,并按 kind: model-provider 分类。当你将一个未标记的用户插件放入 $HERMES_HOME/plugins/,而该插件恰好调用了带 ProviderProfile 的 register_provider,Manager 会通过源码文本启发式检测自动将其归类为 kind: model-provider——因此即使没有 plugin.yaml,插件仍能正确路由。pyproject.toml 中添加入口点:[project.entry-points."hermes.plugins"]
acme-inference = "acme_hermes_plugin:register"acme_hermes_plugin:register 是一个调用 register_provider(profile) 的函数。通用 PluginManager 在 discover_and_load() 期间会拾取入口点插件。对于 kind: model-provider 的 pip 插件,你仍需在 manifest 中声明 kind(或依赖源码文本启发式检测)。