接入协议
鼎惠API 通过统一网关聚合不同模型服务。不同客户端可能使用不同协议,配置时最容易出错的是 Base URL、路径和鉴权头。
基础地址
| 用途 | 地址 |
|---|---|
| 主站 | https://www.tophdd.cn |
| OpenAI 兼容 Base URL | https://www.tophdd.cn/v1 |
| Anthropic 兼容 Base URL | https://www.tophdd.cn 或按工具要求填写到 /v1 前 |
| Gemini 兼容 Base URL | https://www.tophdd.cn |
如果工具单独要求填写 Base URL 和路径,通常不要重复填写 /v1。例如工具内部会自动拼接 /v1/chat/completions 时,Base URL 填 https://www.tophdd.cn;如果工具只填写 OpenAI Compatible Endpoint,通常填 https://www.tophdd.cn/v1。
鉴权方式
| 协议 | Header |
|---|---|
| OpenAI Compatible | Authorization: Bearer sk-your-dinghui-key |
| Anthropic Messages | x-api-key: sk-your-dinghui-key |
| Anthropic Messages | anthropic-version: 2023-06-01 |
| Gemini Native | Authorization: Bearer sk-your-dinghui-key |
OpenAI Chat Completions
适用于多数聊天客户端和 OpenAI 兼容工具。
POST /v1/chat/completions
Authorization: Bearer sk-your-dinghui-key
Content-Type: application/json
{
"model": "your-model-id",
"messages": [
{"role": "user", "content": "你好"}
]
}
OpenAI Responses API
适用于支持 Responses API 的新工具或 Agent 客户端。
POST /v1/responses
Authorization: Bearer sk-your-dinghui-key
Content-Type: application/json
{
"model": "your-model-id",
"input": "请总结这段代码的作用"
}
Anthropic Messages
适用于 Claude Code 和 Anthropic 兼容客户端。
POST /v1/messages
x-api-key: sk-your-dinghui-key
anthropic-version: 2023-06-01
Content-Type: application/json
{
"model": "your-claude-model-id",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "帮我分析这个错误"}
]
}
Gemini Native
适用于 Gemini SDK 或兼容 Gemini 原生协议的工具。
POST /v1beta/models/{model}:generateContent
Authorization: Bearer sk-your-dinghui-key
Content-Type: application/json
{
"contents": [
{
"parts": [
{"text": "请解释这个概念"}
]
}
]
}
图片接口
图片生成通常使用独立接口或特定模型能力。请先查看:
常见填错方式
| 现象 | 可能原因 |
|---|---|
| 401 | Key 填错,或 Anthropic 协议使用了 Bearer Header |
| 404 | Base URL 多写或少写 /v1,模型 ID 不存在 |
| 405 | 请求方法错误,例如把 POST 写成 GET |
| 429 | 并发或频率过高,需要降低请求速度 |
| 5xx | 上游模型或通道异常,建议重试或切换模型 |