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

# /v1/chat/completions

> 为给定的聊天对话创建模型响应。您可以在文本生成、视觉和音频指南中了解更多信息。

参数支持可能因用于生成响应的模型而异，特别是对于较新的推理模型。仅推理模型支持的参数将在下文中标注。



## OpenAPI

````yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: TokenOps AI API
  description: TokenOps AI API 提供了强大的AI服务能力，包括聊天对话、Gemini模型集成等功能。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://model-api.skyengine.com.cn
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: 创建聊天完成
      description: |-
        为给定的聊天对话创建模型响应。您可以在文本生成、视觉和音频指南中了解更多信息。

        参数支持可能因用于生成响应的模型而异，特别是对于较新的推理模型。仅推理模型支持的参数将在下文中标注。
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChatCompletionRequest'
      responses:
        '200':
          description: 返回聊天完成对象，如果请求是流式的，则返回聊天完成块对象的流式序列。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateChatCompletionResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/CreateChatCompletionStreamResponse'
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OpenAIAuth: []
components:
  schemas:
    CreateChatCompletionRequest:
      allOf:
        - $ref: '#/components/schemas/CreateModelResponseProperties'
        - type: object
          properties:
            messages:
              description: 对话历史消息列表。根据您使用的模型，支持不同的消息类型（模态），如文本、图像和音频。
              type: array
              minItems: 1
              example:
                - role: user
                  content: 你好，请介绍一下你自己
              items:
                $ref: '#/components/schemas/ChatCompletionRequestMessage'
            model:
              $ref: '#/components/schemas/ModelId'
              description: 用于生成响应的模型ID，如 `gpt-4o`。我们提供各种具有不同能力、性能特点和价格点的模型。
            modalities:
              $ref: '#/components/schemas/ResponseModalities'
            verbosity:
              $ref: '#/components/schemas/Verbosity'
            reasoning_effort:
              $ref: '#/components/schemas/ReasoningEffort'
            max_completion_tokens:
              description: 完成部分可生成的token数量上限，包括可见的输出token和推理token。
              type: integer
              nullable: true
            frequency_penalty:
              type: number
              default: 0
              minimum: -2
              maximum: 2
              nullable: true
              description: '-2.0到2.0之间的数字。正值会根据文本中已有的频率对新token进行惩罚，降低模型逐字重复相同内容的可能性。'
            presence_penalty:
              type: number
              default: 0
              minimum: -2
              maximum: 2
              nullable: true
              description: '-2.0到2.0之间的数字。正值会根据token是否已在文本中出现过进行惩罚，增加模型谈论新主题的可能性。'
            web_search_options:
              type: object
              title: 网络搜索
              description: 这个工具会搜索网络以获取相关结果用于响应。
              properties:
                user_location:
                  type: object
                  nullable: true
                  required:
                    - type
                    - approximate
                  description: 搜索的近似位置参数。
                  properties:
                    type:
                      type: string
                      description: 位置近似类型。始终为 `approximate`。
                      enum:
                        - approximate
                    approximate:
                      $ref: '#/components/schemas/WebSearchLocation'
                search_context_size:
                  $ref: '#/components/schemas/WebSearchContextSize'
            top_logprobs:
              description: >-
                一个介于0和20之间的整数，指定在每个token位置返回的最可能token的数量，每个token都有相关的对数概率。如果使用此参数，必须将
                `logprobs` 设置为 `true`。
              type: integer
              minimum: 0
              maximum: 20
              nullable: true
            response_format:
              description: >-
                指定模型必须输出的格式。


                设置为 `{ "type": "json_schema", "json_schema": {...} }`
                启用结构化输出，确保模型匹配您提供的JSON模式。


                设置为 `{ "type": "json_object" }`
                启用旧版JSON模式，确保模型生成的消息是有效的JSON。对于支持的模型，推荐使用 `json_schema`。
              anyOf:
                - $ref: '#/components/schemas/ResponseFormatText'
                - $ref: '#/components/schemas/ResponseFormatJsonSchema'
                - $ref: '#/components/schemas/ResponseFormatJsonObject'
            audio:
              type: object
              nullable: true
              description: '音频输出参数。当使用 `modalities: ["audio"]` 请求音频输出时需要。'
              required:
                - voice
                - format
              properties:
                voice:
                  $ref: '#/components/schemas/VoiceId'
                  description: >-
                    模型用于响应的声音。支持的声音有
                    `alloy`、`ash`、`ballad`、`coral`、`echo`、`fable`、`nova`、`onyx`、`sage`
                    和 `shimmer`。
                format:
                  type: string
                  enum:
                    - wav
                    - aac
                    - mp3
                    - flac
                    - opus
                    - pcm16
                  description: 指定输出音频格式。必须是 `wav`、`mp3`、`flac`、`opus` 或 `pcm16` 之一。
            store:
              type: boolean
              default: false
              nullable: true
              description: |-
                是否存储此聊天完成请求的输出以用于模型蒸馏或评估产品。

                支持文本和图像输入。注意：超过8MB的图像输入将被丢弃。
            stream:
              description: |-
                如果设置为true，模型响应数据将使用服务器发送事件(SSE)实时流式传输。
                有关更多信息，请参阅流式响应指南。
              type: boolean
              nullable: true
              default: false
            stop:
              $ref: '#/components/schemas/StopConfiguration'
            logit_bias:
              type: object
              default: null
              nullable: true
              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
              default: false
              nullable: true
            max_tokens:
              description: |-
                可以在聊天完成中生成的最大token数。这个值可用于控制通过API生成的文本的成本。

                此值现已被 `max_completion_tokens` 取代，且与o系列模型不兼容。
              type: integer
              nullable: true
              deprecated: true
            'n':
              type: integer
              minimum: 1
              maximum: 128
              default: 1
              example: 1
              nullable: true
              description: 为每个输入消息生成的聊天完成数量。请注意，您将根据所有选择生成的token数量被收费。保持 `n` 为 `1` 以最小化成本。
            prediction:
              nullable: true
              description: 预测输出配置，当模型响应的大部分内容事先已知时，可以大大提高响应时间。这在您要重新生成文件且大部分内容只有微小变化时最为常见。
              anyOf:
                - $ref: '#/components/schemas/PredictionContent'
              discriminator:
                propertyName: type
            seed:
              type: integer
              minimum: -9223372036854776000
              maximum: 9223372036854776000
              nullable: true
              deprecated: true
              description: |-
                此功能处于Beta阶段。
                如果指定，我们的系统将尽最大努力确定性采样，使得具有相同 `seed` 和参数的重复请求应返回相同的结果。
                不保证确定性，您应该参考响应参数中的 `system_fingerprint` 来监控后端的变化。
            stream_options:
              $ref: '#/components/schemas/ChatCompletionStreamOptions'
            tools:
              type: array
              description: 模型可能调用的工具列表。您可以提供自定义工具或函数工具。
              items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionTool'
                  - $ref: '#/components/schemas/CustomToolChatCompletions'
                discriminator:
                  propertyName: type
            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`。
              anyOf:
                - type: string
                  description: '`none` 表示模型不会调用函数，而是生成一条消息。`auto` 表示模型可以在生成消息和调用函数之间选择。'
                  enum:
                    - none
                    - auto
                  title: 函数调用模式
                - $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: 聊天完成的唯一标识符。
          example: chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG
        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`（已弃用）。
                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
          description: 创建聊天完成的Unix时间戳（秒）。
          example: 1741570283
        model:
          type: string
          description: 用于聊天完成的模型。
          example: gpt-4o-2024-08-06
        service_tier:
          $ref: '#/components/schemas/ServiceTier'
        system_fingerprint:
          type: string
          deprecated: true
          description: 此指纹代表模型运行的后端配置。可以与请求参数`seed`结合使用，以了解可能影响确定性的后端变化。
          example: fp_44709d6fcb
        object:
          type: string
          description: 对象类型，始终为`chat.completion`。
          enum:
            - chat.completion
          example: chat.completion
        usage:
          $ref: '#/components/schemas/CompletionUsage'
      required:
        - choices
        - created
        - id
        - model
        - object
    CreateChatCompletionStreamResponse:
      type: object
      description: >-
        表示基于提供的输入由模型返回的聊天完成响应的流式块。更多信息请参阅[流式响应指南](https://platform.openai.com/docs/guides/streaming-responses)。
      properties:
        id:
          type: string
          description: 聊天完成的唯一标识符。每个块具有相同的ID。
          example: chatcmpl-123
        choices:
          type: array
          description: >-
            聊天完成选项列表。如果`n`大于1，可以包含多个元素。如果您设置了`stream_options: {"include_usage":
            true}`，最后一个块可能为空。
          items:
            type: object
            required:
              - delta
              - finish_reason
              - index
            properties:
              delta:
                $ref: '#/components/schemas/ChatCompletionStreamResponseDelta'
              logprobs:
                description: 选项的对数概率信息。
                type: object
                nullable: true
                properties:
                  content:
                    description: 带有对数概率信息的消息内容token列表。
                    type: array
                    items:
                      $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                    nullable: true
                  refusal:
                    description: 带有对数概率信息的消息拒绝token列表。
                    type: array
                    items:
                      $ref: '#/components/schemas/ChatCompletionTokenLogprob'
                    nullable: true
                required:
                  - content
                  - refusal
              finish_reason:
                type: string
                description: >-
                  模型停止生成token的原因。如果模型遇到自然停止点或提供的停止序列，则为`stop`；如果达到请求中指定的最大token数，则为`length`；如果由于内容过滤器而省略内容，则为`content_filter`；如果模型调用了工具，则为`tool_calls`；或者如果模型调用了函数，则为`function_call`（已弃用）。
                enum:
                  - stop
                  - length
                  - tool_calls
                  - content_filter
                  - function_call
                nullable: true
              index:
                type: integer
                description: 选项在选项列表中的索引。
        created:
          type: integer
          description: 创建聊天完成的Unix时间戳（秒）。每个块具有相同的时间戳。
          example: 1677652288
        model:
          type: string
          description: 用于生成完成的模型。
          example: gpt-4
        service_tier:
          $ref: '#/components/schemas/ServiceTier'
        system_fingerprint:
          type: string
          deprecated: true
          description: 此指纹代表模型运行的后端配置。可以与请求参数`seed`结合使用，以了解可能影响确定性的后端变化。
          example: fp_44709d6fcb
        object:
          type: string
          description: 对象类型，始终为`chat.completion.chunk`。
          enum:
            - chat.completion.chunk
          example: chat.completion.chunk
        usage:
          $ref: '#/components/schemas/CompletionUsage'
          nullable: true
          description: >-
            一个可选字段，仅当您在请求中设置`stream_options: {"include_usage":
            true}`时才会出现。当出现时，除了最后一个块外，它包含一个null值，最后一个块包含整个请求的token使用统计信息。


            **注意：** 如果流被中断或取消，您可能不会收到包含请求总token使用量的最终使用块。
      required:
        - choices
        - created
        - id
        - model
        - object
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    CreateModelResponseProperties:
      allOf:
        - $ref: '#/components/schemas/ModelResponseProperties'
        - type: object
          properties:
            top_logprobs:
              description: 一个介于0和20之间的整数，指定在每个token位置返回的最可能token的数量，每个token都有相关的对数概率。
              type: integer
              minimum: 0
              maximum: 20
    ChatCompletionRequestMessage:
      anyOf:
        - $ref: '#/components/schemas/ChatCompletionRequestUserMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestDeveloperMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestSystemMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestAssistantMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestToolMessage'
        - $ref: '#/components/schemas/ChatCompletionRequestFunctionMessage'
      discriminator:
        propertyName: role
    ModelId:
      example: gpt-4o
      anyOf:
        - type: string
        - $ref: '#/components/schemas/ChatModel'
    ResponseModalities:
      type: array
      description: 指定响应中应包含的模态类型。
      items:
        type: string
        enum:
          - text
          - audio
    Verbosity:
      type: string
      enum:
        - low
        - medium
        - high
      description: 控制模型响应的详细程度。
      default: medium
    ReasoningEffort:
      anyOf:
        - type: string
          enum:
            - minimal
            - low
            - medium
            - high
          default: medium
          description: >-
            限制推理模型的推理努力程度。当前支持的值有 `minimal`、`low`、`medium` 和
            `high`。减少推理努力可以导致更快的响应和在响应中使用更少的推理token。
        - type: 'null'
    WebSearchLocation:
      type: object
      properties:
        country_code:
          type: string
          description: 两字母的ISO 3166-1国家代码。
        region_code:
          type: string
          description: 地区代码，如美国的州代码。
      required:
        - country_code
    WebSearchContextSize:
      type: string
      enum:
        - small
        - medium
        - large
      description: 控制从搜索结果中提取的上下文量。
      default: medium
    ResponseFormatText:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
          description: 指定响应格式为纯文本。
      required:
        - type
    ResponseFormatJsonSchema:
      type: object
      properties:
        type:
          type: string
          enum:
            - json_schema
          description: 指定响应格式为符合提供的JSON模式的结构化输出。
        json_schema:
          type: object
          description: 定义响应必须遵循的JSON模式。
          additionalProperties: true
        name:
          type: string
          description: 模式的名称。
        description:
          type: string
          description: 模式的描述。
        strict:
          type: boolean
          description: 是否严格验证响应符合模式。
          default: false
      required:
        - type
        - json_schema
    ResponseFormatJsonObject:
      type: object
      properties:
        type:
          type: string
          enum:
            - json_object
          description: 指定响应格式为JSON对象。
      required:
        - type
    VoiceId:
      type: string
      enum:
        - alloy
        - ash
        - ballad
        - coral
        - echo
        - fable
        - nova
        - onyx
        - sage
        - shimmer
      description: 用于音频输出的声音ID。
    StopConfiguration:
      description: |-
        最新推理模型 `o3` 和 `o4-mini` 不支持。

        最多4个序列，API将在生成这些序列时停止生成更多token。返回的文本不会包含停止序列。
      nullable: true
      anyOf:
        - type: string
          default: <|endoftext|>
          example: |+

          nullable: true
        - type: array
          minItems: 1
          maxItems: 4
          items:
            type: string
            example: '["\n"]'
    PredictionContent:
      type: object
      properties:
        type:
          type: string
          enum:
            - content
          description: 预测类型，必须是 'content'。
        content:
          type: string
          description: 预测的文本内容。
      required:
        - type
        - content
    ChatCompletionStreamOptions:
      type: object
      description: 流式聊天完成的选项。
      properties:
        include_usage:
          type: boolean
          description: 如果为true，则在流的最后一个块中包含使用情况统计信息。
          default: false
    ChatCompletionTool:
      type: object
      title: 函数工具
      properties:
        type:
          type: string
          enum:
            - function
          description: 工具的类型，必须是 'function'。
        function:
          $ref: '#/components/schemas/ChatCompletionToolFunction'
      required:
        - type
        - function
    CustomToolChatCompletions:
      type: object
      title: 自定义工具
      properties:
        type:
          type: string
          description: 自定义工具的类型。
      required:
        - type
    ChatCompletionToolChoiceOption:
      anyOf:
        - type: string
          enum:
            - auto
            - none
            - required
          description: 工具选择策略。'auto'表示模型自动决定是否使用工具，'none'表示不使用工具，'required'表示必须使用工具。
        - type: object
          title: 指定工具
          properties:
            type:
              type: string
              enum:
                - function
              description: 工具类型，必须是 'function'。
            function:
              type: object
              properties:
                name:
                  type: string
                  description: 要使用的函数名称。
              required:
                - name
          required:
            - type
            - function
    ParallelToolCalls:
      type: boolean
      default: true
      description: 是否允许模型并行调用多个工具。
    ChatCompletionFunctionCallOption:
      type: object
      properties:
        name:
          type: string
          description: 要调用的函数名称。
      required:
        - name
    ChatCompletionFunctions:
      type: object
      properties:
        name:
          type: string
          description: 函数的名称。
        description:
          type: string
          description: 函数的描述。
        parameters:
          type: object
          description: 函数参数的JSON Schema定义。
          additionalProperties: true
      required:
        - name
    ChatCompletionResponseMessage:
      type: object
      description: 由模型生成的聊天完成消息。
      properties:
        content:
          anyOf:
            - type: string
              description: 消息的内容。
            - type: 'null'
        refusal:
          anyOf:
            - type: string
              description: 模型生成的拒绝消息。
            - type: 'null'
        tool_calls:
          $ref: '#/components/schemas/ChatCompletionMessageToolCalls'
        annotations:
          type: array
          description: >-
            消息的注释，在适用时，如使用[网络搜索工具](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat)时。
          items:
            type: object
            description: 使用网络搜索时的URL引用。
            required:
              - type
              - url_citation
            properties:
              type:
                type: string
                description: URL引用的类型。始终为`url_citation`。
                enum:
                  - 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
                    description: 网络资源的URL。
                  title:
                    type: string
                    description: 网络资源的标题。
        role:
          type: string
          enum:
            - assistant
          description: 此消息作者的角色。
        function_call:
          type: object
          deprecated: true
          description: 已弃用并被`tool_calls`替代。模型生成的应调用的函数的名称和参数。
          properties:
            arguments:
              type: string
              description: >-
                用于调用函数的参数，由模型以JSON格式生成。请注意，模型并不总是生成有效的JSON，并且可能会产生您的函数模式中未定义的参数。在调用函数之前，请在代码中验证参数。
            name:
              type: string
              description: 要调用的函数的名称。
          required:
            - name
            - arguments
        audio:
          anyOf:
            - type: object
              description: >-
                如果请求了音频输出模态，此对象包含有关模型音频响应的数据。[了解更多](https://platform.openai.com/docs/guides/audio)。
              required:
                - id
                - expires_at
                - data
                - transcript
              properties:
                id:
                  type: string
                  description: 此音频响应的唯一标识符。
                expires_at:
                  type: integer
                  description: 此音频响应在服务器上不再可用于多轮对话的Unix时间戳（秒）。
                data:
                  type: string
                  description: 模型生成的Base64编码音频字节，格式为请求中指定的格式。
                transcript:
                  type: string
                  description: 模型生成的音频转录。
            - type: 'null'
      required:
        - role
        - content
        - refusal
    ChatCompletionTokenLogprob:
      type: object
      properties:
        token:
          type: string
          description: Token文本
        logprob:
          type: number
          description: Token的对数概率
        bytes:
          type: array
          items:
            type: integer
          description: Token的字节表示
        top_logprobs:
          type: array
          items:
            type: object
            properties:
              token:
                type: string
              logprob:
                type: number
              bytes:
                type: array
                items:
                  type: integer
          description: 该位置最可能的token及其对数概率
    ServiceTier:
      anyOf:
        - type: string
          description: |-
            指定用于处理请求的处理类型。
              - 如果设置为'auto'，则请求将使用项目设置中配置的服务层级进行处理。除非另有配置，否则项目将使用'default'。
              - 如果设置为'default'，则请求将使用所选模型的标准定价和性能进行处理。
              - 如果设置为'[flex](https://platform.openai.com/docs/guides/flex-processing)'或'[priority](https://openai.com/api-priority-processing/)'，则请求将使用相应的服务层级进行处理。
              - 未设置时，默认行为为'auto'。

              设置`service_tier`参数时，响应体将包含基于实际用于处理请求的处理模式的`service_tier`值。此响应值可能与参数中设置的值不同。
          enum:
            - auto
            - default
            - flex
            - scale
            - priority
          default: auto
        - 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: 使用预测输出时，预测中出现在完成中的token数量。
            audio_tokens:
              type: integer
              default: 0
              description: 模型生成的音频输入token。
            reasoning_tokens:
              type: integer
              default: 0
              description: 模型为推理生成的token。
            rejected_prediction_tokens:
              type: integer
              default: 0
              description: >-
                使用预测输出时，预测中未出现在完成中的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。
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
    ChatCompletionStreamResponseDelta:
      type: object
      description: 由流式模型响应生成的聊天完成增量。
      properties:
        content:
          anyOf:
            - type: string
              description: 块消息的内容。
            - type: 'null'
        function_call:
          deprecated: true
          type: object
          description: 已弃用并被`tool_calls`替代。模型生成的应调用的函数的名称和参数。
          properties:
            arguments:
              type: string
              description: >-
                用于调用函数的参数，由模型以JSON格式生成。请注意，模型并不总是生成有效的JSON，并且可能会产生您的函数模式中未定义的参数。在调用函数之前，请在代码中验证参数。
            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'
    Status:
      type: object
      properties:
        code:
          type: integer
          description: 错误代码
        message:
          type: string
          description: 错误消息
        details:
          type: array
          description: 错误详情
          items:
            type: object
            additionalProperties: true
    ModelResponseProperties:
      type: object
      properties:
        metadata:
          type: object
          description: 请求的元数据
          additionalProperties: true
        top_logprobs:
          anyOf:
            - description: 一个介于0和20之间的整数，指定在每个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）会使输出更加集中和确定性。
                通常建议仅调整temperature或top_p其中之一，不建议两者都修改。
            - type: 'null'
        top_p:
          anyOf:
            - type: number
              minimum: 0
              maximum: 1
              default: 1
              example: 1
              description: >-
                核采样的替代方法，称为nucleus采样，模型考虑具有top_p概率质量的token结果。例如，0.1意味着只考虑构成前10%概率质量的token。

                通常建议仅调整temperature或top_p其中之一，不建议两者都修改。
            - type: 'null'
        user:
          type: string
          example: user-1234
          deprecated: true
          description: >-
            此字段正在被safety_identifier和prompt_cache_key替代。请使用prompt_cache_key来维持缓存优化。

            用于您的终端用户的稳定标识符。用于提高缓存命中率，通过更好地分组类似请求，并帮助检测和防止滥用。
        safety_identifier:
          type: string
          example: safety-identifier-1234
          description: >-
            一个稳定的标识符，用于帮助检测可能违反使用政策的用户。ID应该是唯一标识每个用户的字符串。我们建议对用户名或电子邮件地址进行哈希处理，以避免向我们发送任何识别信息。
        prompt_cache_key:
          type: string
          example: prompt-cache-key-1234
          description: 用于缓存类似请求的响应以优化缓存命中率。替代user字段。
        service_tier:
          type: string
          enum:
            - default
            - scale
          description: 服务层级
    ChatCompletionRequestUserMessage:
      type: object
      title: 用户消息
      properties:
        role:
          type: string
          enum:
            - user
          description: 消息的角色，必须是 'user'。
          default: user
        content:
          anyOf:
            - type: string
              description: 用户消息的文本内容。
              example: 你好，请介绍一下你自己
            - type: array
              description: 包含不同内容部分的数组，可以是文本、图像等。
              items:
                anyOf:
                  - $ref: >-
                      #/components/schemas/ChatCompletionRequestMessageContentPartText
                  - $ref: >-
                      #/components/schemas/ChatCompletionRequestMessageContentPartImage
                  - $ref: >-
                      #/components/schemas/ChatCompletionRequestMessageContentPartAudio
                  - $ref: >-
                      #/components/schemas/ChatCompletionRequestMessageContentPartFile
        name:
          type: string
          description: 用户的名称。
      required:
        - role
        - content
    ChatCompletionRequestDeveloperMessage:
      title: 开发者消息
      type: object
      properties:
        role:
          type: string
          enum:
            - developer
          description: 消息的角色，必须是 'developer'。
        content:
          type: string
          description: 消息的内容。
        name:
          type: string
          description: 开发者的名称。
      required:
        - role
        - content
    ChatCompletionRequestSystemMessage:
      type: object
      title: 系统消息
      properties:
        role:
          type: string
          enum:
            - system
          description: 消息的角色，必须是 'system'。
        content:
          type: string
          description: 系统消息的内容。
        name:
          type: string
          description: 系统消息的名称。
      required:
        - role
        - content
    ChatCompletionRequestAssistantMessage:
      type: object
      title: 助手消息
      properties:
        role:
          type: string
          enum:
            - assistant
          description: 消息的角色，必须是 'assistant'。
          default: assistant
        content:
          anyOf:
            - type: string
              description: 助手消息的文本内容。
            - type: 'null'
              description: 当消息仅包含工具调用时，内容可以为null。
        name:
          type: string
          description: 助手的名称。
        tool_calls:
          type: array
          description: 助手发起的工具调用列表。
          items:
            $ref: '#/components/schemas/ChatCompletionMessageToolCall'
        function_call:
          type: object
          description: 已弃用。请使用 tool_calls 代替。
          deprecated: true
          properties:
            name:
              type: string
              description: 函数的名称。
            arguments:
              type: string
              description: 函数的参数，格式为JSON字符串。
      required:
        - role
    ChatCompletionRequestToolMessage:
      type: object
      title: 工具消息
      properties:
        role:
          type: string
          enum:
            - tool
          description: 消息的角色，必须是 'tool'。
          default: tool
        content:
          type: string
          description: 工具返回的内容。
          example: 工具返回的内容
        tool_call_id:
          type: string
          description: 此消息响应的工具调用的ID。
      required:
        - role
        - content
        - tool_call_id
    ChatCompletionRequestFunctionMessage:
      type: object
      title: 函数消息
      properties:
        role:
          type: string
          enum:
            - function
          description: 消息的角色，必须是 'function'。
          default: function
        content:
          type: string
          description: 函数返回的内容。
        name:
          type: string
          description: 函数的名称。
      required:
        - role
        - content
        - name
    ChatModel:
      type: string
      enum:
        - gpt-4o
        - gpt-4o-mini
        - gpt-4-turbo
        - gpt-4
        - gpt-3.5-turbo
        - o1-preview
        - o1-mini
      description: 可用于聊天完成的模型ID。
    ChatCompletionToolFunction:
      type: object
      properties:
        name:
          type: string
          description: 函数的名称。
        description:
          type: string
          description: 函数的描述。
        parameters:
          type: object
          description: 函数参数的JSON Schema定义。
          additionalProperties: true
      required:
        - name
    ChatCompletionMessageToolCalls:
      type: array
      description: 模型生成的工具调用，如函数调用。
      items:
        anyOf:
          - $ref: '#/components/schemas/ChatCompletionMessageToolCall'
          - $ref: '#/components/schemas/ChatCompletionMessageCustomToolCall'
        discriminator:
          propertyName: type
    ChatCompletionMessageToolCallChunk:
      type: object
      properties:
        index:
          type: integer
        id:
          type: string
          description: 工具调用的ID。
        type:
          type: string
          enum:
            - function
          description: 工具的类型。目前，仅支持`function`。
        function:
          type: object
          properties:
            name:
              type: string
              description: 要调用的函数的名称。
            arguments:
              type: string
              description: >-
                用于调用函数的参数，由模型以JSON格式生成。请注意，模型并不总是生成有效的JSON，并且可能会产生您的函数模式中未定义的参数。在调用函数之前，请在代码中验证参数。
      required:
        - index
    ChatCompletionRequestMessageContentPartText:
      type: object
      title: 文本内容部分
      description: 文本输入部分。
      properties:
        type:
          type: string
          enum:
            - text
          description: 内容部分的类型，始终为 `text`。
          default: text
        text:
          type: string
          description: 文本内容。
      required:
        - type
        - text
    ChatCompletionRequestMessageContentPartImage:
      type: object
      title: 图像内容部分
      description: 图像输入部分。
      properties:
        type:
          type: string
          enum:
            - image_url
          description: 内容部分的类型。
          default: image_url
        image_url:
          type: object
          properties:
            url:
              type: string
              description: 图像的URL或Base64编码的图像数据。
              format: uri
            detail:
              type: string
              description: 指定图像的详细级别。
              enum:
                - auto
                - low
                - high
              default: auto
          required:
            - url
      required:
        - type
        - image_url
    ChatCompletionRequestMessageContentPartAudio:
      type: object
      title: 音频内容部分
      description: 音频输入部分。
      properties:
        type:
          type: string
          enum:
            - input_audio
          description: 内容部分的类型，始终为 `input_audio`。
          default: input_audio
        input_audio:
          type: object
          properties:
            data:
              type: string
              description: Base64编码的音频数据。
            format:
              type: string
              enum:
                - wav
                - mp3
              description: 编码音频数据的格式。目前支持"wav"和"mp3"。
          required:
            - data
            - format
      required:
        - type
        - input_audio
    ChatCompletionRequestMessageContentPartFile:
      type: object
      title: 文件内容部分
      description: 文件输入部分。
      properties:
        type:
          type: string
          enum:
            - file
          description: 内容部分的类型，始终为 `file`。
          default: file
        file:
          type: object
          properties:
            filename:
              type: string
              description: 文件的名称，用于将文件作为字符串传递给模型时使用。
            file_data:
              type: string
              description: Base64编码的文件数据，用于将文件作为字符串传递给模型时使用。
            file_id:
              type: string
              description: 要用作输入的已上传文件的ID。
      required:
        - type
        - file
    ChatCompletionMessageToolCall:
      type: object
      title: 函数工具调用
      description: 模型创建的函数工具调用。
      properties:
        id:
          type: string
          description: 工具调用的ID。
        type:
          type: string
          enum:
            - function
          description: 工具的类型。目前，仅支持`function`。
        function:
          type: object
          description: 模型调用的函数。
          properties:
            name:
              type: string
              description: 要调用的函数的名称。
            arguments:
              type: string
              description: >-
                用于调用函数的参数，由模型以JSON格式生成。请注意，模型并不总是生成有效的JSON，并且可能会产生您的函数模式中未定义的参数。在调用函数之前，请在代码中验证参数。
          required:
            - name
            - arguments
      required:
        - id
        - type
        - function
    ChatCompletionMessageCustomToolCall:
      type: object
      title: 自定义工具调用
      description: 模型创建的自定义工具调用。
      properties:
        id:
          type: string
          description: 工具调用的ID。
        type:
          type: string
          enum:
            - custom
          description: 工具的类型。始终为`custom`。
        custom:
          type: object
          description: 模型调用的自定义工具。
          properties:
            name:
              type: string
              description: 要调用的自定义工具的名称。
            input:
              type: string
              description: 模型生成的自定义工具调用的输入。
          required:
            - name
            - input
      required:
        - id
        - type
        - custom
  securitySchemes:
    OpenAIAuth:
      type: http
      scheme: bearer
      description: >-
        OpenAI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为 `Bearer
        {API_KEY}`

````