跳转到主要内容
创建对话补全
curl --request POST \
  --url https://xxx.wengaocloud.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "你是一个简洁的产品助手。"
    },
    {
      "role": "user",
      "content": "用三句话介绍这个平台。"
    }
  ]
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "choices": [
    {}
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "prompt_tokens_details": {}
  }
}

授权

Authorization
string
header
默认值:sk-your-api-key
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
model
string
必填
示例:

"gpt-4o-mini"

messages
object[]
必填
temperature
number
必填范围: 0 <= x <= 2
stream
boolean
默认值:false
tools
object[]

响应

对话补全响应。流式请求返回 text/event-stream 事件流。

id
string
object
string
示例:

"chat.completion"

choices
object[]
usage
object