> ## 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.

# Responses

> OpenAI Responses 兼容入口，推荐用于 Codex、OpenAI SDK 和新项目。

`/v1/responses` 是 Codex / OpenAI API 调用的主推荐入口，适合文本、多模态输入和工具调用。旧版客户端可以使用 `/v1/chat/completions`，但新接入优先选择 Responses。

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://code.heihuzi.ai/v1/responses \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gpt-5.5",
      "input": "写一个 TypeScript debounce 函数"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://code.heihuzi.ai/v1/responses",
      headers={
          "Authorization": "Bearer <token>",
          "Content-Type": "application/json",
      },
      json={
          "model": "gpt-5.5",
          "input": "写一个 TypeScript debounce 函数",
      },
  )

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://code.heihuzi.ai/v1/responses", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "gpt-5.5",
      input: "写一个 TypeScript debounce 函数"
    })
  });

  console.log(await response.json());
  ```
</RequestExample>

## Body

<ParamField body="model" type="string" required>
  模型 ID。推荐使用 `gpt-5.5`、`gpt-5.4`、`gpt-5.4-mini`、`gpt-5.3-codex`、`gpt-5.3-codex-spark`。
</ParamField>

<ParamField body="input" type="string | array" required>
  输入内容。可传字符串，也可传 OpenAI Responses 兼容的多模态 input 结构。
</ParamField>

<ParamField body="stream" type="boolean">
  是否启用流式响应。
</ParamField>

<ParamField body="tools" type="array">
  OpenAI Responses 兼容工具列表。需要图像生成时，可以声明 image generation 工具并使用 `gpt-image-2`。
</ParamField>

<ParamField body="temperature" type="number">
  采样温度。具体支持情况取决于当前模型和渠道。
</ParamField>

## 图像工具

Responses 可以通过工具调用触发图像生成。直接生成图片时，仍建议使用 `/v1/images/generations`；需要在一次对话或任务流里组合文本和图片能力时，再使用 Responses 工具模式。

## Response

返回 OpenAI Responses 兼容结构。具体输出字段会随请求模式、流式设置和上游模型变化。

## 与 Chat Completions 的关系

* Responses 是 Codex / OpenAI 新接入的首选入口。
* Chat Completions 只作为旧版 `messages` 客户端的兼容入口。
* 两个接口都走 OpenAI-compatible 能力，但请求体和响应结构不同。
