HERMES + CLAUDE

在 Hermes Agent 中使用 Claude。

Anthropic Claude 提供 Opus 4.8 以获得最强能力(200K 上下文、扩展思考)、Sonnet 4.6 以获得均衡性能、Haiku 4.5 以获得速度。Hermes Agent 通过 custom:runapi 提供商以 Anthropic 官方每 token 费率的 50% 调用 Claude——使用你为聊天配置的相同密钥和 base_url。

一个 API 密钥 · OpenAI 兼容端点 · 每 token 计费 5 折
使用 RunAPI 通过 Hermes Agent 发送 Claude 聊天补全请求。

要求:
- 使用 Hermes Agent 中已配置的 custom:runapi 提供商
- 调用 RunAPI 聊天补全端点 https://runapi.ai/v1/chat/completions
- 将 model 设置为 "claude-opus-4.8"
- RUNAPI_API_KEY 环境变量提供授权
- 响应是同步的——assistant 消息直接在响应体中返回
- 如需流式传输,设置 "stream": true 以接收 server-sent events
curl -X POST https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-4.8",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain the difference between a mutex and a semaphore in three sentences."}
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "claude-opus-4.8",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A mutex is a locking mechanism that allows only one thread to access a resource at a time..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 87,
    "total_tokens": 111
  }
}
复制 curl 命令进行测试 claude
工作原理

三步在 Hermes Agent 中使用 Claude

1

Configure RunAPI

Set the RUNAPI_API_KEY environment variable. If you already added RunAPI as a custom:runapi provider in Hermes Agent, the same key and base_url work for Claude — switch the model parameter to claude-opus-4.8 in your Hermes config or use the /model command.

export RUNAPI_API_KEY=runapi_xxx
2

Call Claude

Send a POST request to /v1/chat/completions with model set to claude-opus-4.8. Include a messages array with at least one user message. Set max_tokens to control response length. Add "stream" true for token-by-token SSE output in your Hermes session.

POST /v1/chat/completions
3

Read the response

The endpoint returns the assistant message synchronously — no task polling needed. Hermes Agent displays the response inline. Token usage counts are included in the response for billing transparency. Streaming responses arrive as SSE events for real-time display.

usage.total_tokens: 111
参数

Claude API 参数(OpenAI 兼容)

参数 类型 说明
model string Required. claude-opus-4.8, claude-sonnet-4.6, claude-haiku-4.5, or any Claude variant listed in the RunAPI catalog.
messages array Required. Array of message objects with role (system, user, assistant) and content fields.
max_tokens integer Maximum number of tokens in the response. Defaults vary by model — set explicitly for predictable billing.
stream boolean When true, returns server-sent events with incremental token deltas instead of a single JSON response.
temperature float Sampling temperature between 0 and 1. Lower values produce more deterministic output.
top_p float Nucleus sampling cutoff. Alternative to temperature — use one or the other, not both.

Hermes Agent 上的 Claude 是什么?

Claude 是 Anthropic 的 LLM,Hermes Agent 通过 custom:runapi provider 以官方 Anthropic 单 token 价格的一半调用它。三个档位——Opus 4.8(200K 上下文、扩展思考)、Sonnet 4.6(平衡速度与质量)、Haiku 4.5(快速低成本)——全部通过同一个 provider 配置。只需修改 model 字段即可在各档位间按请求切换,无需重新配置。

Claude 使用场景

构建带工具调用和 MCP 的 AI agent

在 Hermes Agent 中使用 Claude 的函数调用和模型上下文协议支持,构建能读取文件、查询数据库并基于推理采取行动的多步骤自动化工作流。

代码生成与审查

将编程任务通过 Hermes Agent 路由给 Claude——Opus 4.8 用于复杂架构决策和多文件重构,Sonnet 4.6 用于日常 PR 审查和测试生成。

带提示词缓存的内容生成

使用提示词缓存大批量生成营销文案、文档或报告,在系统提示词和上下文跨多次请求保持不变时降低成本。

常见问题

Claude + Hermes Agent 常见问题

Hermes Agent 通用配置

尚未配置?请从 Hermes Agent 的 RunAPI 配置指南开始。

Hermes Agent 配置指南 →

Claude 模型目录

查看所有 Claude 版本、每 token 定价和上下文窗口详情。

Claude 模型 →

立即在 Hermes Agent 中试用 Claude。

免费获取 RunAPI 密钥,配置 custom:runapi 提供商,以 Anthropic 官方费率的 50% 开始使用 Claude。