openapi: 3.0.0
info:
  title: Universal Chat API
  version: 1.0.0
servers:
  - url: https://api.openai.com/v1
paths:
  /openai/deployments/{Deployment_Name}/chat/completions/{api_version}:
    post:
      security:
        - ApiKeyAuth: []
      parameters:
        - in: path
          name: api_version
          schema:
            type: string
          required: true
          description: The API version to use for this operation. This follows the YYYY-MM-DD format.
          example: '2023-03-15'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: ID of the model to use.
                messages:
                  type: array
                  minItems: 1
                  description: A list of messages comprising the conversation so far.
                  items:
                    $ref: '#/components/schemas/Message'
                functions:
                  type: array
                  items:
                    $ref: '#/components/schemas/Function'
                  description: A list of functions the assistant may generate JSON inputs for.
                function_call:
                  description: 'Controls how the assistant responds to function calls. "none" means the assistant does not call a function, and responds to the end-user. "auto" means the assistant can pick between an end-user or calling a function. Specifying a particular function via `{"name": "my_function"}` forces the assistant to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present.'
                  oneOf:
                    - type: string
                      enum:
                        - none
                        - auto
                    - type: object
                      properties:
                        name:
                          type: string
                          description: The name of the function to call.
                      required: [name]
                addons:
                  type: array
                  items:
                    $ref: '#/components/schemas/Addon'
                  description: A list of addons the assistant may use.
                stream:
                  type: boolean
                  description: 'If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message'
                  default: false
                temperature:
                  type: number
                  description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
                  minimum: 0
                  maximum: 2
                  default: 1
                top_p:
                  type: number
                  description: An alternative to sampling with temperature, called nucleus sampling, where the assistant considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
                  minimum: 0
                  maximum: 1
                  default: 1
                'n':
                  type: integer
                  description: How many chat completion choices to generate for each input message.
                  minimum: 1
                  maximum: 128
                  default: 1
                stop:
                  oneOf:
                    - type: string
                      nullable: true
                    - type: array
                      minItems: 1
                      maxItems: 4
                      items:
                        type: string
                  description: Up to 4 sequences where the assistant will stop generating further tokens.
                max_tokens:
                  type: integer
                  description: The maximum number of tokens to generate by the assistant.
                  default: infinity
                presence_penalty:
                  type: number
                  description: Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
                  minimum: -2
                  maximum: 2
                  default: 0
                frequency_penalty:
                  type: number
                  description: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
                  minimum: -2
                  maximum: 2
                  default: 0
                logit_bias:
                  type: object
                  additionalProperties: true
                  description: |-
                    Modify the likelihood of specified tokens appearing in the completion.

                    Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
                  default: null
                user:
                  type: string
                  description: A unique identifier representing end-user.
              required:
                - messages
            examples:
              GPT World:
                value:
                  messages:
                    - role: user
                      content: What is chat gpt?
              GPT World Streaming:
                value:
                  stream: true
                  messages:
                    - role: user
                      content: What is chat gpt?
              Weather-forecast Addon:
                value:
                  model: gpt-4
                  messages:
                    - role: user
                      content: Temperature tomorrow in New York?
                  addons:
                    - name: weather-forecast
              Bing Search:
                value:
                  messages:
                    - role: user
                      content: Find something in bing
              IMF Demo. The first user message:
                value:
                  messages:
                    - role: user
                      content: Give me NGDP indicator for Poland
              IMF Demo. Control activation:
                value:
                  messages:
                    - role: user
                      content: Give me NGDP indicator for Poland
                    - role: assistant
                      content: |-
                        I see that you already have the NGDP indicator for Poland in your current data state. Here's the updated form based on your request:

                        Form: Query Params { Period: [2000, 2022] Country: 964 Indicator: NGDP Frequency: A }

                        Is there anything else you'd like to change or add?
                    - role: user
                      custom_content:
                        completed_control:
                          label: Get Data
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
              examples:
                GPT World:
                  value:
                    id: 1d84aa54-e476-405d-9713-386bdfc85993
                    object: chat.completion
                    created: '1687222194'
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: ChatGPT is an advanced conversational AI model built on the GPT-3.5 architecture. It is a Large Language Model (LLM) that can engage in context-aware, human-like interactions. It is a suitable testbed for creativity and has demonstrated remarkable capabilities in understanding and generating human-like text. It heavily relies on in-context examples and has a strong bias toward using or not using certain tools.
                          custom_content:
                            attachments:
                              - index: 0
                                type: text/plain
                                title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                              - index: 1
                                type: text/plain
                                title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                              - index: 2
                                type: text/plain
                                title: 'HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face'
                                data: By leveraging the strong language capability of ChatGPT and abundant AI models in Hugging Face, HuggingGPT is able to cover numerous sophisticated AI tasks in different modalities and domains and achieve impressive results in language, vision, speech, and other challenging tasks, which paves a new way towards advanced artiﬁcial intelligence 2.
                                reference_url: https://arxiv.org/abs/2303.17580
                            stages:
                              - index: 0
                                name: Paraphrasing
                                content: '**New phrase:** What is chat gpt?'
                                status: completed
                              - index: 1
                                name: Search for relevant documents
                                attachments:
                                  - index: 0
                                    type: text/plain
                                    title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                    data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                    reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                  - index: 1
                                    type: text/plain
                                    title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                    data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                    reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                  - index: 2
                                    type: text/plain
                                    title: 'HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face'
                                    data: By leveraging the strong language capability of ChatGPT and abundant AI models in Hugging Face, HuggingGPT is able to cover numerous sophisticated AI tasks in different modalities and domains and achieve impressive results in language, vision, speech, and other challenging tasks, which paves a new way towards advanced artiﬁcial intelligence 2.
                                    reference_url: https://arxiv.org/abs/2303.17580
                                status: completed
                        finish_reason: stop
                    statistics:
                      usage_per_model:
                        - name: text-embedding-ada-002
                          prompt_tokens: '23'
                          total_tokens: '23'
                        - name: gpt-4
                          prompt_tokens: '123'
                          completion_tokens: '17'
                          total_tokens: '140'
                Weather-forecast Addon:
                  value:
                    id: 1d84aa54-e476-405d-9713-386bdfc85993
                    object: chat.completion
                    created: '1687222194'
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: |-
                            The weather forecast for tomorrow, June 21, 2023, in New York is as follows:
                            01:00: Overcast clouds, temperature 20.59°C, feels like 20.3°C, humidity 61%, wind speed 4.97 m/s
                            22:00: Light rain, temperature 19.11°C, feels like 18.64°C, humidity 60%, wind speed 6.68 m/s
                          custom_content:
                            stages:
                              - index: 0
                                name: Weather forecast
                                content: |-
                                  ##### Addon request:
                                  `weather-forecast("New York", "2023-06-21")`
                                  ##### Addon response:
                                  Date & Time: 2023-06-21 01:00:00
                                  Weather Description: overcast clouds
                                  Temperature: 293.74 K
                                  Feels Like: 293.45 K
                                  Humidity: 61 %
                                  Wind Speed: 4.97 m/s

                                  Date & Time: 2023-06-21 04:00:00
                                  Weather Description: overcast clouds
                                  Temperature: 292.64 K
                                  Feels Like: 292.26 K
                                  Humidity: 62 %
                                  Wind Speed: 4.37 m/s
                                status: completed
                        finish_reason: stop
                    usage:
                      prompt_tokens: 0
                      completion_tokens: 0
                      total_tokens: 0
                Bing Search:
                  value:
                    id: 1d84aa54-e476-405d-9713-386bdfc85993
                    object: chat.completion
                    created: '1687222194'
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: I found some breaking news on CNN regarding a missing Titanic submersible. The submersible reportedly has about 40 hours of air left, and efforts to locate the vessel have not yet been successful. The sub, which disappeared on Sunday, has five people on board. The Coast Guard is uncertain if they have enough time to rescue those onboard before the oxygen runs out. The five members aboard the submersible include a Pakistani billionaire father and son, a British explorer, a French diver, and the CEO of the company that operates the submersible.
                          custom_content:
                            stages:
                              - index: 0
                                name: Browsing
                                content: I found some breaking news on CNN regarding a missing Titanic submersible. The submersible reportedly has about 40 hours of air left, and efforts to locate the vessel have not yet been successful. The sub, which disappeared on Sunday, has five people on board. The Coast Guard is uncertain if they have enough time to rescue those onboard before the oxygen runs out. The five members aboard the submersible include a Pakistani billionaire father and son, a British explorer, a French diver, and the CEO of the company that operates the submersible.
                                attachments:
                                  - index: 0
                                    title: Searched Bing
                                    data: 'Searched Bing: "[latest news](https://www.bing.com/search?q=latest%20news)"'
                                    reference_url: https://www.bing.com/search?q=latest%20news
                                  - index: 1
                                    title: Clicked on
                                    data: 'Clicked on: "[edition.cnn.com](https://edition.cnn.com/)"'
                                    reference_url: https://edition.cnn.com/
                                  - index: 2
                                    title: Reading content
                                    data: Reading content
                                  - index: 3
                                    title: Finished browsing
                                    data: Finished browsing
                                status: completed
                        finish_reason: stop
                    usage:
                      prompt_tokens: 0
                      completion_tokens: 0
                      total_tokens: 0
                IMF Demo. The first user message:
                  value:
                    id: 1d84aa54-e476-405d-9713-386bdfc85993
                    object: chat.completion
                    created: '1687222194'
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: |-
                            I see that you already have the NGDP indicator for Poland in your current data state. Here's the updated form based on your request:

                            Form: Query Params { Period: [2000, 2022] Country: 964 Indicator: NGDP Frequency: A }

                            Is there anything else you'd like to change or add?
                          custom_content:
                            controls:
                              - index: 0
                                label: Get Data
                        finish_reason: stop
                    usage:
                      prompt_tokens: 0
                      completion_tokens: 0
                      total_tokens: 0
                IMF Demo. Control activation:
                  value:
                    id: 1d84aa54-e476-405d-9713-386bdfc85993
                    object: chat.completion
                    created: '1687222194'
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: ''
                          custom_content:
                            attachments:
                              - index: 0
                                title: Gross domestic product, current prices
                                type: image/png
                                url: https://_.com/72153376-0fca-11ee-be56-0242ac120002.png
                              - index: 1
                                title: Excel input
                                data: |-
                                  |   | DATA_CODE | SERIES_CODE |
                                  | - | --------- | ----------- |
                                  | 0 | WEO       | 964.NGDP.A  |
                              - index: 2
                                title: SDMX URL
                                data: SDMX
                                reference_url: https://apim-imfeid-dev-01.azure-api.net/uatsdmx/api/v1/workspaces/default:StatGPT/registry/sdmx/2.1/data/WEO/964.NGDP.A?startPeriod=2000&endPeriod=2022
                              - index: 3
                                title: Code snippet
                                data: |-
                                  ```python
                                  provider = sdmx.Request('IMF_RES')
                                      data_msg = provider.data('WEO', key={'FREQUENCY': ['A'], 'COUNTRY': ['964', '964'], 'INDICATOR': ['NGDP', 'NGDP']}, params={'startPeriod': '2000', 'endPeriod': '2022'})```
                        finish_reason: stop
                    usage:
                      prompt_tokens: 0
                      completion_tokens: 0
                      total_tokens: 0
            text/event-stream:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/StreamResponse'
              examples:
                GPT World Streaming:
                  value:
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            role: assistant
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 0
                                  name: Paraphrasing
                                  status: null
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 0
                                  content: '**New phrase:**'
                                  status: null
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 0
                                  content: ' What is chat gpt?'
                                  status: completed
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 1
                                  name: Search for relevant documents
                                  status: null
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 1
                                  attachments:
                                    - index: 0
                                      type: text/plain
                                      title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                      data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                      reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                    - index: 1
                                      type: text/plain
                                      title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                      data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                      reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                  status: null
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              stages:
                                - index: 1
                                  attachments:
                                    - index: 2
                                      type: text/plain
                                      title: 'HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face'
                                      data: By leveraging the strong language capability of ChatGPT and abundant AI models in Hugging Face, HuggingGPT is able to cover numerous sophisticated AI tasks in different modalities and domains and achieve impressive results in language, vision, speech, and other challenging tasks, which paves a new way towards advanced artiﬁcial intelligence 2.
                                      reference_url: https://arxiv.org/abs/2303.17580
                                  status: completed
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222194'
                      choices:
                        - index: 0
                          delta:
                            content: ChatGPT is an advanced conversational AI model built on the GPT-3.5 architecture.
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222195'
                      choices:
                        - index: 0
                          delta:
                            content: ' It is a Large Language Model (LLM) that can engage in context-aware, human-like interactions. It is a suitable testbed for creativity and has demonstrated remarkable capabilities in understanding and generating human-like text. It heavily relies on in-context examples and has a strong bias toward using or not using certain tools.'
                          finish_reason: null
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222195'
                      choices:
                        - index: 0
                          delta:
                            custom_content:
                              attachments:
                                - index: 0
                                  type: text/plain
                                  title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                  data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                  reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                - index: 1
                                  type: text/plain
                                  title: 'GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo'
                                  data: This preliminary technical report describes the development of GPT4All, a chatbot trained over a massive curated corpus of assistant in- teractions including word problems, story de- scriptions, multi-turn dialogue, and code. We openly release the collected data, data cura- tion procedure, training code, and final model weights to promote open research and repro- ducibility. Additionally, we release quantized 4-bit versions of the model allowing virtually anyone to run the model on CPU.
                                  reference_url: https://s3.amazonaws.com/static.nomic.ai/gpt4all/2023_GPT4All_Technical_Report.pdf
                                - index: 2
                                  type: text/plain
                                  title: 'HuggingGPT: Solving AI Tasks with ChatGPT and its Friends in Hugging Face'
                                  data: By leveraging the strong language capability of ChatGPT and abundant AI models in Hugging Face, HuggingGPT is able to cover numerous sophisticated AI tasks in different modalities and domains and achieve impressive results in language, vision, speech, and other challenging tasks, which paves a new way towards advanced artiﬁcial intelligence 2.
                                  reference_url: https://arxiv.org/abs/2303.17580
                          finish_reason: stop
                    - id: 1d84aa54-e476-405d-9713-386bdfc85993
                      object: chat.completion.chunk
                      created: '1687222196'
                      statistics:
                        usage_per_model:
                          - index: 0
                            name: text-embedding-ada-002
                            prompt_tokens: 23
                            total_tokens: 23
                          - index: 1
                            name: gpt-4
                            prompt_tokens: 123
                            completion_tokens: 17
                            total_tokens: 140
        '401':
          description: Invalid Authentication
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit reached
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    $ref: '#/components/schemas/Error'
        '500':
          description: The server had an error while processing your request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    $ref: '#/components/schemas/Error'
        '503':
          description: The engine is currently overloaded, please try again later
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    $ref: '#/components/schemas/Error'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key
      description: |-
        All API requests must include the API key in the `Api-Key` HTTP header as follows:
        ```bash
        Api-Key: DIAL_API_KEY
        ```
  schemas:
    FunctionCall:
      type: object
      description: |-
        The name and arguments of a function that should be called, as generated by the assistant.

        Only the `assistant` can set this field.
      properties:
        name:
          type: string
          description: The name of the function that the assistant decided to call.
        arguments:
          type: string
          description: The arguments for the function in JSON format.
    ResponseFunctionCall:
      type: object
      description: The name and arguments of a function that should be called, as generated by the assistant.
      properties:
        name:
          type: string
          description: The name of the function that the assistant decided to call.
        arguments:
          type: string
          description: The arguments for the function in JSON format.
    Function:
      type: object
      properties:
        name:
          type: string
          description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
        description:
          type: string
          description: The description of what the function does.
        parameters:
          type: object
          description: The parameters the functions accepts, described as a JSON Schema object.
      required:
        - name
    Addon:
      oneOf:
        - type: object
          properties:
            name:
              type: string
              description: The name of the system addon.
        - type: object
          properties:
            url:
              type: string
              description: The url to open ai plugin schema.
    Message:
      type: object
      description: The assistant message.
      properties:
        role:
          type: string
          description: The role of the messages author. One of `system`, `user`, `assistant` or `function`.
        content:
          type: string
          description: The contents of the message. `content` is required for all messages except `assistant` messages with function calls or `user` messages with control.
        custom_content:
          $ref: '#/components/schemas/CustomContent'
        name:
          type: string
          writeOnly: true
          description: |-
            The name of the author of this message.

            `name` is required if `role` is _function_, and it should be the name of the function whose response is in the content. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
        function_call:
          type: object
          writeOnly: true
          $ref: '#/components/schemas/FunctionCall'
      required:
        - role
    ResponseMessage:
      type: object
      description: The assistant message.
      properties:
        role:
          type: string
          description: The role of the messages author. Always is `assistant` for response.
        content:
          type: string
          description: The contents of the message. `content` is set for all messages except messages with function calls.
        custom_content:
          $ref: '#/components/schemas/ResponseCustomContent'
        function_call:
          type: object
          writeOnly: true
          $ref: '#/components/schemas/ResponseFunctionCall'
      required:
        - role
    Delta:
      type: object
      description: Description of new content of the message.
      properties:
        role:
          type: string
          description: The role of the messages author. Always is `assistant` for response.
        content:
          type: string
          description: The contents of the message.
        custom_content:
          $ref: '#/components/schemas/ResponseCustomContent'
        function_call:
          $ref: '#/components/schemas/ResponseFunctionCall'
    CustomContent:
      type: object
      description: |-
        The custom content of the message.

        - For `assistant`, the field should save `state` passed by the `assistant` in the response.

        - For `user`, only `attachments` and `completed_control` can be set.

        - For `system`, the field is not available.
      properties:
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
          description: List of attachments. The field can be used by the `assistant` to attach additional output and by the `user` to attach additional input.
        completed_control:
          $ref: '#/components/schemas/CompletedControl'
        state:
          type: object
          additionalProperties: true
          description: |-
            The internal state of the assistant. This field can have an arbitrary set of fields with an arbitrary structure.

            Only `assistant` message can contain `state` field.
    ResponseCustomContent:
      type: object
      description: The custom content of the message.
      properties:
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/ResponseAttachment'
          description: List of attachments.
        controls:
          type: array
          items:
            $ref: '#/components/schemas/Control'
          description: List of controls. These are suggested controls to user.
        stages:
          type: array
          readOnly: true
          items:
            $ref: '#/components/schemas/Stage'
          description: Intermediate stages the assistant did to get the response.
        state:
          type: object
          additionalProperties: true
          description: The internal state of the assistant. This field can have an arbitrary set of fields with an arbitrary structure. In case of streaming, the state is published fully in one chunk.
    Attachment:
      type: object
      properties:
        type:
          type: string
          default: text/markdown
          description: The content type of the attachment. Should be one of the MIME types.
        title:
          type: string
          description: The title of the attachment.
        data:
          type: string
          description: |-
            Should follow the format described in the MIME standard for `type`.

            It is **required** that the attachment has exactly one of the following fields: `data` or `url` (never both).
        url:
          type: string
          description: |-
            The content of `url` should follow the format described in the MIME standard for `type`.

            It is **required** that the attachment has exactly one of the following fields: `data` or `url` (never both).
        reference_type:
          type: string
          description: The content type of `reference_url`. Should be one of the MIME types.
        reference_url:
          type: string
          description: If `reference_type` is specified, the content of `reference_url` should follow the format described in the MIME standart for `reference_type`.
      required:
        - index
    ResponseAttachment:
      type: object
      properties:
        index:
          type: integer
          description: All attachments of the message must have unique index. The first attachment must have index 0, each subsequent one should set an index that is one greater than the previous one.
        type:
          type: string
          default: text/markdown
          description: The content type of the attachment. Should be one of the MIME types.
        title:
          type: string
          description: The title of the attachment.
        data:
          type: string
          description: |-
            Should follow the format described in the MIME standard for `type`.

            It is **required** that the attachment has exactly one of the following fields: `data` or `url` (never both).
        url:
          type: string
          description: |-
            The content of `url` should follow the format described in the MIME standard for `type`.

            It is **required** that the attachment has exactly one of the following fields: `data` or `url` (never both).
        reference_type:
          type: string
          description: The content type of `reference_url`. Should be one of the MIME types.
        reference_url:
          type: string
          description: If `reference_type` is specified, the content of `reference_url` should follow the format described in the MIME standart for `reference_type`.
      required:
        - index
    Control:
      type: object
      properties:
        index:
          type: integer
          description: All controls of the message must have unique index. The first control must have index 0, each subsequent one should set an index that is one greater than the previous one.
        label:
          type: string
          description: The label of the control element.
        schema:
          type: object
          description: Schema of the control defined using JSON Schema.
      required:
        - index
        - label
    CompletedControl:
      type: object
      description: The completed control. The control should be selected from the set of controls from the last assistant response.
      properties:
        label:
          type: string
          description: The label of the control element.
        value:
          type: object
          description: Should follow the schema described in the related control.
      required:
        - label
    Stage:
      type: object
      properties:
        index:
          type: integer
          description: All stages of the message must have unique index. The first stage must have index 0, each subsequent one should set an index that is one greater than the previous one.
        name:
          type: string
          description: The name of the stage.
        content:
          type: string
          description: The contents of the stage.
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/ResponseAttachment'
          description: List of attachments to the stage.
        status:
          type: string
          nullable: true
          description: |-
            The status of execution of the stage. The possible statuses:

            | Status | Description |
            | - | - |
            | `null` | The stage is in progress |
            | completed | The stage is completed |
             | failed | The stage is failed |
      required:
        - index
        - name
        - status
    Response:
      type: object
      properties:
        id:
          type: string
          description: The ID of the response.
        object:
          type: string
          description: Object type. Always is "chat.completion" for non-streaming.
        created:
          type: integer
          description: The response timestamp. The time in seconds since the epoch.
        choices:
          type: array
          description: List of generated messages. Contains _n_ items.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the choice from _0_ to _n - 1_
              message:
                type: object
                $ref: '#/components/schemas/ResponseMessage'
              finish_reason:
                type: string
                nullable: true
                description: |-
                  The finish reason of generation of the choice. The possible reasons:

                  | Reason | Description|
                  | - | - |
                  | `null` | The generation is in progress |
                  | stop | Successful generation |
                  | length | The generation was stopped due to exceeding the available number of tokens |
                  |function_call|The assistant decided to call a function|
                  |content_filter|Omitted content due to a flag from content filters|
            required:
              - index
              - message
              - finish_reason
        usage:
          type: object
          description: The field contains information about used models tokens for generation of the response.
          properties:
            prompt_tokens:
              type: integer
              description: The number of tokens in the request to the model.
            completion_tokens:
              type: integer
              description: The number of tokens in the response from the model.
            total_tokens:
              type: integer
              description: The sum of prompt and completion tokens.
        statistics:
          type: object
          $ref: '#/components/schemas/Statistics'
    Statistics:
      type: object
      description: The assistant work statistics.
      properties:
        usage_per_model:
          type: array
          description: Statistics of tokens used in models by the assistant. In case of streaming, the statistics is published fully in one chunk.
          items:
            type: object
            properties:
              index:
                type: integer
                description: All items of the `usage_per_model` must have unique index. The first item must have index 0, each subsequent one should set an index that is one greater than the previous one.
              model:
                type: string
                description: The model name.
              prompt_tokens:
                type: integer
                description: The number of tokens in the request to the model.
              completion_tokens:
                type: integer
                description: The number of tokens in the response from the model.
              total_tokens:
                type: integer
                description: The sum of prompt and completion tokens.
    StreamResponse:
      type: object
      properties:
        id:
          type: string
          description: The ID of the response.
        object:
          type: string
          description: Object type. Always is "chat.completion.chunk" for streaming.
        created:
          type: integer
          description: The response timestamp. The time in seconds since the epoch.
        choices:
          type: array
          description: List of generated chanks.
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of the choice from 0 to _n - 1_
              delta:
                type: object
                $ref: '#/components/schemas/Delta'
              finish_reason:
                type: string
                description: |-
                  The finish reason of generation of the choice. The possible reasons:

                  | Reason | Description|
                  | - | - |
                  | stop | Successful generation |
                  | length | The generation was stopped due to exceeding the available number of tokens |
                  |function_call|The assistant decided to call a function|
                  |content_filter|Omitted content due to a flag from content filters|
                  |`null`|The generation of the choice is in progress|
            required:
              - index
              - message
              - finish_reason
        usage:
          type: object
          description: The field contains information about used models tokens for generation of the response. In case of streaming, the usage is published fully in one chunk.
          properties:
            prompt_tokens:
              type: integer
              description: The number of tokens in the request to the model.
            completion_tokens:
              type: integer
              description: The number of tokens in the response from the model.
            total_tokens:
              type: integer
              description: The sum of prompt and completion tokens.
        statistics:
          type: object
          $ref: '#/components/schemas/Statistics'
    Error:
      type: object
      properties:
        type:
          type: string
          nullable: false
        message:
          type: string
          nullable: false
        param:
          type: string
          nullable: true
        code:
          type: string
          nullable: true
      required:
        - type
        - message
        - param
        - code
