Files
haiyushuke-website/content/models/claude.mdx
2026-06-16 14:34:09 +08:00

43 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Claude 接入
sidebarTitle: Claude
description: Anthropic Claude 系列模型接入说明
---
# Claude (Anthropic) 接入
Claude 模型可通过 **OpenAI 兼容接口** 或 **Anthropic Messages API** 接入(以控制台开通能力为准)。
## OpenAI 兼容方式(推荐迁移)
```bash
curl https://api.haiyushuke.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"messages": [{"role": "user", "content": "总结以下三点:安全、成本、延迟"}]
}'
```
将 `model` 替换为控制台提供的 Claude 模型 ID。
## 系统提示与多轮对话
与 OpenAI 相同,使用 `messages` 数组:
```json
{
"model": "claude-sonnet-4-20250514",
"messages": [
{ "role": "system", "content": "你是企业知识库助手,回答需简洁。" },
{ "role": "user", "content": "什么是 RAG" }
]
}
```
## 注意事项
- 部分 Claude 特性(如扩展思考、工具调用)需使用对应 API 形态,请参考控制台该模型的「能力标签」。
- 长上下文模型请留意单次请求的 `max_tokens` 与账单中的输入 token 统计。