跳转到主要内容
POST
/
v1
/
chat
/
completions
对话补全
curl --request POST \
  --url https://alltoken.aatest.online/v1/chat/completions \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ]
}
'
{
  "id": "<string>",
  "choices": [
    {}
  ],
  "usage": {}
}

用途

用于发送多轮对话请求,生成文本回复。

请求头

Authorization
string
默认值:"Bearer YOUR_API_KEY"
必填
Bearer 鉴权请求头,格式为 Bearer YOUR_API_KEY

请求体

model
string
默认值:"glm-4"
必填
模型名称,例如 gpt-4o-mini
messages
object[]
必填
对话消息数组,至少包含一条用户消息。
temperature
number
默认值:"0.7"
可选,控制生成随机性。
stream
boolean
默认值:"false"
可选,是否启用流式返回。
max_tokens
integer
默认值:"512"
可选,限制本次生成的最大输出 token 数。

示例请求体

{
  "model": "glm-4",
  "messages": [
    {
      "role": "user",
      "content": "你好,请介绍一下 AllTokens。"
    }
  ],
  "temperature": 0.7
}

响应

id
string
请求 ID。
choices
object[]
生成结果数组,内容通常位于 choices[0].message.content
usage
object
Token 使用统计。