> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heihuzi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Completions

> gpt-5.5 的 messages 请求、普通响应与流式响应。

`POST https://code.heihuzi.ai/v1/chat/completions` 的非流式和流式均已使用 `gpt-5.5` 验证。

<RequestExample>
  ```bash theme={null}
  curl --fail-with-body --silent --show-error --max-time 600 \
    --request POST \
    --url https://code.heihuzi.ai/v1/chat/completions \
    --header "Authorization: Bearer $HEIHUZI_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "gpt-5.5",
    "messages": [
      {
        "role": "user",
        "content": "Reply with exactly API_OK."
      }
    ]
  }' \
    --output chat.json
  ```
</RequestExample>

## 请求参数

<ParamField body="model" type="string" required>本页验证 `gpt-5.5`；省略返回 400。</ParamField>
<ParamField body="messages" type="object[]" required>示例传入一条 `role: "user"`、`content` 为字符串的消息；省略返回 400。</ParamField>
<ParamField body="stream" type="boolean">已验证省略时返回 JSON，设为 `true` 返回 SSE。</ParamField>
<ParamField body="temperature" type="number">流式用例使用 `0.2`。</ParamField>
<ParamField body="max_tokens" type="integer">流式用例使用 `256` 作为请求输出长度上限。</ParamField>

## 返回值

非流式从 `choices[].message.content` 读取文本。本次响应节选如下。

```json theme={null}
{
  "object": "chat.completion",
  "model": "gpt-5.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "API_OK"
      },
      "finish_reason": "stop"
    }
  ]
}
```

流式用例的完整请求体为：

```json theme={null}
{
  "model": "gpt-5.5",
  "messages": [
    {
      "role": "user",
      "content": "Reply with exactly API_OK."
    }
  ],
  "stream": true,
  "temperature": 0.2,
  "max_tokens": 256
}
```

实测响应为 `text/event-stream`，文本分片位于 `choices[].delta.content`，结束标记为 `data: [DONE]`。使用 [Responses](/cn/api-reference/responses) 的客户端应按该接口的独立结构读取。
