AnthropicLLM
Claude Sonnet 5 API
anthropic/claude-sonnet-5Anthropic's Claude Sonnet 5 on the OpenAI-compatible chat completions API, with a 1,000,000 token context, vision, tools and reasoning.
- 1M context
- 工具
- 视觉
- 推理
在 Playground 中运行 Claude Sonnet 5
Send a chat request with your account and see the exact token charge. Code needs an API key.
参数
请求预览
{"model": "anthropic/claude-sonnet-5","messages": [],"stream": true,"max_tokens": 1024}网页 Playground 使用你的登录会话发送此请求体。在代码中请使用 API Key 发送相同内容。
结果
发送一条消息,用你的账号运行 Claude Sonnet 5。
收到回复后,这里会显示用量和扣费。
Claude Sonnet 5 价格
美元 / 百万 token。按每次请求的提示词长度选择档位。
- Reserve请求被接受时,Hermes 会按估算的提示词长度加上 max_tokens(未设置时为 8,192)预留额度。设置 max_tokens 可以减少预留。
- Settle响应结束后,按模型返回的实际用量结算:提示词 token 按输入价、命中缓存的 token 按缓存读取价、输出 token 按输出价,预留的剩余部分立即释放。
- Failures模型拒绝请求时不收费。流式输出在已生成内容后中断时,会按已生成文本估算并扣费。
Claude Sonnet 5 能做什么
Anthropic’s Claude Sonnet 5 model page describes this model as a previous-generation Sonnet with a 1M-token context and adaptive thinking. Its native Claude API features are not automatically equivalent to options supported by the Hermes OpenAI-compatible route.
Claude Sonnet 5 is called with the OpenAI chat completions format: send anthropic/claude-sonnet-5 as the model to the Hermes base URL with your API key. The catalog lists a context window of 1,000,000 tokens and support for tools, vision and reasoning; JSON schema output is not listed for this model.
Billing is per token from prepaid credits, with a separate cache-read rate for cached prompt tokens.
使用场景
Coding and review
Long files and diffs fit in the 1,000,000 token context.
Tool-using agents
Function tools pass through unchanged.
Reading images
Send screenshots or scans as image_url parts.
用代码调用 Claude Sonnet 5
任意 OpenAI SDK 都可用:设置 base URL 和你的 Hermes Key。
- 1
创建 API Key
In the dashboard, with the chat:create scope. API 密钥 - 2
Point your SDK at Hermes
Base URLhttps://api.hermes-ai.net/api/v1 - 3
发送对话补全请求
POST /chat/completionswithanthropic/claude-sonnet-5
代码示例
Set HERMES_API_KEY in your environment.
export HERMES_API_KEY=your_api_keycurl https://api.hermes-ai.net/api/v1/chat/completions \
-H "Authorization: Bearer $HERMES_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-5",
"messages": [{"role": "user", "content": "Say hello in one sentence."}],
"max_tokens": 200
}'请求
POST https://api.hermes-ai.net/api/v1/chat/completions 带 chat:create 权限的 API Key,或已登录会话。
| 字段 | 类型 | 说明 |
|---|---|---|
| model | string | anthropic/claude-sonnet-5 |
| messages | array | OpenAI 对话消息:system、user、assistant、tool 角色;text 和 image_url 内容块。 |
| stream | boolean | SSE 流式输出,最后一个事件包含 usage。 |
| max_tokens | integer | 输出上限,同时决定预留额度。 |
| tools / tool_choice | array / object | 仅支持 function 工具。 |
| response_format | object | 模型支持时可用 JSON 模式和 JSON schema。 |
| temperature, top_p, stop, seed, reasoning_effort | 原样透传。 |
响应
| 字段 | 说明 |
|---|---|
| choices[].message / delta | OpenAI chat completion 结构。 |
| usage | 模型返回的 prompt_tokens、completion_tokens 和 prompt_tokens_details.cached_tokens。 |
| hermes.charged_micros | 精确扣费(微美元,JSON 响应)。流式请求可在 GET /api/v1/chat/requests 查看。 |
| x-hermes-request | 请求 id 响应头,账单流水中使用同一 id。 |
| error.code | 文档中的 Hermes 错误码;请按错误码而非消息文本分支。 |
Claude Sonnet 5 API 常见问题
Answers built from the model's catalog entry and the Hermes AI API contract.
Do I need the Anthropic SDK?
No. Hermes AI API serves Claude Sonnet 5 through the OpenAI-compatible endpoint, so the OpenAI SDK with the Hermes base URL works.
Does Claude Sonnet 5 support structured outputs?
The catalog does not list JSON schema output for this model. Ask for JSON in the prompt and validate it in your code.
What is the Claude Sonnet 5 API on Hermes AI?
Claude Sonnet 5 by Anthropic is served through the OpenAI-compatible chat completions endpoint, https://api.hermes-ai.net/api/v1/chat/completions, with the model ID anthropic/claude-sonnet-5.
What is the context window of Claude Sonnet 5?
1,000,000 tokens, shared by the prompt and the output.
Does Claude Sonnet 5 support vision, tools and JSON output?
Supported: 工具, 视觉 和 推理. Not supported: JSON 和 音频. Streaming works with stream: true.
How is Claude Sonnet 5 billed?
Per token, from prepaid credits. When a request is accepted, credits are reserved for the estimated prompt plus max_tokens of output (8,192 when you set none); when it finishes, the exact charge is taken from the usage the model reports and the rest is released. A rejected request is not charged. Rates are in the pricing table.
Can I use the OpenAI SDK with Claude Sonnet 5?
Yes. Set the base URL to https://api.hermes-ai.net/api/v1 and use your Hermes API key; send anthropic/claude-sonnet-5 as the model. Chat completions, streaming, tools and JSON output work unchanged.
What happens when I hit a rate limit?
Too many requests per minute return 429 RATE_LIMITED and too many in flight return 429 CONCURRENCY_LIMITED. If the model provider rate limits, you get 429 UPSTREAM_RATE_LIMITED and nothing is charged. Retry with backoff.
How do I get an API key for Claude Sonnet 5?
Create one under API 密钥 in the dashboard with the chat:create scope, then add credits on the Billing page.