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

# 创建模型响应（Responses 格式）

> 以 OpenAI Responses API 格式创建模型响应，支持多轮对话与工具调用

## 可填写的模型

| 模型 ID             | 说明                                    |
| ----------------- | ------------------------------------- |
| `gpt-5.4`         | GPT-5 系列旗舰，顶级推理 / 编码 / Agentic，1M 上下文 |
| `gpt-5.4-mini`    | 轻量均衡版，适合高频调用与兜底                       |
| `deepseek-v4-pro` | DeepSeek 高性价比推理模型                     |

完整列表见 [`GET /v1/models`](/zh/api-reference/models/list-models)。

## 多轮对话续接

通过 `previous_response_id` 字段传入上一轮响应的 `id`，
即可在无需重复发送完整上下文的情况下延续对话。

## 推理控制

对支持推理的模型，通过 `reasoning.effort`（`low` / `medium` / `high`）
控制推理深度；通过 `reasoning.summary`（`auto` / `concise` / `detailed`）
控制推理摘要的详细程度。

## 上下文截断

`truncation` 设置为 `auto` 时，系统自动截断超出上下文窗口的旧内容；
设置为 `disabled` 时，若请求超出窗口将返回错误。


## OpenAPI

````yaml /openapi/chat.zh.yaml post /v1/responses
openapi: 3.1.0
info:
  title: InfinityBlue API — 聊天（Chat）
  version: 1.0.0
  summary: 统一的 AI 模型 API 网关 — 聊天接口
  description: |
    InfinityBlue 是一个统一的 AI 模型 API 网关，以 **OpenAI、Google Gemini、
    Anthropic Claude 等原生格式** 对外提供兼容接口，背后聚合了 OpenAI、
    Google、DeepSeek、字节豆包（Seedance）、快手可灵（Kling）等厂商的模型。

    你无需为每家厂商单独接入——只要把 base URL 指向 InfinityBlue，
    沿用你熟悉的官方 SDK 即可调用全部模型。

    ## 认证

    所有请求都需要在请求头中携带 API Key：

    ```
    Authorization: Bearer YOUR_API_KEY
    ```

    在 [控制台](https://api.getinfinityblue.com/console) 创建和管理你的 API Key。

    ## 接口格式约定

    | 路径前缀 | 兼容格式 |
    | --- | --- |
    | `/v1/*` | OpenAI（Chat Completions、Responses、Images 等） |
    | `/v1/messages` | Anthropic Claude Messages |
    | `/v1beta/models/*` | Google Gemini 原生 |

    ## 模型选择

    在 `model` 参数中传入任意模型 ID 即可。完整可用列表见
    [`GET /v1/models`](/zh/api-reference/models/list-models)
    或 [模型价格页](https://api.getinfinityblue.com/pricing)。
  contact:
    name: InfinityBlue
    url: https://getinfinityblue.com
servers:
  - url: https://api.getinfinityblue.com
    description: 生产环境
security:
  - bearerAuth: []
tags:
  - name: 聊天（Chat）
    description: |
      文本对话、视觉理解、工具调用、流式输出与推理模型，
      通过统一的对话接口提供。
paths:
  /v1/responses:
    post:
      tags:
        - 聊天（Chat）
      summary: 创建模型响应（Responses 格式）
      description: |
        使用 OpenAI Responses API 格式创建模型响应。
        支持多轮对话、工具调用、推理等功能。
        与 Chat Completions 相比，Responses API 提供了以 `previous_response_id`
        串联多轮的无状态续接机制，更适合 Agentic 场景。
      operationId: createResponse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
            examples:
              simple:
                summary: 基础文本对话
                value:
                  model: gpt-5.4
                  input: 用一句话介绍你自己。
              multi_turn:
                summary: 多轮对话续接
                value:
                  model: gpt-5.4
                  input: 继续解释上面提到的第二点。
                  previous_response_id: resp_abc123
              with_instructions:
                summary: 携带系统指令
                value:
                  model: gpt-5.4-mini
                  instructions: 你是一个专业的代码审查助手，回答请使用中文。
                  input: 帮我审查这段 Python 代码是否有内存泄漏风险。
              reasoning:
                summary: 推理模型
                value:
                  model: deepseek-v4-pro
                  input: 证明：无穷多个素数存在。
                  reasoning:
                    effort: high
                    summary: detailed
      responses:
        '200':
          description: 成功创建响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: API Key 无效或缺失
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ResponsesRequest:
      type: object
      required:
        - model
      description: OpenAI Responses API 请求体。
      properties:
        model:
          type: string
          description: 模型 ID，例如 `gpt-5.4`。完整列表见 `GET /v1/models`。
          examples:
            - gpt-5.4
        input:
          description: |
            输入内容，可以是纯文本字符串，或包含多条消息的数组。
            若省略，须通过 `previous_response_id` 续接上一轮对话。
          oneOf:
            - type: string
            - type: array
              description: 消息数组，格式与 Chat Completions 的 `messages` 相同。
              items:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - system
                      - user
                      - assistant
                      - tool
                    description: 消息角色。
                  content:
                    description: 消息内容，字符串或多模态内容数组。
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          type: object
        instructions:
          type: string
          description: 系统级指令，等同于 Chat Completions 中的 `system` 消息。
        max_output_tokens:
          type: integer
          description: 模型在本次响应中可生成的最大 token 数（含推理 token）。
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: 采样温度，取值 0–2，控制输出的随机性。
        top_p:
          type: number
          minimum: 0
          maximum: 1
          description: 核采样概率阈值，与 `temperature` 二选一调整。
        stream:
          type: boolean
          default: false
          description: 是否以 Server-Sent Events 流式返回。
        tools:
          type: array
          description: 模型可调用的工具列表。
          items:
            type: object
        tool_choice:
          description: |
            工具调用策略。字符串 `auto`/`none`/`required`，
            或指定具体工具的对象。
          oneOf:
            - type: string
              enum:
                - auto
                - none
                - required
            - type: object
        reasoning:
          type: object
          description: 推理配置，仅对支持推理的模型生效。
          properties:
            effort:
              type: string
              enum:
                - low
                - medium
                - high
              description: 推理深度。
            summary:
              type: string
              enum:
                - auto
                - concise
                - detailed
              description: 推理摘要详细程度。
        previous_response_id:
          type: string
          description: |
            上一轮响应的 `id`。填入后可在不重复发送历史上下文的情况下
            延续多轮对话。
        truncation:
          type: string
          enum:
            - auto
            - disabled
          description: |
            上下文截断策略。`auto` 自动截断超出窗口的旧内容；
            `disabled` 超出时返回错误。
    ResponsesResponse:
      type: object
      description: OpenAI Responses API 响应体。
      properties:
        id:
          type: string
          description: 本次响应的唯一标识，可用作下一轮的 `previous_response_id`。
        object:
          type: string
          description: 对象类型，值为 `response`。
          examples:
            - response
        created_at:
          type: integer
          description: 创建时间的 Unix 时间戳（秒）。
        status:
          type: string
          enum:
            - completed
            - failed
            - in_progress
            - incomplete
          description: 响应状态。
        model:
          type: string
          description: 实际处理请求的模型。
        output:
          type: array
          description: 模型生成的输出块列表。
          items:
            type: object
            properties:
              type:
                type: string
                description: 输出块类型，例如 `message`。
              id:
                type: string
                description: 输出块 ID。
              status:
                type: string
                description: 输出块状态。
              role:
                type: string
                description: 角色，通常为 `assistant`。
              content:
                type: array
                description: 内容片段列表。
                items:
                  type: object
                  properties:
                    type:
                      type: string
                      description: 内容类型，例如 `output_text`。
                    text:
                      type: string
                      description: 文本内容。
        usage:
          $ref: '#/components/schemas/Usage'
    ErrorResponse:
      type: object
      description: 标准错误响应。
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: 错误信息。
              examples:
                - 无效的时长。支持的范围为 4 到 15 秒。
            type:
              type: string
              description: 错误类型。
              examples:
                - invalid_request_error
            param:
              type:
                - string
                - 'null'
              description: 相关参数。
              examples:
                - seconds
            code:
              type:
                - string
                - 'null'
              description: 错误代码。
              examples:
                - invalid_duration
    Usage:
      type: object
      description: 本次请求的 token 用量统计。
      properties:
        prompt_tokens:
          type: integer
          description: 提示词消耗的 token 数。
        completion_tokens:
          type: integer
          description: 补全消耗的 token 数。
        total_tokens:
          type: integer
          description: 总消耗 token 数。
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              description: 命中缓存的 token 数。
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            image_tokens:
              type: integer
        completion_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            reasoning_tokens:
              type: integer
              description: 推理消耗的 token 数。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        使用 Bearer Token 认证，格式：`Authorization: Bearer sk-xxxxxx`。
        在 [控制台](https://api.getinfinityblue.com/console) 获取 API Key。

````