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

# OpenAI Chat Format

> 根据对话历史创建模型响应。支持流式和非流式响应。

兼容 OpenAI Chat Completions API。




## OpenAPI

````yaml post /v1/chat/completions
openapi: 3.1.0
info:
  title: UToken API
  version: 1.0.0
  description: Complete UToken API Reference Documentation
servers:
  - url: https://utoken.yoostudio.ai
    description: Production
security: []
tags:
  - name: Images / Native Gemini Format
  - name: Images / Native OpenAI Format
  - name: Images / Qwen OpenAI Compatible Format
  - name: Realtime Voice
  - name: Content Moderation
  - name: Text Embeddings
  - name: Unimplemented / Fine-tuning
  - name: Unimplemented / File Management
  - name: Models / List Models
  - name: Chat Completions
  - name: Chat Completions / Native Gemini Format
  - name: Chat Completions / Native OpenAI Format
  - name: Text Completions
  - name: Video Generation
  - name: Video Generation / Sora Format
  - name: Video Generation / Jimeng (Dreamina) Format
  - name: Video Generation / Kling AI Format
  - name: Document Reranking
  - name: Audio Processing
  - name: Audio Processing / Native OpenAI Format
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions / Native OpenAI Format
      summary: Chat Completions Format
      description: >
        Creates model responses based on conversation history. Supports both
        streaming and non-streaming responses.


        Compatible with the OpenAI Chat Completions API.
      operationId: createchatcompletion
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  type: string
                  description: Model ID
                  examples:
                    - gpt-4
                messages:
                  type: array
                  items:
                    type: object
                    required:
                      - role
                      - content
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                          - developer
                        description: Message Role
                      content:
                        oneOf:
                          - type: string
                          - type: array
                            items:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                    - image_url
                                    - input_audio
                                    - file
                                    - video_url
                                text:
                                  type: string
                                image_url:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                      description: Image URL or base64 encoded data
                                    detail:
                                      type: string
                                      enum:
                                        - low
                                        - high
                                        - auto
                                  x-apifox-orders:
                                    - url
                                    - detail
                                input_audio:
                                  type: object
                                  properties:
                                    data:
                                      type: string
                                      description: Base64 encoded audio data
                                    format:
                                      type: string
                                      enum:
                                        - wav
                                        - mp3
                                  x-apifox-orders:
                                    - data
                                    - format
                                file:
                                  type: object
                                  properties:
                                    filename:
                                      type: string
                                    file_data:
                                      type: string
                                    file_id:
                                      type: string
                                  x-apifox-orders:
                                    - filename
                                    - file_data
                                    - file_id
                                video_url:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                  x-apifox-orders:
                                    - url
                              x-apifox-orders:
                                - type
                                - text
                                - image_url
                                - input_audio
                                - file
                                - video_url
                        description: Message Content
                      name:
                        type: string
                        description: Sender Name
                      tool_calls:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                            type:
                              type: string
                              examples:
                                - function
                            function:
                              type: object
                              properties:
                                name:
                                  type: string
                                arguments:
                                  type: string
                              x-apifox-orders:
                                - name
                                - arguments
                          x-apifox-orders:
                            - id
                            - type
                            - function
                      tool_call_id:
                        type: string
                        description: Tool Call ID (for tool role messages)
                      reasoning_content:
                        type: string
                        description: Reasoning Content
                    x-apifox-orders:
                      - role
                      - content
                      - name
                      - tool_calls
                      - tool_call_id
                      - reasoning_content
                  description: List of conversation messages
                temperature:
                  type: number
                  minimum: 0
                  maximum: 2
                  default: 1
                  description: Sampling Temperature
                top_p:
                  type: number
                  minimum: 0
                  maximum: 1
                  default: 1
                  description: Nucleus sampling parameter (top_p)
                'n':
                  type: integer
                  minimum: 1
                  default: 1
                  description: Number of completions to generate
                stream:
                  type: boolean
                  default: false
                  description: Enable streaming response
                stream_options:
                  type: object
                  properties:
                    include_usage:
                      type: boolean
                  x-apifox-orders:
                    - include_usage
                stop:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: Stop sequences
                max_tokens:
                  type: integer
                  description: Maximum tokens for generation
                max_completion_tokens:
                  type: integer
                  description: Maximum tokens for completion
                presence_penalty:
                  type: number
                  minimum: -2
                  maximum: 2
                  default: 0
                frequency_penalty:
                  type: number
                  minimum: -2
                  maximum: 2
                  default: 0
                logit_bias:
                  type: object
                  additionalProperties:
                    type: number
                  properties: {}
                  x-apifox-orders: []
                user:
                  type: string
                tools:
                  type: array
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        examples:
                          - function
                      function:
                        type: object
                        properties:
                          name:
                            type: string
                          description:
                            type: string
                          parameters:
                            type: object
                            description: Parameter definition in JSON Schema format
                            properties: {}
                            x-apifox-orders: []
                        x-apifox-orders:
                          - name
                          - description
                          - parameters
                    x-apifox-orders:
                      - type
                      - function
                tool_choice:
                  oneOf:
                    - type: string
                      enum:
                        - none
                        - auto
                        - required
                    - type: object
                      properties:
                        type:
                          type: string
                        function:
                          type: object
                          properties:
                            name:
                              type: string
                          x-apifox-orders:
                            - name
                      x-apifox-orders:
                        - type
                        - function
                response_format:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - text
                        - json_object
                        - json_schema
                    json_schema:
                      type: object
                      description: JSON Schema definition
                      properties: {}
                      x-apifox-orders: []
                  x-apifox-orders:
                    - type
                    - json_schema
                seed:
                  type: integer
                reasoning_effort:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                  description: Reasoning effort level (for reasoning-capable models)
                modalities:
                  type: array
                  items:
                    type: string
                    enum:
                      - text
                      - audio
                audio:
                  type: object
                  properties:
                    voice:
                      type: string
                    format:
                      type: string
                  x-apifox-orders:
                    - voice
                    - format
              x-apifox-orders:
                - model
                - messages
                - temperature
                - top_p
                - 'n'
                - stream
                - stream_options
                - stop
                - max_tokens
                - max_completion_tokens
                - presence_penalty
                - frequency_penalty
                - logit_bias
                - user
                - tools
                - tool_choice
                - response_format
                - seed
                - reasoning_effort
                - modalities
                - audio
      responses:
        '200':
          description: Response created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                    examples:
                      - chat.completion
                  created:
                    type: integer
                  model:
                    type: string
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        message:
                          type: object
                          required:
                            - role
                            - content
                          properties:
                            role:
                              type: string
                              enum:
                                - system
                                - user
                                - assistant
                                - tool
                                - developer
                              description: Message Role
                            content:
                              oneOf:
                                - type: string
                                - type: array
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - text
                                          - image_url
                                          - input_audio
                                          - file
                                          - video_url
                                      text:
                                        type: string
                                      image_url:
                                        type: object
                                        properties:
                                          url:
                                            type: string
                                            description: Image URL or base64 encoded data
                                          detail:
                                            type: string
                                            enum:
                                              - low
                                              - high
                                              - auto
                                        x-apifox-orders:
                                          - url
                                          - detail
                                      input_audio:
                                        type: object
                                        properties:
                                          data:
                                            type: string
                                            description: Base64 encoded audio data
                                          format:
                                            type: string
                                            enum:
                                              - wav
                                              - mp3
                                        x-apifox-orders:
                                          - data
                                          - format
                                      file:
                                        type: object
                                        properties:
                                          filename:
                                            type: string
                                          file_data:
                                            type: string
                                          file_id:
                                            type: string
                                        x-apifox-orders:
                                          - filename
                                          - file_data
                                          - file_id
                                      video_url:
                                        type: object
                                        properties:
                                          url:
                                            type: string
                                        x-apifox-orders:
                                          - url
                                    x-apifox-orders:
                                      - type
                                      - text
                                      - image_url
                                      - input_audio
                                      - file
                                      - video_url
                              description: Message Content
                            name:
                              type: string
                              description: Sender Name
                            tool_calls:
                              type: array
                              items:
                                type: object
                                properties:
                                  id:
                                    type: string
                                  type:
                                    type: string
                                    examples:
                                      - function
                                  function:
                                    type: object
                                    properties:
                                      name:
                                        type: string
                                      arguments:
                                        type: string
                                    x-apifox-orders:
                                      - name
                                      - arguments
                                x-apifox-orders:
                                  - id
                                  - type
                                  - function
                            tool_call_id:
                              type: string
                              description: Tool Call ID (for tool role messages)
                            reasoning_content:
                              type: string
                              description: Reasoning Content
                          x-apifox-orders:
                            - role
                            - content
                            - name
                            - tool_calls
                            - tool_call_id
                            - reasoning_content
                        finish_reason:
                          type: string
                          enum:
                            - stop
                            - length
                            - tool_calls
                            - content_filter
                      x-apifox-orders:
                        - index
                        - message
                        - finish_reason
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                        description: Prompt tokens
                      completion_tokens:
                        type: integer
                        description: Completion tokens
                      total_tokens:
                        type: integer
                        description: Total tokens
                      prompt_tokens_details:
                        type: object
                        properties:
                          cached_tokens:
                            type: integer
                          text_tokens:
                            type: integer
                          audio_tokens:
                            type: integer
                          image_tokens:
                            type: integer
                        x-apifox-orders:
                          - cached_tokens
                          - text_tokens
                          - audio_tokens
                          - image_tokens
                      completion_tokens_details:
                        type: object
                        properties:
                          text_tokens:
                            type: integer
                          audio_tokens:
                            type: integer
                          reasoning_tokens:
                            type: integer
                        x-apifox-orders:
                          - text_tokens
                          - audio_tokens
                          - reasoning_tokens
                    x-apifox-orders:
                      - prompt_tokens
                      - completion_tokens
                      - total_tokens
                      - prompt_tokens_details
                      - completion_tokens_details
                  system_fingerprint:
                    type: string
                x-apifox-orders:
                  - id
                  - object
                  - created
                  - model
                  - choices
                  - usage
                  - system_fingerprint
        '400':
          description: Request parameter error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: Error message
                      type:
                        type: string
                        description: Error type
                      param:
                        type:
                          - string
                          - 'null'
                        description: Related parameters
                      code:
                        type:
                          - string
                          - 'null'
                        description: Error code
                    x-apifox-orders:
                      - message
                      - type
                      - param
                      - code
                x-apifox-orders:
                  - error
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                        description: Error message
                      type:
                        type: string
                        description: Error type
                      param:
                        type:
                          - string
                          - 'null'
                        description: Related parameters
                      code:
                        type:
                          - string
                          - 'null'
                        description: Error code
                    x-apifox-orders:
                      - message
                      - type
                      - param
                      - code
                x-apifox-orders:
                  - error
      security:
        - BearerAuth: []
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |-
        Use Bearer Token authentication
        Format: Authorization: Bearer sk-xxxxxx

````