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
}

参数说明

参数类型必填说明
modelstring模型 ID(如 deepseek-chatclaude-3-opus
messagesarray对话消息数组
max_tokensinteger最大生成 Token 数
temperaturenumber采样温度(0-2)
streamboolean启用 SSE 流式响应
top_pnumber核采样参数

响应示例

{
  "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 参数自动将请求路由到最优节点,内置负载均衡和自动故障转移。