为 Hermes Agent 配置 Taotoken 作为自定义模型提供商
·
为 Hermes Agent 配置 Taotoken 作为自定义模型提供商
1. 准备工作
在开始配置前,请确保已满足以下条件:
- 拥有有效的 Taotoken API Key(可在 Taotoken 控制台创建)
- 已安装 Hermes Agent 框架并完成基础环境配置
- 了解目标模型 ID(可在 Taotoken 模型广场查看)
2. 通过 CLI 快速配置
推荐使用 @taotoken/taotoken CLI 工具完成一键配置:
npm install -g @taotoken/taotoken
taotoken hermes --key YOUR_API_KEY --model YOUR_MODEL_ID
该命令会自动:
- 将
base_url设置为https://taotoken.net/api/v1 - 将 API Key 写入
.env文件的OPENAI_API_KEY变量 - 设置默认模型为指定 ID
3. 手动配置步骤
如需手动配置,请按以下步骤操作:
3.1 设置环境变量
在项目根目录的 .env 文件中添加:
OPENAI_API_KEY=YOUR_API_KEY
OPENAI_BASE_URL=https://taotoken.net/api/v1
3.2 修改 Hermes 配置文件
在 hermes.config.js 中确保 provider 设置为 custom:
module.exports = {
providers: {
default: 'custom',
custom: {
baseUrl: process.env.OPENAI_BASE_URL,
apiKey: process.env.OPENAI_API_KEY
}
}
}
4. 验证配置
创建测试脚本 test.js:
const hermes = require('hermes-agent');
async function test() {
const response = await hermes.chat.completions.create({
model: 'YOUR_MODEL_ID',
messages: [{ role: 'user', content: 'Hello' }]
});
console.log(response.choices[0].message.content);
}
test();
运行后应能正常获取模型响应。
5. 注意事项
- 确保
base_url末尾包含/v1路径 - 使用 OpenAI 兼容的模型 ID 格式
- 密钥需妥善保管,不要提交到公开仓库
- 模型切换只需修改
hermes.config.js中的默认模型配置
如需进一步了解 Hermes Agent 与 Taotoken 的集成细节,可参考 Taotoken 官方文档。
更多推荐
所有评论(0)