API 接口大全与统一鉴权
Hydite Vtslx AO 提供 OpenAI 兼容协议,一份 API Key 通吃所有模型与供应商
Hydite Vtslx AO 对外暴露一套完全兼容 OpenAI 规范的 HTTP 接口。也就是说,你只需把 base_url 指向 Hydite,把 api_key 换成 Hydite 颁发的虚拟密钥,就能用任意 OpenAI SDK 调用 Anthropic、Google、DeepSeek、通义、智谱、Moonshot、xAI、Mistral 等数十家供应商的模型 —— 代码零改动。
| 部署方式 | Base URL |
|---|
| 共享边缘节点(默认) | https://api.hydite.com/v1 |
| 企业独享实例 | https://<your-tenant>.hydite.com/v1 |
| 私有化部署 | 由你自己的域名提供 |
所有路径同时支持带 /v1 前缀和不带前缀两种形式(/v1/chat/completions 等价于 /chat/completions),与 OpenAI 行为完全一致。
Hydite Vtslx AO 采用 Bearer Token 鉴权,所有业务接口都需要在请求头携带:
1
Authorization: Bearer sk-hydite-xxxxxxxxxxxxxxxxxxxxxxxx
虚拟密钥(Virtual Key)由后台或 /key/generate 接口签发,具备以下能力:
- 多供应商透传:一把 Key 即可调用平台支持的全部模型,无需对每家供应商单独申请。
- 额度与速率控制:可在 Key 级别配置 RPM / TPM / 预算上限。
- 可见模型白名单:可限定某把 Key 只能访问指定的模型分组(交由 API Key Groups 统一管理)。
- 过期与轮换:支持
duration、expires、即时 revoke。
- 审计追踪:每一次调用都会写入用量日志,可按 Key、用户、团队多维度归因。
兼容写法:以 sk- 开头的 Key 直接放在 Authorization: Bearer 中即可,也兼容 api-key、x-api-key 头部(用于对接部分老 SDK)。
所有错误均使用 OpenAI 风格的 JSON 结构:
1
{
2
"error": {
3
"message": "Invalid API key provided",
4
"type": "authentication_error",
5
"code": "invalid_api_key",
6
"param": null
7
}
8
}
常见状态码:401 鉴权失败、403 权限不足、404 模型/资源不存在、429 触发限流、5xx 上游或网关异常(自动按策略重试 / 兜底)。
OpenAI 最核心的对话接口,支持 streaming、function/tool calling、JSON mode、vision、reasoning 等全部能力。
| Method | Path |
|---|
| POST | /v1/chat/completions |
| POST | /v1/engines/{model}/chat/completions |
| POST | /v1/openai/deployments/{model}/chat/completions (Azure 兼容) |
1
curl https://api.hydite.com/v1/chat/completions \
2
-H "Authorization: Bearer $HYDITE_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '{
5
"model": "claude-sonnet-4-5",
6
"messages": [{"role": "user", "content": "你好"}],
7
"stream": true
8
}'
关键参数:model、messages、stream、temperature、top_p、max_tokens、tools、tool_choice、response_format、reasoning_effort、thinking、stream_options。
Text Completions(Legacy)#
| Method | Path |
|---|
| POST | /v1/completions |
| POST | /v1/engines/{model}/completions |
兼容 OpenAI 新一代 Responses API,支持有状态对话、工具调用与多模态输出。
| Method | Path |
|---|
| POST | /v1/responses |
| GET | /v1/responses/{response_id} |
| DELETE | /v1/responses/{response_id} |
| GET | /v1/responses/{response_id}/input_items |
| Method | Path |
|---|
| POST | /v1/embeddings |
| POST | /v1/engines/{model}/embeddings |
1
curl https://api.hydite.com/v1/embeddings \
2
-H "Authorization: Bearer $HYDITE_API_KEY" \
3
-d '{"model":"text-embedding-3-large","input":"hydite"}'
| Method | Path |
|---|
| POST | /v1/moderations |
| Method | Path |
|---|
| POST | /v1/rerank |
| POST | /rerank |
| Method | Path | 说明 |
|---|
| POST | /v1/images/generations | 文生图 |
| POST | /v1/images/edits | 图像编辑 |
| POST | /v1/images/variations | 图像变体 |
| Method | Path | 说明 |
|---|
| POST | /v1/audio/speech | 文本转语音(TTS) |
| POST | /v1/audio/transcriptions | 语音转文字(ASR) |
| POST | /v1/audio/translations | 语音翻译 |
| Method | Path |
|---|
| POST | /v1/files |
| GET | /v1/files |
| GET | /v1/files/{file_id} |
| GET | /v1/files/{file_id}/content |
| DELETE | /v1/files/{file_id} |
| Method | Path |
|---|
| POST | /v1/batches |
| GET | /v1/batches |
| GET | /v1/batches/{batch_id} |
| POST | /v1/batches/{batch_id}/cancel |
| Method | Path |
|---|
| POST | /v1/fine_tuning/jobs |
| GET | /v1/fine_tuning/jobs |
| GET | /v1/fine_tuning/jobs/{fine_tuning_job_id} |
| POST | /v1/fine_tuning/jobs/{fine_tuning_job_id}/cancel |
| GET | /v1/fine_tuning/jobs/{fine_tuning_job_id}/events |
| Method | Path |
|---|
| POST | /v1/containers |
| GET | /v1/containers |
| GET | /v1/containers/{container_id} |
| DELETE | /v1/containers/{container_id} |
完整对接 OpenAI Assistants v2 协议。
| Method | Path |
|---|
| POST / GET | /v1/assistants |
| GET / POST / DELETE | /v1/assistants/{assistant_id} |
| POST | /v1/threads |
| GET / POST / DELETE | /v1/threads/{thread_id} |
| GET / POST | /v1/threads/{thread_id}/messages |
| POST | /v1/threads/{thread_id}/runs |
| Method | Path |
|---|
| POST / GET | /v1/vector_stores |
| GET / POST / DELETE | /v1/vector_stores/{vector_store_id} |
| POST | /v1/vector_stores/{vector_store_id}/search |
| POST | /v1/vector_stores/{vector_store_id}/files |
六、MCP(Model Context Protocol)#
Hydite 内置 MCP Gateway,可将远程 MCP Server 通过统一鉴权暴露给上游 Agent。
| Method | Path | 说明 |
|---|
| GET | /tools/list | 列出工具 |
| POST | /tools/call | 调用工具 |
| GET | /mcp / /mcp/{server} | MCP HTTP 网关 |
| POST | /v1/mcp/oauth/authorize | MCP OAuth 授权 |
| POST | /v1/mcp/oauth/token | MCP OAuth 令牌 |
| Method | Path | 说明 |
|---|
| GET | /v1/models | 当前 Key 可见的模型列表(OpenAI 兼容) |
| GET | /v1/models/{model_id} | 单个模型详情 |
| GET | /v1/model/info | 含价格、上下文长度、能力标签的扩展信息 |
| GET | /group/info | API Key Group 信息(路由策略 / 配额 / 模型白名单) |
| GET | /model/metrics | 模型耗时 / 成功率指标 |
| GET | /utils/supported_openai_params | 指定模型支持的 OpenAI 参数 |
| POST | /utils/token_counter | 不调用模型仅计算 token 数 |
以下管理类接口需使用主账户 Key或具备 admin 权限的 Key。
| Method | Path |
|---|
| POST | /key/generate |
| POST | /key/update |
| POST | /key/delete |
| POST | /key/regenerate |
| POST | /key/block / /key/unblock |
| GET | /key/info |
| GET | /key/list |
| GET | /key/health |
| 资源 | 创建 | 更新 | 删除 | 查询 |
|---|
| User | POST /user/new | POST /user/update | POST /user/delete | GET /user/info · GET /user/list |
| Team | POST /team/new | POST /team/update | POST /team/delete | GET /team/info · GET /team/list |
| Organization | POST /organization/new | POST /organization/update | POST /organization/delete | GET /organization/info · GET /organization/list |
| Customer (End-User) | POST /customer/new | POST /customer/update | POST /customer/delete | GET /customer/info · GET /customer/list |
| Method | Path | 说明 |
|---|
| POST | /model/new | 上线一个模型路由 |
| POST | /model/update | 修改模型配置 |
| POST | /model/delete | 下线模型 |
| GET | /v1/model/info | 查询模型 |
| Method | Path | 说明 |
|---|
| GET | /spend/logs | 调用明细 |
| GET | /spend/tags | 按 tag 维度统计 |
| GET | /spend/users | 按用户统计 |
| GET | /global/spend | 全局总览 |
| GET | /global/spend/report | 时间区间报表 |
| GET | /global/activity | 活跃度指标 |
| Method | Path |
|---|
| POST | /guardrails/apply_guardrail |
| GET | /guardrails/list |
可在请求体里通过 guardrails: ["pii-redact", "moderation"] 在线挂载。
| Method | Path | 说明 |
|---|
| GET | /health | 路由健康度(含每个模型实例) |
| GET | /health/liveliness | 进程存活 |
| GET | /health/readiness | 就绪检查(含 DB / Redis) |
| GET | /health/services | 上游各供应商状态 |
| GET | /metrics | Prometheus 指标 |
| GET | /routes | 当前网关已注册的全部路由 |
所有请求/响应体严格遵循 OpenAI 官方 OpenAPI Schema,可直接复用 openai-python、openai-node、openai-go 等官方 SDK 的 TypedDict / Pydantic / TS 类型定义。Hydite 在此之上对部分供应商专属字段做了透传(如 Anthropic 的 thinking、Google 的 safety_settings),这些字段直接写入请求体即可,网关会自动转发到对应供应商。
如需机器可读的接口契约,可访问:
GET /openapi.json — 当前实例的完整 OpenAPI 3.1 规范
GET /docs — 交互式 Swagger UI(仅在开启 EXPOSE_DOCS 时可见)