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

# 创建聊天补全

> **正在开始新项目？** 建议使用 [Responses](https://developers.openai.com/api/reference/resources/responses)，以便使用 OpenAI 平台的最新功能。可对比 [Chat Completions 与 Responses](https://developers.openai.com/api/docs/guides/migrate-to-responses?api-mode=responses)。

---

为给定的聊天对话创建模型响应。详见 [文本生成](https://developers.openai.com/api/docs/guides/text)、[视觉](https://developers.openai.com/api/docs/guides/images-vision) 和 [音频](https://developers.openai.com/api/docs/guides/audio) 指南。

参数支持情况可能因生成响应所用的模型而异，较新的推理模型尤其如此。仅推理模型支持的参数会在下文注明。关于推理模型中不受支持参数的最新情况，[请参阅推理指南](https://developers.openai.com/api/docs/guides/reasoning)。

返回一个聊天补全对象；如果请求为流式，则返回一系列流式的聊天补全数据块对象。



## OpenAPI

````yaml /openapi/zh/openai-chat-completions.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: OpenAI Chat Completions
  version: v1
  description: >-
    用 OpenAI Chat Completions 协议调用 GPT、DeepSeek、Kimi、GLM、Grok
    等大模型：对话、流式输出、图片理解、函数调用和结构化输出。
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Chat Completions
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: 创建聊天补全
      description: >-
        **正在开始新项目？** 建议使用
        [Responses](https://developers.openai.com/api/reference/resources/responses)，以便使用
        OpenAI 平台的最新功能。可对比 [Chat Completions 与
        Responses](https://developers.openai.com/api/docs/guides/migrate-to-responses?api-mode=responses)。


        ---


        为给定的聊天对话创建模型响应。详见
        [文本生成](https://developers.openai.com/api/docs/guides/text)、[视觉](https://developers.openai.com/api/docs/guides/images-vision)
        和 [音频](https://developers.openai.com/api/docs/guides/audio) 指南。


        参数支持情况可能因生成响应所用的模型而异，较新的推理模型尤其如此。仅推理模型支持的参数会在下文注明。关于推理模型中不受支持参数的最新情况，[请参阅推理指南](https://developers.openai.com/api/docs/guides/reasoning)。


        返回一个聊天补全对象；如果请求为流式，则返回一系列流式的聊天补全数据块对象。
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletionRequest'
            examples:
              基础对话:
                summary: 基础对话
                description: 一条系统提示加一条用户消息。
                value:
                  model: gpt-6.2-sol
                  messages:
                    - role: system
                      content: 你是一个简洁、专业的助手。
                    - role: user
                      content: 用三句话介绍一下量子计算。
              流式输出:
                summary: 流式输出
                description: >-
                  `stream: true` 时以 SSE 逐段返回，最后一帧是 `data:
                  [DONE]`；`stream_options.include_usage` 让最后一个数据块带上用量。
                value:
                  model: gpt-6.2-sol
                  stream: true
                  stream_options:
                    include_usage: true
                  messages:
                    - role: user
                      content: 写一首关于秋天的四行诗。
              多轮对话:
                summary: 多轮对话
                description: 接口不保存会话，每次请求都要带上之前的消息。
                value:
                  model: kimi-k3.1-pro
                  messages:
                    - role: user
                      content: 帮我想一个咖啡店的名字。
                    - role: assistant
                      content: 「晨光咖啡」怎么样？
                    - role: user
                      content: 再给这个名字配一句标语。
              图片理解:
                summary: 图片理解
                description: 用 `image_url` 内容块传入图片地址或 Base64 Data URL。
                value:
                  model: gpt-6.1-terra
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 这张图片里有什么？
                        - type: image_url
                          image_url:
                            url: https://your-cdn.example.com/photo.jpg
              函数调用:
                summary: 函数调用
                description: '模型需要外部数据时返回 `tool_calls`；执行函数后用 `role: tool` 消息把结果传回。'
                value:
                  model: gpt-6.2-sol
                  messages:
                    - role: user
                      content: 杭州今天天气怎么样？
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: 查询指定城市的实时天气
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: 城市名，例如：杭州
                            unit:
                              type: string
                              enum:
                                - celsius
                                - fahrenheit
                          required:
                            - city
                  tool_choice: auto
              结构化输出:
                summary: 结构化输出
                description: 用 `response_format` 约束模型按 JSON Schema 输出。
                value:
                  model: gpt-6.2-sol
                  messages:
                    - role: user
                      content: 从这段话里提取联系人：我是星河科技的李雷，邮箱 lilei@example.com。
                  response_format:
                    type: json_schema
                    json_schema:
                      name: contact
                      strict: true
                      schema:
                        type: object
                        properties:
                          name:
                            type: string
                          company:
                            type: string
                          email:
                            type: string
                        required:
                          - name
                          - company
                          - email
                        additionalProperties: false
              推理强度:
                summary: 推理强度
                description: 支持推理的模型可以用 `reasoning_effort` 在速度和思考深度之间取舍。
                value:
                  model: gpt-6.2-sol
                  reasoning_effort: high
                  messages:
                    - role: user
                      content: >-
                        一个水池有两个进水管和一个出水管，单开甲管 6 小时注满，单开乙管 8 小时注满，单开出水管 12
                        小时放完。三管齐开，多久注满？
      responses:
        '200':
          description: >-
            非流式请求返回一个 Chat Completion 对象。


            如果 `stream` 为 `true`，则返回服务器发送事件（`text/event-stream`）。成功的数据块帧包含一个符合
            `CreateChatCompletionStreamResponse` 的 JSON Chat Completion
            数据块。正常结束时，最后一帧为：


            ```text

            data: [DONE]


            ```


            最后一帧以空行结尾。`[DONE]` 是字面文本，而不是 JSON 数据块，且该帧没有 `event: done` 字段。


            如果流式开始后发生故障，某个数据帧中可能包含一个带 `error` 字段的 JSON 对象，而不是补全数据块。流式 schema
            描述的是成功的 JSON 数据块，不包括错误帧或结束标记。中断的流可能在没有结束标记的情况下结束。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateChatCompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CreateChatCompletionStreamResponse'
        '400':
          description: 请求无效：JSON 格式错误、缺少必填字段，或参数不被所选模型支持。按 `message` 修改后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: invalid_request
                      http_status: 400
                      message: Invalid request.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: invalid_request_error
        '401':
          description: API Key 缺失或无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: unauthorized
                      http_status: 401
                      message: Unauthorized.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: authentication_error
        '402':
          description: 账户余额不足，充值后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: insufficient_balance
                      http_status: 402
                      message: Insufficient balance.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: insufficient_balance_error
        '403':
          description: 当前 API Key 无权使用该模型。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: forbidden
                      http_status: 403
                      message: Access denied.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: permission_error
        '404':
          description: 模型不存在或尚未开放。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: not_found
                      http_status: 404
                      message: The requested model was not found.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: invalid_request_error
        '429':
          description: 请求频率超过限制，退避后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: rate_limit_exceeded
                      http_status: 429
                      message: Rate limit exceeded. Please try again later.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: rate_limit_error
        '500':
          description: 服务内部错误，稍后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: api_error
                      http_status: 500
                      message: Internal server error.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: api_error
        '503':
          description: 服务暂时不可用或处理超时，稍后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GatewayError'
              examples:
                example:
                  value:
                    error:
                      code: service_unavailable
                      http_status: 503
                      message: Service temporarily unavailable. Please try again later.
                      request_id: req_3f9a1c2b7d4e5f60718293a4
                      type: api_error
components:
  schemas:
    CreateChatCompletionRequest:
      allOf:
        - $ref: '#/components/schemas/CreateModelResponseProperties'
        - type: object
          properties:
            prompt_cache_options:
              $ref: '#/components/schemas/PromptCacheOptionsParam'
            messages:
              description: >-
                迄今为止构成对话的消息列表。根据所用的
                [模型](https://developers.openai.com/api/docs/models)，支持不同的消息类型（模态），例如
                [文本](https://developers.openai.com/api/docs/guides/text)、[图像](https://developers.openai.com/api/docs/guides/images-vision)
                和 [音频](https://developers.openai.com/api/docs/guides/audio)。
              type: array
              minItems: 1
              items:
                $ref: '#/components/schemas/ChatCompletionRequestMessage'
            model:
              type: string
              description: >-
                要使用的模型 ID，例如
                `gpt-6.2-sol`。可用模型见[模型介绍](/llm/openai-chat-completions)。
              example: gpt-6.2-sol
            service_tier:
              $ref: '#/components/schemas/ServiceTier'
            modalities:
              $ref: '#/components/schemas/ResponseModalities'
            verbosity:
              $ref: '#/components/schemas/Verbosity'
            reasoning_effort:
              $ref: '#/components/schemas/ReasoningEffort'
            max_completion_tokens:
              description: >-
                补全可生成的 Token 数上限，包括可见的输出 Token 和 [推理
                Token](https://developers.openai.com/api/docs/guides/reasoning)。
              type:
                - integer
                - 'null'
            frequency_penalty:
              type:
                - number
                - 'null'
              default: 0
              minimum: -2
              maximum: 2
              description: >-
                取值范围为 -2.0 到 2.0。正值会根据新 Token
                在已有文本中出现的频率对其进行惩罚，从而降低模型逐字重复同一行内容的可能性。
            presence_penalty:
              type:
                - number
                - 'null'
              default: 0
              minimum: -2
              maximum: 2
              description: 取值范围为 -2.0 到 2.0。正值会根据新 Token 是否已在已有文本中出现对其进行惩罚，从而提高模型谈论新话题的可能性。
            web_search_options:
              type: object
              title: 网页搜索
              description: >-
                此工具在网络上搜索相关结果，用于生成响应。详见
                [网页搜索工具](https://developers.openai.com/api/docs/guides/tools-web-search)。
              properties:
                user_location:
                  type:
                    - object
                    - 'null'
                  required:
                    - type
                    - approximate
                  description: 搜索的大致位置参数。
                  properties:
                    type:
                      type: string
                      description: 位置近似的类型。始终为 `approximate`。
                      const: approximate
                    approximate:
                      $ref: '#/components/schemas/WebSearchLocation'
                search_context_size:
                  $ref: '#/components/schemas/WebSearchContextSize'
            top_logprobs:
              description: >-
                0 到 20 之间的整数，指定在每个 Token 位置返回的最可能 Token 的最大数量，每个 Token
                都附带对数概率。某些情况下，返回的 Token 数可能少于请求的数量。使用此参数时，必须将 `logprobs` 设为
                `true`。
              type:
                - integer
                - 'null'
              minimum: 0
              maximum: 20
            response_format:
              description: >-
                指定模型必须输出的格式的对象。


                设为 `{ "type": "json_schema", "json_schema": {...} }`
                将启用结构化输出，确保模型输出与提供的 JSON Schema 匹配。详见
                [结构化输出指南](https://developers.openai.com/api/docs/guides/structured-outputs)。


                设为 `{ "type": "json_object" }` 将启用旧版 JSON 模式，确保模型生成的消息是有效的
                JSON。对于支持 `json_schema` 的模型，推荐使用 `json_schema`。
              oneOf:
                - $ref: '#/components/schemas/ResponseFormatText'
                - $ref: '#/components/schemas/ResponseFormatJsonSchema'
                - $ref: '#/components/schemas/ResponseFormatJsonObject'
              discriminator:
                propertyName: type
            audio:
              type:
                - object
                - 'null'
              description: >-
                音频输出参数。使用 `modalities: ["audio"]`
                请求音频输出时为必填。[了解更多](https://developers.openai.com/api/docs/guides/audio)。
              required:
                - voice
                - format
              properties:
                voice:
                  $ref: '#/components/schemas/VoiceIdsOrCustomVoice'
                  description: >-
                    模型用于响应的声音。支持的内置声音有
                    `alloy`、`ash`、`ballad`、`coral`、`echo`、`fable`、`nova`、`onyx`、`sage`、`shimmer`、`marin`
                    和 `cedar`。也可以提供带 `id` 的自定义声音对象，例如 `{ "id": "voice_1234"
                    }`。自定义声音必须基于音频样本创建。基于文本提示词创建的声音仅在 Live 中支持。
                format:
                  type: string
                  enum:
                    - wav
                    - aac
                    - mp3
                    - flac
                    - opus
                    - pcm16
                  description: 指定输出音频格式。可选值为 `wav`、`mp3`、`flac`、`opus` 或 `pcm16`。
            store:
              type:
                - boolean
                - 'null'
              default: false
              description: >-
                是否存储此聊天补全请求的输出，以用于我们的
                [模型蒸馏](https://developers.openai.com/api/docs/guides/supervised-fine-tuning#distilling-from-a-larger-model)
                或 [评估](https://developers.openai.com/api/docs/guides/evals) 产品。


                支持文本和图像输入。注意：超过 8MB 的图像输入将被丢弃。
            moderation:
              anyOf:
                - $ref: '#/components/schemas/ModerationParam'
                  description: 对请求输入和生成输出执行内容审核的配置。
                - type: 'null'
            stream:
              description: >-
                设为 true 时，模型响应数据将在生成过程中通过
                [服务器发送事件（SSE）](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
                流式传输给客户端。更多信息请参阅
                [下文的流式部分](https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events)；关于如何处理流式事件，请参阅
                [流式响应](https://developers.openai.com/api/docs/guides/streaming-responses)
                指南。
              type:
                - boolean
                - 'null'
              default: false
            stop:
              $ref: '#/components/schemas/StopConfiguration'
            logit_bias:
              type:
                - object
                - 'null'
              default: null
              additionalProperties:
                type: integer
              description: >-
                调整指定 Token 在补全中出现的可能性。


                接受一个 JSON 对象，将 Token（由其在分词器中的 Token ID 指定）映射到 -100 到 100
                之间的偏置值。从数学上讲，该偏置会在采样前加到模型生成的 logits 上。具体效果因模型而异，但 -1 到 1
                之间的值应会降低或提高被选中的可能性；-100 或 100 这样的值应会禁止或独占选择相应的 Token。
            logprobs:
              description: >-
                是否返回输出 Token 的对数概率。为 true 时，返回 `message` 的 `content` 中每个输出 Token
                的对数概率。
              type:
                - boolean
                - 'null'
              default: false
            max_tokens:
              description: >-
                聊天补全中可生成的最大 [Token](https://platform.openai.com/tokenizer)
                数。此值可用于控制通过 API 生成文本的 [成本](https://openai.com/api/pricing/)。


                此值现已弃用，改用 `max_completion_tokens`，且与 [o
                系列模型](https://developers.openai.com/api/docs/guides/reasoning)
                不兼容。
              type:
                - integer
                - 'null'
              deprecated: true
            'n':
              type:
                - integer
                - 'null'
              minimum: 1
              maximum: 128
              default: 1
              example: 1
              description: >-
                为每条输入消息生成的聊天补全选项数量。注意，将按所有选项生成的 Token 总数计费。将 `n` 保持为 `1`
                可将成本降到最低。
            prediction:
              description: >-
                [Predicted
                Output](https://developers.openai.com/api/docs/guides/predicted-outputs)
                的配置。当模型响应的大部分内容已预先知道时，可以显著缩短响应时间。最常见的场景是重新生成一个大部分内容只有少量改动的文件。
              anyOf:
                - $ref: '#/components/schemas/PredictionContent'
                - type: 'null'
            seed:
              type:
                - integer
                - 'null'
              format: int64
              minimum: -9223372036854776000
              maximum: 9223372036854776000
              deprecated: true
              description: >-
                此功能处于 Beta 阶段。如果指定，系统将尽力进行确定性采样，使使用相同 `seed`
                和参数的重复请求返回相同结果。不保证确定性，可参考响应参数 `system_fingerprint` 来监控后端的变化。
            stream_options:
              $ref: '#/components/schemas/ChatCompletionStreamOptions'
            tools:
              type: array
              description: >-
                模型可以调用的工具列表。可以提供
                [自定义工具](https://developers.openai.com/api/docs/guides/function-calling#custom-tools)
                或
                [函数工具](https://developers.openai.com/api/docs/guides/function-calling)。
              items:
                oneOf:
                  - $ref: '#/components/schemas/ChatCompletionTool'
                  - $ref: '#/components/schemas/CustomToolChatCompletions'
            tool_choice:
              $ref: '#/components/schemas/ChatCompletionToolChoiceOption'
            parallel_tool_calls:
              $ref: '#/components/schemas/ParallelToolCalls'
            function_call:
              deprecated: true
              description: |-
                已弃用，改用 `tool_choice`。

                控制模型调用哪个函数（如有）。

                `none` 表示模型不调用函数，而是生成一条消息。

                `auto` 表示模型可以在生成消息和调用函数之间自行选择。

                通过 `{"name": "my_function"}` 指定某个函数，会强制模型调用该函数。

                没有函数时默认为 `none`；存在函数时默认为 `auto`。
              oneOf:
                - type: string
                  description: '`none` 表示模型不调用函数，而是生成一条消息。`auto` 表示模型可以在生成消息和调用函数之间自行选择。'
                  enum:
                    - none
                    - auto
                - $ref: '#/components/schemas/ChatCompletionFunctionCallOption'
            functions:
              deprecated: true
              description: |-
                已弃用，改用 `tools`。

                模型可以为其生成 JSON 输入的函数列表。
              type: array
              minItems: 1
              maxItems: 128
              items:
                $ref: '#/components/schemas/ChatCompletionFunctions'
          required:
            - model
            - messages
    CreateChatCompletionResponse:
      type: object
      description: 表示模型根据所提供输入返回的聊天补全响应。
      properties:
        id:
          type: string
          description: 聊天补全的唯一标识符。
        choices:
          type: array
          description: 聊天补全选项列表。如果 `n` 大于 1，可能有多个选项。
          items:
            type: object
            required:
              - finish_reason
              - index
              - message
              - logprobs
            properties:
              finish_reason:
                type: string
                description: >-
                  模型停止生成 Token 的原因。如果模型到达自然停止点或遇到提供的停止序列，则为 `stop`；如果达到请求中指定的最大
                  Token 数，则为 `length`；如果内容因内容过滤器的标记而被省略，则为
                  `content_filter`；如果模型调用了工具，则为 `tool_calls`；如果模型调用了函数，则为
                  `function_call`（已弃用）。更多信息请阅读 [Model
                  Spec](https://model-spec.openai.com/2025-12-18.html)。
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - function_call
              index:
                type: integer
                description: 该选项在选项列表中的索引。
              message:
                $ref: '#/components/schemas/ChatCompletionResponseMessage'
              logprobs:
                anyOf:
                  - description: 该选项的对数概率信息。
                    type: object
                    properties:
                      content:
                        anyOf:
                          - description: 带有对数概率信息的消息内容 Token 列表。
                            type: array
                            items:
                              $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                          - type: 'null'
                      refusal:
                        anyOf:
                          - description: 带有对数概率信息的消息拒绝 Token 列表。
                            type: array
                            items:
                              $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                          - type: 'null'
                    required:
                      - content
                      - refusal
                  - type: 'null'
        created:
          type: integer
          format: unixtime
          description: 聊天补全的创建时间，以 Unix 时间戳（秒）表示。
        model:
          type: string
          description: 用于聊天补全的模型。
        metadata:
          $ref: '#/components/schemas/Metadata'
        service_tier:
          $ref: '#/components/schemas/ServiceTier'
        system_fingerprint:
          type: string
          deprecated: true
          description: |-
            此指纹表示模型运行所用的后端配置。

            可与请求参数 `seed` 结合使用，以了解后端何时发生了可能影响确定性的变更。
        object:
          type: string
          description: 对象类型，始终为 `chat.completion`。
          const: chat.completion
        usage:
          $ref: '#/components/schemas/CompletionUsage'
        moderation:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionModeration'
              description: 如果请求了经内容审核的补全，则为针对请求输入和生成输出的内容审核结果。
            - type: 'null'
      required:
        - choices
        - created
        - id
        - model
        - object
    CreateChatCompletionStreamResponse:
      type: object
      description: >-
        表示模型根据所提供输入返回的聊天补全响应的一个流式数据块。[了解更多](https://developers.openai.com/api/docs/guides/streaming-responses)。
      properties:
        id:
          type: string
          description: 聊天补全的唯一标识符。每个数据块的 ID 相同。
        choices:
          type: array
          description: >-
            聊天补全选项列表。如果 `n` 大于 1，可能包含多个元素。如果设置了 `stream_options:
            {"include_usage": true}`，最后一个数据块中也可能为空。
          items:
            type: object
            required:
              - delta
              - index
            properties:
              delta:
                $ref: '#/components/schemas/ChatCompletionStreamResponseDelta'
              logprobs:
                description: 该选项的对数概率信息。
                type:
                  - object
                  - 'null'
                properties:
                  content:
                    description: 带有对数概率信息的消息内容 Token 列表。
                    type:
                      - array
                      - 'null'
                    items:
                      $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                  refusal:
                    description: 带有对数概率信息的消息拒绝 Token 列表。
                    type:
                      - array
                      - 'null'
                    items:
                      $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                required:
                  - content
                  - refusal
              finish_reason:
                type:
                  - string
                  - 'null'
                description: >-
                  模型停止生成 Token 的原因。如果模型到达自然停止点或遇到提供的停止序列，则为 `stop`；如果达到请求中指定的最大
                  Token 数，则为 `length`；如果内容因内容过滤器的标记而被省略，则为
                  `content_filter`；如果模型调用了工具，则为 `tool_calls`；如果模型调用了函数，则为
                  `function_call`（已弃用）。在仅包含 `delta.audio.expires_at`
                  的最后一个音频更新中省略此字段。
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - function_call
                  - null
              index:
                type: integer
                description: 该选项在选项列表中的索引。
        created:
          type: integer
          format: unixtime
          description: 聊天补全的创建时间，以 Unix 时间戳（秒）表示。每个数据块的时间戳相同。
        model:
          type: string
          description: 用于生成补全的模型。
        obfuscation:
          type: string
          description: >-
            为统一流式数据块大小而添加的混淆字符串，用于缓解某些侧信道攻击。该字段默认包含，当
            `stream_options.include_obfuscation` 为 `false` 时省略。
        service_tier:
          $ref: '#/components/schemas/ServiceTier'
        system_fingerprint:
          type: string
          deprecated: true
          description: 此指纹表示模型运行所用的后端配置。可与请求参数 `seed` 结合使用，以了解后端何时发生了可能影响确定性的变更。
        object:
          type: string
          description: 对象类型，始终为 `chat.completion.chunk`。
          const: chat.completion.chunk
        usage:
          anyOf:
            - $ref: '#/components/schemas/CompletionUsage'
            - type: 'null'
          description: >-
            可选字段，仅在请求中设置了 `stream_options: {"include_usage": true}` 时出现。出现时，其值为
            null，**最后一个数据块除外**，该数据块包含整个请求的 Token 用量统计。


            **注意：** 如果流被中断或取消，可能收不到包含请求 Token 总用量的最终用量数据块。
        moderation:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionModeration'
              description: 针对请求输入和生成输出的内容审核结果。请求经内容审核的补全时，出现在内容审核数据块中。
            - type: 'null'
      required:
        - choices
        - created
        - id
        - model
        - object
      examples:
        - id: chatcmpl-123
          object: chat.completion.chunk
          created: 1694268190
          model: gpt-6.2-astra
          system_fingerprint: fp_44709d6fcb
          choices:
            - index: 0
              delta:
                content: Hello
              logprobs: null
              finish_reason: null
          obfuscation: p9K3xT6w
        - id: chatcmpl-123
          object: chat.completion.chunk
          created: 1694268190
          model: gpt-6.2-astra
          system_fingerprint: fp_44709d6fcb
          choices:
            - index: 0
              delta: {}
              logprobs: null
              finish_reason: stop
          obfuscation: ''
    GatewayError:
      type: object
      description: 错误响应。
      properties:
        error:
          type: object
          description: 错误信息。
          properties:
            code:
              type: string
              description: >-
                错误码，例如
                `invalid_request`、`unauthorized`、`insufficient_balance`、`rate_limit_exceeded`。个别由模型侧直接返回的参数错误里，这里是数字形式的状态码。
            http_status:
              type: integer
              description: 与响应的 HTTP 状态码相同；个别由模型侧直接返回的错误不带这个字段。
            message:
              type: string
              description: 错误描述（英文）。程序逻辑请依据状态码和 `code` 判断，不要依赖这段文字。
            request_id:
              type: string
              description: 本次请求的 ID，与响应头 `X-Request-Id` 相同，反馈问题时请提供；个别错误不带这个字段，请以响应头为准。
            type:
              type: string
              description: >-
                错误大类，例如
                `invalid_request_error`、`authentication_error`、`rate_limit_error`、`api_error`；个别错误不带这个字段。
          required:
            - code
            - message
      required:
        - error
    CreateModelResponseProperties:
      allOf:
        - $ref: '#/components/schemas/ModelResponseProperties'
        - type: object
          properties:
            top_logprobs:
              description: >-
                0 到 20 之间的整数，指定在每个 Token 位置返回的最可能 Token 的最大数量，每个 Token
                都附带对数概率。某些情况下，返回的 Token 数可能少于请求的数量。
              type: integer
              minimum: 0
              maximum: 20
    PromptCacheOptionsParam:
      properties:
        ttl:
          $ref: '#/components/schemas/PromptCacheTTLEnum'
          description: 应用于请求写入的每个隐式和显式缓存断点的最短生命周期。默认为 `30m`，这也是目前唯一支持的值。后端可能会将缓存条目保留更长时间。
        mode:
          $ref: '#/components/schemas/PromptCacheModeEnum'
          description: >-
            控制 OpenAI 是否自动创建隐式缓存断点。默认为 `implicit`。使用 `implicit` 时，OpenAI
            会创建一个隐式断点，并写入请求中最近的最多三个显式断点。使用 `explicit` 时，OpenAI
            不创建隐式断点，并写入最近的最多四个显式断点。如果没有显式断点，请求将不使用提示缓存。
      type: object
      required: []
      title: 提示缓存选项
      description: >-
        提示缓存的选项。`gpt-5.6` 及更新的模型支持。默认情况下，OpenAI 会自动选择一个隐式缓存断点。可以通过
        `prompt_cache_breakpoint` 为内容块添加显式断点。每个请求最多可写入四个断点。进行缓存匹配时，OpenAI
        最多考虑对话中最近的 80 个断点，不限制内容块的回溯范围。将 `mode` 设为 `explicit` 可禁用隐式断点。`ttl` 默认为
        `30m`。支持的生命周期取决于所用 API。最新详情请参阅
        [提示缓存指南](https://developers.openai.com/api/docs/guides/prompt-caching)。
    ChatCompletionRequestMessage:
      oneOf:
        - $ref: '#/components/schemas/ChatCompletionRequestDeveloperMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestUserMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestToolMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage'
      discriminator:
        propertyName: role
    ServiceTier:
      anyOf:
        - type: string
          description: |-
            指定处理请求所用的处理类型。
              - 设为 'auto' 时，请求将使用项目设置中配置的服务层级处理。除非另行配置，项目将使用 'default'。
              - 设为 'default' 时，请求将按所选模型的标准价格和性能处理。
              - 设为 '[flex](https://developers.openai.com/api/docs/guides/flex-processing)' 时，请求将使用 Flex Processing 服务层级处理。
              - 要在请求级别启用 [Fast 模式](https://developers.openai.com/api/docs/guides/fast-mode)，请在 Responses 或 Chat Completions 中加入 `service_tier=fast` 或 `service_tier=priority` 参数。无论请求中指定的是 `service_tier=fast` 还是 `priority`，响应中都会显示 `service_tier=priority`。
              - 未设置时，默认行为为 'auto'。

              设置了 `service_tier` 参数时，响应体会包含 `service_tier` 值，该值基于实际处理请求所用的处理模式，可能与参数中设置的值不同。
          enum:
            - auto
            - default
            - flex
            - scale
            - priority
            - fast
          default: auto
        - type: 'null'
    ResponseModalities:
      anyOf:
        - type: array
          description: >-
            希望模型生成的输出类型。大多数模型都能生成文本，这也是默认值：


            `["text"]`


            `gpt-4o-audio-preview` 模型还可用于
            [生成音频](https://developers.openai.com/api/docs/guides/audio)。要让该模型同时生成文本和音频响应，可以使用：


            `["text", "audio"]`
          items:
            type: string
            enum:
              - text
              - audio
        - type: 'null'
    Verbosity:
      anyOf:
        - type: string
          enum:
            - low
            - medium
            - high
          default: medium
          description: >-
            限制模型响应的详细程度。值越低，响应越简洁；值越高，响应越详细。目前支持的值为 `low`、`medium` 和 `high`。默认为
            `medium`。
        - type: 'null'
    ReasoningEffort:
      anyOf:
        - type: string
          enum:
            - none
            - minimal
            - low
            - medium
            - high
            - xhigh
            - max
          default: medium
          description: >-
            限制推理模型的推理强度。目前支持的值为 `none`、`minimal`、`low`、`medium`、`high`、`xhigh` 和
            `max`。降低推理强度可以加快响应速度，并减少响应中用于推理的 Token。并非所有推理模型都支持每个值。各模型的支持情况请参阅
            [推理指南](https://developers.openai.com/api/docs/guides/reasoning)。
        - type: 'null'
    WebSearchLocation:
      type: object
      title: 网页搜索位置
      description: 搜索的大致位置参数。
      properties:
        country:
          type: string
          description: >-
            用户所在国家/地区的两字母 [ISO
            国家代码](https://en.wikipedia.org/wiki/ISO_3166-1)，例如 `US`。
        region:
          type: string
          description: 用户所在地区的自由文本输入，例如 `California`。
        city:
          type: string
          description: 用户所在城市的自由文本输入，例如 `San Francisco`。
        timezone:
          type: string
          description: >-
            用户的 [IANA 时区](https://timeapi.io/documentation/iana-timezones)，例如
            `America/Los_Angeles`。
    WebSearchContextSize:
      type: string
      description: 关于搜索使用多少上下文窗口空间的高层指导。可选值为 `low`、`medium` 或 `high`。默认为 `medium`。
      enum:
        - low
        - medium
        - high
      default: medium
    ResponseFormatText:
      type: object
      title: 文本
      description: 默认响应格式。用于生成文本响应。
      properties:
        type:
          type: string
          description: 所定义的响应格式类型。始终为 `text`。
          const: text
      required:
        - type
    ResponseFormatJsonSchema:
      type: object
      title: JSON Schema
      description: >-
        JSON Schema 响应格式。用于生成结构化的 JSON 响应。详见
        [结构化输出](https://developers.openai.com/api/docs/guides/structured-outputs)。
      properties:
        type:
          type: string
          description: 所定义的响应格式类型。始终为 `json_schema`。
          const: json_schema
        json_schema:
          type: object
          title: JSON Schema
          description: 结构化输出的配置选项，包括 JSON Schema。
          properties:
            description:
              type: string
              description: 响应格式用途的描述，模型据此决定如何按该格式进行响应。
            name:
              type: string
              description: 响应格式的名称。只能包含 a-z、A-Z、0-9、下划线和短横线，最大长度为 64。
            schema:
              $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema'
            strict:
              anyOf:
                - type: boolean
                  default: false
                  description: >-
                    生成输出时是否启用严格的 schema 遵循。设为 true 时，模型将始终严格遵循 `schema` 字段中定义的
                    schema。当 `strict` 为 `true` 时，仅支持 JSON Schema 的一个子集。详见
                    [结构化输出指南](https://developers.openai.com/api/docs/guides/structured-outputs)。
                - type: 'null'
          required:
            - name
      required:
        - type
        - json_schema
    ResponseFormatJsonObject:
      type: object
      title: JSON 对象
      description: >-
        JSON 对象响应格式。一种生成 JSON 响应的旧方法。对于支持 `json_schema` 的模型，推荐使用
        `json_schema`。注意，如果没有系统消息或用户消息指示模型生成 JSON，模型不会生成 JSON。
      properties:
        type:
          type: string
          description: 所定义的响应格式类型。始终为 `json_object`。
          const: json_object
      required:
        - type
    VoiceIdsOrCustomVoice:
      title: 声音
      description: 内置声音名称或自定义声音引用。
      anyOf:
        - $ref: '#/components/schemas/VoiceIdsShared'
        - type: object
          description: 自定义声音引用。
          additionalProperties: false
          required:
            - id
          properties:
            id:
              type: string
              description: 自定义声音 ID，例如 `voice_1234`。
              example: voice_1234
    ModerationParam:
      properties:
        model:
          type: string
          description: 用于经内容审核补全的内容审核模型，例如 'omni-moderation-latest'。
        policy:
          anyOf:
            - $ref: '#/components/schemas/ModerationPolicyParam'
              description: 应用于经内容审核的响应输入和输出的策略。
            - type: 'null'
      type: object
      required:
        - model
      description: 对此响应的输入和输出执行内容审核的配置。
    StopConfiguration:
      description: |-
        最新推理模型 `o3` 和 `o4-mini` 不支持此参数。

        最多 4 个序列，API 遇到这些序列时将停止继续生成 Token。返回的文本不包含停止序列。
      default: null
      oneOf:
        - type: string
          default: <|endoftext|>
          example: |+

        - type: array
          minItems: 1
          maxItems: 4
          items:
            type: string
            example: '["\n"]'
        - type: 'null'
    PredictionContent:
      type: object
      title: 静态内容
      description: 静态的预测输出内容，例如正在重新生成的文本文件的内容。
      required:
        - type
        - content
      properties:
        type:
          type: string
          enum:
            - content
          description: 要提供的预测内容的类型。目前该类型始终为 `content`。
        content:
          description: 生成模型响应时应匹配的内容。如果生成的 Token 与此内容匹配，整个模型响应可以更快地返回。
          oneOf:
            - type: string
              title: 文本内容
              description: 用于 Predicted Output 的内容。通常是正在重新生成且只有少量改动的文件文本。
            - type: array
              description: >-
                具有指定类型的内容部分数组。支持的选项因生成响应所用的
                [模型](https://developers.openai.com/api/docs/models) 而异。可包含文本输入。
              title: 内容部分数组
              items:
                $ref: >-
                  #/components/schemas/ChatCompletionRequestMessageContentPartText
              minItems: 1
    ChatCompletionStreamOptions:
      anyOf:
        - description: '流式响应的选项。仅在设置了 `stream: true` 时设置此项。'
          type: object
          properties:
            include_usage:
              type: boolean
              description: >-
                如果设置，将在 `data: [DONE]` 消息之前额外流式传输一个数据块。该数据块中的 `usage` 字段显示整个请求的
                Token 用量统计，`choices` 字段始终为空数组。


                其他所有数据块也会包含 `usage` 字段，但其值为 null。**注意：** 如果流被中断，可能收不到包含请求 Token
                总用量的最终用量数据块。
            include_obfuscation:
              type: boolean
              description: >-
                为 true 时启用流混淆。流混淆会在流式增量事件的 `obfuscation`
                字段中添加随机字符，使负载大小趋于一致，以缓解某些侧信道攻击。这些混淆字段默认包含，但会给数据流带来少量额外开销。如果信任应用与
                OpenAI API 之间的网络链路，可将 `include_obfuscation` 设为 false 以节省带宽。
        - type: 'null'
    ChatCompletionTool:
      type: object
      title: 函数工具
      description: 可用于生成响应的函数工具。
      properties:
        type:
          type: string
          const: function
          description: 工具类型。目前仅支持 `function`。
        function:
          $ref: '#/components/schemas/FunctionObject'
      required:
        - type
        - function
    CustomToolChatCompletions:
      type: object
      title: 自定义工具
      description: 使用指定格式处理输入的自定义工具。
      properties:
        type:
          type: string
          const: custom
          description: 自定义工具的类型。始终为 `custom`。
        custom:
          type: object
          title: 自定义工具属性
          description: 自定义工具的属性。
          properties:
            name:
              type: string
              description: 自定义工具的名称，用于在工具调用中标识该工具。
            description:
              type: string
              description: 自定义工具的可选描述，用于提供更多上下文。
            format:
              description: 自定义工具的输入格式。默认为无约束文本。
              oneOf:
                - type: object
                  title: 文本格式
                  description: 无约束的自由格式文本。
                  properties:
                    type:
                      type: string
                      enum:
                        - text
                      description: 无约束文本格式。始终为 `text`。
                  required:
                    - type
                  additionalProperties: false
                - type: object
                  title: 语法格式
                  description: 用户定义的语法。
                  properties:
                    type:
                      type: string
                      enum:
                        - grammar
                      description: 语法格式。始终为 `grammar`。
                    grammar:
                      type: object
                      title: 语法格式
                      description: 所选的语法。
                      properties:
                        definition:
                          type: string
                          description: 语法定义。
                        syntax:
                          type: string
                          description: 语法定义的句法。可选值为 `lark` 或 `regex`。
                          enum:
                            - lark
                            - regex
                      required:
                        - definition
                        - syntax
                  required:
                    - type
                    - grammar
                  additionalProperties: false
          required:
            - name
      required:
        - type
        - custom
    ChatCompletionToolChoiceOption:
      description: >-
        控制模型调用哪个工具（如有）。`none` 表示模型不调用任何工具，而是生成一条消息。`auto`
        表示模型可以在生成消息和调用一个或多个工具之间自行选择。`required` 表示模型必须调用一个或多个工具。通过 `{"type":
        "function", "function": {"name": "my_function"}}` 指定某个工具，会强制模型调用该工具。


        没有工具时默认为 `none`；存在工具时默认为 `auto`。
      oneOf:
        - type: string
          title: 工具选择模式
          description: >-
            `none` 表示模型不调用任何工具，而是生成一条消息。`auto`
            表示模型可以在生成消息和调用一个或多个工具之间自行选择。`required` 表示模型必须调用一个或多个工具。
          enum:
            - none
            - auto
            - required
        - $ref: '#/components/schemas/ChatCompletionAllowedToolsChoice'
        - $ref: '#/components/schemas/ChatCompletionNamedToolChoice'
        - $ref: '#/components/schemas/ChatCompletionNamedToolChoiceCustom'
    ParallelToolCalls:
      description: >-
        使用工具时是否启用
        [并行函数调用](https://developers.openai.com/api/docs/guides/function-calling#parallel-function-calling)。
      type: boolean
      default: true
    ChatCompletionFunctionCallOption:
      type: object
      description: '通过 `{"name": "my_function"}` 指定某个函数，会强制模型调用该函数。'
      properties:
        name:
          type: string
          description: 要调用的函数名称。
      required:
        - name
    ChatCompletionFunctions:
      type: object
      deprecated: true
      properties:
        description:
          type: string
          description: 函数功能的描述，模型据此决定何时以及如何调用该函数。
        name:
          type: string
          description: 要调用的函数名称。只能包含 a-z、A-Z、0-9、下划线和短横线，最大长度为 64。
        parameters:
          $ref: '#/components/schemas/FunctionParameters'
      required:
        - name
    ChatCompletionResponseMessage:
      type: object
      description: 模型生成的聊天补全消息。
      properties:
        content:
          anyOf:
            - type: string
              description: 消息的内容。
            - type: 'null'
        refusal:
          anyOf:
            - type: string
              description: 模型生成的拒绝消息。
            - type: 'null'
        tool_calls:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionMessageToolCalls'
            - type: 'null'
        annotations:
          type: array
          description: >-
            消息的注释（如适用），例如使用
            [网页搜索工具](https://developers.openai.com/api/docs/guides/tools-web-search)
            时。
          items:
            type: object
            description: 使用网页搜索时的 URL 引用。
            required:
              - type
              - url_citation
            properties:
              type:
                type: string
                description: URL 引用的类型。始终为 `url_citation`。
                const: url_citation
              url_citation:
                type: object
                description: 使用网页搜索时的 URL 引用。
                required:
                  - end_index
                  - start_index
                  - url
                  - title
                properties:
                  end_index:
                    type: integer
                    description: URL 引用在消息中最后一个字符的索引。
                  start_index:
                    type: integer
                    description: URL 引用在消息中第一个字符的索引。
                  url:
                    type: string
                    format: uri
                    description: 网络资源的 URL。
                  title:
                    type: string
                    description: 网络资源的标题。
        role:
          type: string
          const: assistant
          description: 此消息作者的角色。
        function_call:
          type:
            - object
            - 'null'
          deprecated: true
          description: 已弃用，已由 `tool_calls` 取代。模型生成的应被调用函数的名称和参数。
          properties:
            arguments:
              type: string
              description: >-
                调用函数时使用的参数，由模型以 JSON 格式生成。注意，模型生成的 JSON 不一定总是有效，也可能臆造函数 schema
                中未定义的参数。调用函数前请在代码中校验这些参数。
            name:
              type: string
              description: 要调用的函数名称。
          required:
            - name
            - arguments
        audio:
          anyOf:
            - type: object
              description: >-
                如果请求了音频输出模态，此对象包含模型音频响应的相关数据。[了解更多](https://developers.openai.com/api/docs/guides/audio)。
              required:
                - id
                - expires_at
                - data
                - transcript
              properties:
                id:
                  type: string
                  description: 此音频响应的唯一标识符。
                expires_at:
                  type: integer
                  format: unixtime
                  description: 此音频响应在服务器上不再可用于多轮对话的时间，以 Unix 时间戳（秒）表示。
                data:
                  type: string
                  description: 模型生成的 Base64 编码音频字节，格式为请求中指定的格式。
                transcript:
                  type: string
                  description: 模型生成的音频的转录文本。
            - type: 'null'
      required:
        - role
        - content
    ChatCompletionTokenLogprob:
      type: object
      properties:
        token:
          description: Token。
          type: string
        logprob:
          description: >-
            该 Token 的对数概率（如果它位于最可能的前 20 个 Token 之内）。否则使用值 `-9999.0`，表示该 Token
            极不可能出现。
          type: number
        bytes:
          anyOf:
            - description: >-
                表示该 Token UTF-8 字节形式的整数列表。当某些字符由多个 Token
                表示、需要合并其字节表示才能得到正确文本时很有用。如果该 Token 没有字节表示，可以为 `null`。
              type: array
              items:
                type: integer
            - type: 'null'
        top_logprobs:
          description: 在该 Token 位置上最可能的 Token 及其对数概率列表。条目数可能少于请求的 `top_logprobs`。
          type: array
          items:
            type: object
            properties:
              token:
                description: Token。
                type: string
              logprob:
                description: >-
                  该 Token 的对数概率（如果它位于最可能的前 20 个 Token 之内）。否则使用值 `-9999.0`，表示该
                  Token 极不可能出现。
                type: number
              bytes:
                anyOf:
                  - description: >-
                      表示该 Token UTF-8 字节形式的整数列表。当某些字符由多个 Token
                      表示、需要合并其字节表示才能得到正确文本时很有用。如果该 Token 没有字节表示，可以为 `null`。
                    type: array
                    items:
                      type: integer
                  - type: 'null'
            required:
              - token
              - logprob
              - bytes
      required:
        - token
        - logprob
        - bytes
        - top_logprobs
    Metadata:
      anyOf:
        - type: object
          description: |-
            可附加到对象上的 16 个键值对。可用于以结构化格式存储对象的附加信息，并通过 API 或控制台查询对象。

            键为字符串，最大长度为 64 个字符。值为字符串，最大长度为 512 个字符。
          additionalProperties:
            type: string
        - type: 'null'
    CompletionUsage:
      type: object
      description: 补全请求的用量统计。
      properties:
        completion_tokens:
          type: integer
          default: 0
          description: 生成的补全中的 Token 数。
        prompt_tokens:
          type: integer
          default: 0
          description: 提示词中的 Token 数。
        total_tokens:
          type: integer
          default: 0
          description: 请求使用的 Token 总数（提示词 + 补全）。
        completion_tokens_details:
          type: object
          description: 补全所用 Token 的明细。
          properties:
            accepted_prediction_tokens:
              type: integer
              default: 0
              description: 使用 Predicted Outputs 时，预测内容中出现在补全里的 Token 数。
            audio_tokens:
              type: integer
              default: 0
              description: 模型生成的音频输入 Token。
            reasoning_tokens:
              type: integer
              default: 0
              description: 模型为推理生成的 Token。
            text_tokens:
              type: integer
              description: 模型生成的文本输出 Token。
            rejected_prediction_tokens:
              type: integer
              default: 0
              description: >-
                使用 Predicted Outputs 时，预测内容中未出现在补全里的 Token 数。不过，与推理 Token 一样，这些
                Token 在计费、输出和上下文窗口限制方面仍计入补全 Token 总数。
        prompt_tokens_details:
          type: object
          description: 提示词所用 Token 的明细。
          properties:
            audio_tokens:
              type: integer
              default: 0
              description: 提示词中的音频输入 Token。
            cached_tokens:
              type: integer
              default: 0
              description: 提示词中的缓存 Token。
            text_tokens:
              type: integer
              description: 提示词中的文本输入 Token。
            image_tokens:
              type: integer
              description: 提示词中的图像输入 Token。
            cache_write_tokens:
              type: integer
              default: 0
              description: 写入缓存的提示词 Token 数（未经调整）。
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
    ChatCompletionModeration:
      type: object
      description: 针对请求输入和生成输出的内容审核结果或错误。
      properties:
        input:
          oneOf:
            - $ref: '#/components/schemas/ChatCompletionModerationResults'
            - $ref: '#/components/schemas/ChatCompletionModerationError'
          discriminator:
            propertyName: type
          description: 针对请求输入的内容审核。
        output:
          oneOf:
            - $ref: '#/components/schemas/ChatCompletionModerationResults'
            - $ref: '#/components/schemas/ChatCompletionModerationError'
          discriminator:
            propertyName: type
          description: 针对生成输出的内容审核。
      required:
        - input
        - output
    ChatCompletionStreamResponseDelta:
      type: object
      description: 流式模型响应生成的聊天补全增量。流式音频可能以部分更新的形式到达，携带 ID、Base64 数据或转录文本。最后一个音频更新仅包含其过期时间戳。
      properties:
        audio:
          type: object
          description: 部分音频响应。音频数据块可能携带 ID、Base64 数据或转录文本；最后一个音频更新仅包含其过期时间戳。
          properties:
            id:
              type: string
              description: 此音频响应的唯一标识符。
            expires_at:
              type: integer
              format: unixtime
              description: 此音频响应在服务器上不再可用于多轮对话的时间，以 Unix 时间戳（秒）表示。
            data:
              type: string
              description: 模型生成的 Base64 编码音频字节，格式为请求中指定的格式。
            transcript:
              type: string
              description: 此音频数据块的转录文本。
        content:
          anyOf:
            - type: string
              description: 数据块消息的内容。
            - type: 'null'
        function_call:
          deprecated: true
          type: object
          description: 已弃用，已由 `tool_calls` 取代。模型生成的应被调用函数的名称和参数。
          properties:
            arguments:
              type: string
              description: >-
                调用函数时使用的参数，由模型以 JSON 格式生成。注意，模型生成的 JSON 不一定总是有效，也可能臆造函数 schema
                中未定义的参数。调用函数前请在代码中校验这些参数。
            name:
              type: string
              description: 要调用的函数名称。
        tool_calls:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionMessageToolCallChunk'
        role:
          type: string
          enum:
            - developer
            - system
            - user
            - assistant
            - tool
          description: 此消息作者的角色。
        refusal:
          anyOf:
            - type: string
              description: 模型生成的拒绝消息。
            - type: 'null'
    ModelResponseProperties:
      type: object
      properties:
        metadata:
          $ref: '#/components/schemas/Metadata'
        top_logprobs:
          anyOf:
            - description: >-
                0 到 20 之间的整数，指定在每个 Token 位置返回的最可能 Token 的最大数量，每个 Token
                都附带对数概率。某些情况下，返回的 Token 数可能少于请求的数量。
              type: integer
              minimum: 0
              maximum: 20
            - type: 'null'
        temperature:
          anyOf:
            - type: number
              minimum: 0
              maximum: 2
              default: 1
              example: 1
              description: >-
                使用的采样温度，取值范围为 0 到 2。较高的值（如 0.8）会使输出更随机，较低的值（如
                0.2）会使输出更集中、更确定。通常建议只调整此参数或 `top_p` 其中之一，不要同时调整。
            - type: 'null'
        top_p:
          anyOf:
            - type: number
              minimum: 0
              maximum: 1
              default: 1
              example: 1
              description: >-
                温度采样的替代方法，称为核采样：模型只考虑累计概率质量达到 top_p 的 Token 结果。因此 0.1 表示只考虑构成前
                10% 概率质量的 Token。


                通常建议只调整此参数或 `temperature` 其中之一，不要同时调整。
            - type: 'null'
        user:
          type:
            - string
            - 'null'
          example: user-1234
          deprecated: true
          description: >-
            此字段正在被 `safety_identifier` 和 `prompt_cache_key` 取代。请改用
            `prompt_cache_key` 以保持缓存优化。终端用户的稳定标识符。用于更好地对相似请求进行分桶以提高缓存命中率，并帮助
            OpenAI
            检测和防止滥用。[了解更多](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers)。
        safety_identifier:
          anyOf:
            - type: string
              maxLength: 128
              example: safety-identifier-1234
              description: >-
                稳定标识符，用于帮助检测应用中可能违反 OpenAI 使用政策的用户。ID 应为唯一标识每个用户的字符串，最大长度为 128
                个字符。建议对用户名或电子邮件地址进行哈希处理，以避免向我们发送任何身份识别信息。[了解更多](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers)。
            - type: 'null'
        prompt_cache_key:
          anyOf:
            - type: string
              example: prompt-cache-key-1234
              description: >-
                OpenAI 用于缓存相似请求的响应，以优化缓存命中率。取代 `user`
                字段。[了解更多](https://developers.openai.com/api/docs/guides/prompt-caching)。
            - type: 'null'
        prompt_cache_retention:
          deprecated: true
          anyOf:
            - type: string
              enum:
                - in_memory
                - 24h
              description: >-
                已弃用。请改用 `prompt_cache_options.ttl`。


                提示缓存的保留策略。设为 `24h` 可启用扩展提示缓存，使缓存的前缀保持活跃更长时间，最长 24
                小时。[了解更多](https://developers.openai.com/api/docs/guides/prompt-caching#prompt-cache-retention)。此字段表示最长保留策略，而
                `prompt_cache_options.ttl` 表示最短缓存生命周期。这两个字段相互独立，互不影响。对于
                `gpt-5.5`、`gpt-5.5-pro` 及未来的模型，仅支持 `24h`。


                对于同时支持 `in_memory` 和 `24h` 的较旧模型，默认值取决于组织的数据保留策略：
                  - 未启用 ZDR 的组织默认为 `24h`。
                  - 已启用 ZDR 的组织在未指定 `prompt_cache_retention` 时默认为 `in_memory`。
            - type: 'null'
    PromptCacheTTLEnum:
      type: string
      enum:
        - 30m
    PromptCacheModeEnum:
      type: string
      enum:
        - implicit
        - explicit
    ChatCompletionRequestDeveloperMessage:
      type: object
      title: 开发者消息
      description: >-
        开发者提供的指令，无论用户发送什么消息，模型都应遵循。在 o1 及更新的模型中，`developer` 消息取代了以前的 `system`
        消息。
      properties:
        content:
          description: 开发者消息的内容。
          oneOf:
            - type: string
              description: 开发者消息的内容。
              title: 文本内容
            - type: array
              description: 具有指定类型的内容部分数组。对于开发者消息，仅支持 `text` 类型。
              title: 内容部分数组
              items:
                $ref: >-
                  #/components/schemas/ChatCompletionRequestMessageContentPartText
              minItems: 1
        role:
          type: string
          const: developer
          description: 消息作者的角色，此处为 `developer`。
        name:
          type: string
          description: 参与者的可选名称。为模型提供信息，用于区分同一角色的不同参与者。
      required:
        - content
        - role
    ChatCompletionRequestSystemMessage:
      type: object
      title: 系统消息
      description: 开发者提供的指令，无论用户发送什么消息，模型都应遵循。在 o1 及更新的模型中，请改用 `developer` 消息实现此目的。
      properties:
        content:
          description: 系统消息的内容。
          oneOf:
            - type: string
              description: 系统消息的内容。
              title: 文本内容
            - type: array
              description: 具有指定类型的内容部分数组。对于系统消息，仅支持 `text` 类型。
              title: 内容部分数组
              items:
                $ref: >-
                  #/components/schemas/ChatCompletionRequestSystemMessageContentPart
              minItems: 1
        role:
          type: string
          const: system
          description: 消息作者的角色，此处为 `system`。
        name:
          type: string
          description: 参与者的可选名称。为模型提供信息，用于区分同一角色的不同参与者。
      required:
        - content
        - role
    ChatCompletionRequestUserMessage:
      type: object
      title: 用户消息
      description: 终端用户发送的消息，包含提示词或额外的上下文信息。
      properties:
        content:
          description: 用户消息的内容。
          oneOf:
            - type: string
              description: 消息的文本内容。
              title: 文本内容
            - type: array
              description: >-
                具有指定类型的内容部分数组。支持的选项因生成响应所用的
                [模型](https://developers.openai.com/api/docs/models)
                而异。可包含文本、图像或音频输入。
              title: 内容部分数组
              items:
                $ref: >-
                  #/components/schemas/ChatCompletionRequestUserMessageContentPart
              minItems: 1
        role:
          type: string
          const: user
          description: 消息作者的角色，此处为 `user`。
        name:
          type: string
          description: 参与者的可选名称。为模型提供信息，用于区分同一角色的不同参与者。
      required:
        - content
        - role
    ChatCompletionRequestAssistantMessage:
      type: object
      title: 助手消息
      description: 模型为响应用户消息而发送的消息。
      properties:
        content:
          anyOf:
            - oneOf:
                - type: string
                  description: 助手消息的内容。
                  title: 文本内容
                - type: array
                  description: 具有指定类型的内容部分数组。可以是一个或多个 `text` 类型，或恰好一个 `refusal` 类型。
                  title: 内容部分数组
                  items:
                    $ref: >-
                      #/components/schemas/ChatCompletionRequestAssistantMessageContentPart
                  minItems: 1
              description: 助手消息的内容。除非指定了 `tool_calls` 或 `function_call`，否则为必填。
            - type: 'null'
        refusal:
          anyOf:
            - type: string
              description: 助手的拒绝消息。
            - type: 'null'
        role:
          type: string
          const: assistant
          description: 消息作者的角色，此处为 `assistant`。
        name:
          type: string
          description: 参与者的可选名称。为模型提供信息，用于区分同一角色的不同参与者。
        audio:
          anyOf:
            - type: object
              description: >-
                模型先前音频响应的相关数据。[了解更多](https://developers.openai.com/api/docs/guides/audio)。
              required:
                - id
              properties:
                id:
                  type: string
                  description: 模型先前音频响应的唯一标识符。
            - type: 'null'
        tool_calls:
          $ref: '#/components/schemas/ChatCompletionMessageToolCalls'
        function_call:
          anyOf:
            - type: object
              deprecated: true
              description: 已弃用，已由 `tool_calls` 取代。模型生成的应被调用函数的名称和参数。
              properties:
                arguments:
                  type: string
                  description: >-
                    调用函数时使用的参数，由模型以 JSON 格式生成。注意，模型生成的 JSON 不一定总是有效，也可能臆造函数
                    schema 中未定义的参数。调用函数前请在代码中校验这些参数。
                name:
                  type: string
                  description: 要调用的函数名称。
              required:
                - arguments
                - name
            - type: 'null'
      required:
        - role
    ChatCompletionRequestToolMessage:
      type: object
      title: 工具消息
      properties:
        role:
          type: string
          const: tool
          description: 消息作者的角色，此处为 `tool`。
        content:
          oneOf:
            - type: string
              description: 工具消息的内容。
              title: 文本内容
            - type: array
              description: 具有指定类型的内容部分数组。对于工具消息，仅支持 `text` 类型。
              title: 内容部分数组
              items:
                $ref: >-
                  #/components/schemas/ChatCompletionRequestToolMessageContentPart
              minItems: 1
          description: 工具消息的内容。
        tool_call_id:
          type: string
          description: 此消息所响应的工具调用。
      required:
        - role
        - content
        - tool_call_id
    ChatCompletionRequestFunctionMessage:
      type: object
      title: 函数消息
      deprecated: true
      properties:
        role:
          type: string
          const: function
          description: 消息作者的角色，此处为 `function`。
        content:
          anyOf:
            - type: string
              description: 函数消息的内容。
            - type: 'null'
        name:
          type: string
          description: 要调用的函数名称。
      required:
        - role
        - content
        - name
    ResponseFormatJsonSchemaSchema:
      type: object
      title: JSON Schema
      description: >-
        响应格式的 schema，以 JSON Schema 对象描述。如何构建 JSON Schema 请参阅
        [此处](https://json-schema.org/)。
      additionalProperties: true
    VoiceIdsShared:
      example: ash
      anyOf:
        - type: string
        - type: string
          enum:
            - alloy
            - ash
            - ballad
            - coral
            - echo
            - sage
            - shimmer
            - verse
            - marin
            - cedar
    ModerationPolicyParam:
      properties:
        input:
          anyOf:
            - $ref: '#/components/schemas/ModerationConfigParam'
              description: 响应输入的内容审核策略。
            - type: 'null'
        output:
          anyOf:
            - $ref: '#/components/schemas/ModerationConfigParam'
              description: 响应输出的内容审核策略。
            - type: 'null'
      type: object
      required: []
      description: 应用于经内容审核的响应输入和输出的策略。
    ChatCompletionRequestMessageContentPartText:
      type: object
      title: 文本内容部分
      description: 了解 [文本输入](https://developers.openai.com/api/docs/guides/text)。
      properties:
        type:
          type: string
          const: text
          description: 内容部分的类型。
        text:
          type: string
          description: 文本内容。
        prompt_cache_breakpoint:
          $ref: '#/components/schemas/PromptCacheBreakpointParam'
      required:
        - type
        - text
    FunctionObject:
      type: object
      properties:
        description:
          type: string
          description: 函数功能的描述，模型据此决定何时以及如何调用该函数。
        name:
          type: string
          description: 要调用的函数名称。只能包含 a-z、A-Z、0-9、下划线和短横线，最大长度为 64。
        parameters:
          $ref: '#/components/schemas/FunctionParameters'
        strict:
          anyOf:
            - type: boolean
              default: false
              description: >-
                生成函数调用时是否启用严格的 schema 遵循。设为 true 时，模型将严格遵循 `parameters` 字段中定义的
                schema。当 `strict` 为 `true` 时，仅支持 JSON Schema
                的一个子集。关于结构化输出的更多信息，请参阅
                [函数调用指南](https://developers.openai.com/api/docs/guides/function-calling)。
            - type: 'null'
      required:
        - name
    ChatCompletionAllowedToolsChoice:
      type: object
      title: 允许的工具
      description: 将模型可用的工具限制为预定义的集合。
      properties:
        type:
          type: string
          const: allowed_tools
          description: 允许的工具配置类型。始终为 `allowed_tools`。
        allowed_tools:
          $ref: '#/components/schemas/ChatCompletionAllowedTools'
      required:
        - type
        - allowed_tools
    ChatCompletionNamedToolChoice:
      type: object
      title: 函数工具选择
      description: 指定模型应使用的工具。用于强制模型调用某个特定函数。
      properties:
        type:
          type: string
          const: function
          description: 对于函数调用，类型始终为 `function`。
        function:
          type: object
          properties:
            name:
              type: string
              description: 要调用的函数名称。
          required:
            - name
      required:
        - type
        - function
    ChatCompletionNamedToolChoiceCustom:
      type: object
      title: 自定义工具选择
      description: 指定模型应使用的工具。用于强制模型调用某个特定的自定义工具。
      properties:
        type:
          type: string
          const: custom
          description: 对于自定义工具调用，类型始终为 `custom`。
        custom:
          type: object
          properties:
            name:
              type: string
              description: 要调用的自定义工具名称。
          required:
            - name
      required:
        - type
        - custom
    FunctionParameters:
      type: object
      description: >-
        函数接受的参数，以 JSON Schema 对象描述。示例请参阅
        [指南](https://developers.openai.com/api/docs/guides/function-calling)，格式说明请参阅
        [JSON Schema 参考](https://json-schema.org/understanding-json-schema/)。


        省略 `parameters` 将定义一个参数列表为空的函数。
      additionalProperties: true
    ChatCompletionMessageToolCalls:
      type: array
      description: 模型生成的工具调用，例如函数调用。
      items:
        oneOf:
          - $ref: '#/components/schemas/ChatCompletionMessageToolCall'
          - $ref: '#/components/schemas/ChatCompletionMessageCustomToolCall'
        discriminator:
          propertyName: type
    ChatCompletionModerationResults:
      type: object
      description: 针对请求输入或生成输出的成功内容审核结果。
      properties:
        type:
          type: string
          const: moderation_results
          description: 对象类型，始终为 `moderation_results`。
        model:
          type: string
          description: 用于生成结果的内容审核模型。
        results:
          type: array
          description: 内容审核结果列表。
          items:
            $ref: '#/components/schemas/ModerationResultBody'
      required:
        - type
        - model
        - results
    ChatCompletionModerationError:
      type: object
      description: 尝试进行内容审核时产生的错误。
      properties:
        type:
          type: string
          const: error
          description: 对象类型，始终为 `error`。
        code:
          type: string
          description: 错误码。
        message:
          type: string
          description: 错误信息。
      required:
        - type
        - code
        - message
    ChatCompletionMessageToolCallChunk:
      type: object
      properties:
        index:
          type: integer
        id:
          type: string
          description: 工具调用的 ID。
        type:
          type: string
          const: function
          description: 工具类型。目前仅支持 `function`。
        function:
          type: object
          properties:
            name:
              type: string
              description: 要调用的函数名称。
            arguments:
              type: string
              description: >-
                调用函数时使用的参数，由模型以 JSON 格式生成。注意，模型生成的 JSON 不一定总是有效，也可能臆造函数 schema
                中未定义的参数。调用函数前请在代码中校验这些参数。
      required:
        - index
    ChatCompletionRequestSystemMessageContentPart:
      oneOf:
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText'
    ChatCompletionRequestUserMessageContentPart:
      oneOf:
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText'
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartImage'
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartAudio'
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartFile'
    ChatCompletionRequestAssistantMessageContentPart:
      oneOf:
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText'
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartRefusal'
      discriminator:
        propertyName: type
    ChatCompletionRequestToolMessageContentPart:
      oneOf:
        - $ref: '#/components/schemas/ChatCompletionRequestMessageContentPartText'
    ModerationConfigParam:
      properties:
        mode:
          $ref: '#/components/schemas/ModerationMode'
      type: object
      required:
        - mode
      description: 响应输入的内容审核策略。
    PromptCacheBreakpointParam:
      properties:
        mode:
          type: string
          enum:
            - explicit
          description: 断点模式。始终为 `explicit`。
          default: explicit
        ttl:
          type: string
          enum:
            - 30m
            - 12h
          description: 此缓存断点的最短生命周期。默认为请求的 TTL。
      type: object
      required:
        - mode
      title: 提示缓存断点
      description: >-
        标记可复用提示词前缀的确切结束位置。省略 `ttl` 时，该断点继承请求的 `prompt_cache_options.ttl`；边界不会按
        Token 块取整。
    ChatCompletionAllowedTools:
      type: object
      title: 允许的工具
      description: 将模型可用的工具限制为预定义的集合。
      properties:
        mode:
          type: string
          enum:
            - auto
            - required
          description: |-
            将模型可用的工具限制为预定义的集合。

            `auto` 允许模型从允许的工具中选择，也可以生成消息。

            `required` 要求模型调用一个或多个允许的工具。
        tools:
          type: array
          description: |-
            允许模型调用的工具定义列表。

            对于 Chat Completions API，工具定义列表可能如下所示：
            ```json
            [
              { "type": "function", "function": { "name": "get_weather" } },
              { "type": "function", "function": { "name": "get_time" } }
            ]
            ```
          items:
            type: object
            description: 允许模型调用的工具定义。
            additionalProperties: true
      required:
        - mode
        - tools
    ChatCompletionMessageToolCall:
      type: object
      title: 函数工具调用
      description: 模型发起的函数工具调用。
      properties:
        id:
          type: string
          description: 工具调用的 ID。
        type:
          type: string
          const: function
          description: 工具类型。目前仅支持 `function`。
        function:
          type: object
          description: 模型调用的函数。
          properties:
            name:
              type: string
              description: 要调用的函数名称。
            arguments:
              type: string
              description: >-
                调用函数时使用的参数，由模型以 JSON 格式生成。注意，模型生成的 JSON 不一定总是有效，也可能臆造函数 schema
                中未定义的参数。调用函数前请在代码中校验这些参数。
          required:
            - name
            - arguments
      required:
        - id
        - type
        - function
    ChatCompletionMessageCustomToolCall:
      type: object
      title: 自定义工具调用
      description: 模型发起的自定义工具调用。
      properties:
        id:
          type: string
          description: 工具调用的 ID。
        type:
          type: string
          const: custom
          description: 工具类型。始终为 `custom`。
        custom:
          type: object
          description: 模型调用的自定义工具。
          properties:
            name:
              type: string
              description: 要调用的自定义工具名称。
            input:
              type: string
              description: 模型为自定义工具调用生成的输入。
          required:
            - name
            - input
      required:
        - id
        - type
        - custom
    ModerationResultBody:
      properties:
        type:
          type: string
          enum:
            - moderation_result
          description: 对象类型，对于成功的内容审核结果始终为 `moderation_result`。
          default: moderation_result
        model:
          type: string
          description: 生成此结果的内容审核模型。
        flagged:
          type: boolean
          description: 布尔值，表示内容是否被任一类别标记。
        categories:
          additionalProperties:
            type: boolean
          type: object
          description: 内容审核类别到布尔值的字典；如果输入在该类别下被标记，则为 True。
        category_scores:
          additionalProperties:
            type: number
          type: object
          description: 内容审核类别到分数的字典。
        category_applied_input_types:
          additionalProperties:
            items:
              $ref: '#/components/schemas/ModerationInputType'
            type: array
          type: object
          description: 每个类别的分数所反映的输入模态。
      type: object
      required:
        - type
        - model
        - flagged
        - categories
        - category_scores
        - category_applied_input_types
      title: 内容审核结果
      description: 针对响应输入或输出生成的内容审核结果。
    ChatCompletionRequestMessageContentPartImage:
      type: object
      title: 图像内容部分
      description: 了解 [图像输入](https://developers.openai.com/api/docs/guides/images-vision)。
      properties:
        type:
          type: string
          const: image_url
          description: 内容部分的类型。
        image_url:
          type: object
          properties:
            url:
              type: string
              description: 图像的 URL 或 Base64 编码的图像数据。
              format: uri
            detail:
              type: string
              description: >-
                指定图像的细节级别。详见
                [视觉指南](https://developers.openai.com/api/docs/guides/images-vision#choose-an-image-detail-level)。
              enum:
                - auto
                - low
                - high
                - original
              default: auto
          required:
            - url
        prompt_cache_breakpoint:
          $ref: '#/components/schemas/PromptCacheBreakpointParam'
      required:
        - type
        - image_url
    ChatCompletionRequestMessageContentPartAudio:
      type: object
      title: 音频内容部分
      description: 了解 [音频输入](https://developers.openai.com/api/docs/guides/audio)。
      properties:
        type:
          type: string
          const: input_audio
          description: 内容部分的类型。始终为 `input_audio`。
        input_audio:
          type: object
          properties:
            data:
              type: string
              description: Base64 编码的音频数据。
            format:
              type: string
              enum:
                - wav
                - mp3
              description: 编码音频数据的格式。目前支持 "wav" 和 "mp3"。
          required:
            - data
            - format
        prompt_cache_breakpoint:
          $ref: '#/components/schemas/PromptCacheBreakpointParam'
      required:
        - type
        - input_audio
    ChatCompletionRequestMessageContentPartFile:
      type: object
      title: 文件内容部分
      description: 了解用于文本生成的 [文件输入](https://developers.openai.com/api/docs/guides/text)。
      properties:
        type:
          type: string
          const: file
          description: 内容部分的类型。始终为 `file`。
        file:
          type: object
          properties:
            filename:
              type: string
              description: 文件名，以字符串形式向模型传入文件时使用。
            file_data:
              type: string
              description: Base64 编码的文件数据，以字符串形式向模型传入文件时使用。
            file_id:
              type: string
              description: 用作输入的已上传文件的 ID。
        prompt_cache_breakpoint:
          $ref: '#/components/schemas/PromptCacheBreakpointParam'
      required:
        - type
        - file
    ChatCompletionRequestMessageContentPartRefusal:
      type: object
      title: 拒绝内容部分
      properties:
        type:
          type: string
          const: refusal
          description: 内容部分的类型。
        refusal:
          type: string
          description: 模型生成的拒绝消息。
      required:
        - type
        - refusal
    ModerationMode:
      type: string
      enum:
        - score
        - block
    ModerationInputType:
      type: string
      enum:
        - text
        - image
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        在 `Authorization` 请求头中传入 DreamTo API Key：`Authorization: Bearer <API
        Key>`。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.