OpenAI 协议
完全兼容 OpenAI /v1/chat/completions 端点。可使用任何 OpenAI SDK 或 HTTP 客户端。
端点
POST https://api.dsesnet.com/v1/chat/completions 请求示例
{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 100,
"temperature": 0.7,
"stream": false
} 参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID(如 deepseek-chat、claude-3-opus) |
messages | array | 是 | 对话消息数组 |
max_tokens | integer | 否 | 最大生成 Token 数 |
temperature | number | 否 | 采样温度(0-2) |
stream | boolean | 否 | 启用 SSE 流式响应 |
top_p | number | 否 | 核采样参数 |
响应示例
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "deepseek-chat",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
} 流式响应
设置 "stream": true 接收 Server-Sent Events (SSE):
curl -X POST https://api.dsesnet.com/v1/chat/completions \
-H "Authorization: Bearer gw-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"Hi"}],"stream":true}' 模型路由
网关根据 model 参数自动将请求路由到最优节点,内置负载均衡和自动故障转移。