跳到主要内容

Chat Completions

用于多轮回话、文本生成、摘要、信息抽取和结构化助手场景。

Endpoint

POST https://pinducloud.cc/v1/chat/completions

请求示例

curl https://pinducloud.cc/v1/chat/completions \
-H "Authorization: Bearer $PINDUCLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{
"role": "system",
"content": "You are a precise API documentation assistant."
},
{
"role": "user",
"content": "List three production API security practices."
}
],
"temperature": 0.3,
"max_tokens": 500
}'

响应示例

{
"id": "chatcmpl_abc123",
"object": "chat.completion",
"created": 1710000000,
"model": "gpt-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "1. Keep API keys on trusted servers.\n2. Apply request timeouts and retry limits.\n3. Log errors with sensitive data removed."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 38,
"completion_tokens": 42,
"total_tokens": 80
}
}

流式请求

curl https://pinducloud.cc/v1/chat/completions \
-H "Authorization: Bearer $PINDUCLOUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "Create a short launch checklist."
}
],
"stream": true
}'

参数

参数类型必填说明
modelstring模型 ID,例如 gpt-5.5
messagesarrayOpenAI 格式的回话消息
temperaturenumber采样温度
max_tokensnumber最大输出 token 数
streamboolean是否返回流式响应

接入建议

  • 默认低延迟场景可使用 gpt-5.5
  • Claude 系列模型请改用 /v1/messages,不要通过本接口调用。
  • 服务端应设置请求超时和最大重试次数。