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

# Chat Completions

> Generate a model response to a conversation that can include references to video content



## OpenAPI

````yaml POST /chat/completions
openapi: 3.0.0
info:
  title: Cloudglue API
  description: API for Cloudglue
  license:
    name: Apache License 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 0.7.8
servers:
  - url: https://api.cloudglue.dev/v1
security:
  - bearerAuth: []
paths:
  /chat/completions:
    post:
      tags:
        - Chat
      summary: >-
        Generate a model response to a conversation that can include references
        to video content
      description: >-
        Generate a model response to a conversation that can include references
        to video content
      operationId: createCompletion
      requestBody:
        description: Chat completion parameters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Collections not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Chat completion limits reached (monthly or daily)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: An unexpected error occurred on the server
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      properties:
        model:
          type: string
          description: Name of the video understanding model to use.
          enum:
            - nimbus-001
        messages:
          type: array
          description: A list of messages comprising the conversation so far
          items:
            $ref: '#/components/schemas/ChatMessage'
        collections:
          type: array
          description: >-
            List of collection IDs to use as context for the chat.


            Note that 'nimbus-001' only supports collections with
            collection_type 'media-descriptions' or 'rich-transcripts'
          items:
            type: string
          minItems: 1
          maxItems: 1
        filter:
          type: object
          description: Filter criteria to constrain search results used in chat
          properties:
            metadata:
              type: array
              description: Filter by file metadata using JSON path expressions
              items:
                type: object
                properties:
                  path:
                    type: string
                    description: >-
                      JSON path on metadata object (e.g. 'my_custom_field',
                      'category.subcategory')
                  operator:
                    type: string
                    enum:
                      - NotEqual
                      - Equal
                      - LessThan
                      - GreaterThan
                      - In
                      - ContainsAny
                      - ContainsAll
                    description: Comparison operator to apply
                  valueText:
                    type: string
                    description: >-
                      Text value for scalar comparison (used with NotEqual,
                      Equal, LessThan, GreaterThan, In)
                  valueTextArray:
                    type: array
                    items:
                      type: string
                    description: >-
                      Array of values for array comparisons (used with
                      ContainsAny, ContainsAll)
                required:
                  - path
                  - operator
            video_info:
              type: array
              description: >-
                Filter by video information. Use scope 'file' for source video
                properties or 'segment' for segment properties (e.g. segment
                duration).
              items:
                type: object
                properties:
                  path:
                    type: string
                    enum:
                      - duration_seconds
                      - has_audio
                    description: >-
                      JSON path on video_info object (e.g. 'has_audio',
                      'duration_seconds')
                  scope:
                    type: string
                    enum:
                      - file
                      - segment
                    description: >-
                      Scope of the filter. 'file' filters by source video
                      properties, 'segment' filters by segment properties. Only
                      duration_seconds is supported with segment scope.
                  operator:
                    type: string
                    enum:
                      - NotEqual
                      - Equal
                      - LessThan
                      - GreaterThan
                      - In
                      - ContainsAny
                      - ContainsAll
                    description: Comparison operator to apply
                  valueText:
                    type: string
                    description: >-
                      Text value for scalar comparison (used with NotEqual,
                      Equal, LessThan, GreaterThan, In)
                  valueTextArray:
                    type: array
                    items:
                      type: string
                    description: >-
                      Array of values for array comparisons (used with
                      ContainsAny, ContainsAll)
                required:
                  - path
                  - operator
            file:
              type: array
              description: Filter by file properties using JSON path expressions
              items:
                type: object
                properties:
                  path:
                    type: string
                    description: >-
                      JSON path on file object (e.g. 'uri', 'id', 'filename',
                      'created_at', 'bytes')
                  operator:
                    type: string
                    enum:
                      - NotEqual
                      - Equal
                      - LessThan
                      - GreaterThan
                      - In
                      - ContainsAny
                      - ContainsAll
                    description: Comparison operator to apply
                  valueText:
                    type: string
                    description: >-
                      Text value for scalar comparison (used with NotEqual,
                      Equal, LessThan, GreaterThan, In)
                  valueTextArray:
                    type: array
                    items:
                      type: string
                    description: >-
                      Array of values for array comparisons (used with
                      ContainsAny, ContainsAll)
                required:
                  - path
                  - operator
        temperature:
          type: number
          description: Sampling temperature to use, between 0 and 2
          minimum: 0
          maximum: 2
      required:
        - model
        - messages
        - collections
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for this chat completion
        object:
          type: string
          description: Object type, always "chat.completion"
        created_at:
          type: integer
          description: Unix timestamp in milliseconds when the chat completion was created
        model:
          type: string
          description: The model used for the chat completion
        choices:
          type: array
          description: The generated responses
          items:
            type: object
            properties:
              index:
                type: integer
                description: The index of this choice
              message:
                $ref: '#/components/schemas/ChatMessage'
                description: The chat message generated by the model
              citations:
                type: array
                description: >-
                  Citations to specific video segments that informed the
                  response
                items:
                  allOf:
                    - type: object
                      properties:
                        collection_id:
                          type: string
                          description: ID of the collection containing the cited video
                        file_id:
                          type: string
                          description: ID of the file being cited
                        segment_id:
                          type: string
                          description: ID of the segment being cited
                        start_time:
                          oneOf:
                            - type: string
                              description: Start time of the cited segment in seconds
                            - type: number
                              description: Start time of the cited segment in seconds
                          description: Start time of the cited segment in seconds
                        end_time:
                          oneOf:
                            - type: string
                              description: End time of the cited segment in seconds
                            - type: number
                              description: End time of the cited segment in seconds
                          description: End time of the cited segment in seconds
                        text:
                          type: string
                          description: >-
                            (Deprecated) Relevant text from the segment; use
                            context and relevant_sources instead
                        context:
                          type: string
                          description: >-
                            Short explanation of the relevance of the segment to
                            the query provided as context
                        relevant_sources:
                          type: array
                          description: >-
                            List of source modalities in segment that are
                            relevant for this citation
                          items:
                            type: object
                            properties:
                              text:
                                type: string
                                description: >-
                                  Source modality, one of
                                  visual_scene_description, scene_text, speech
                    - $ref: '#/components/schemas/DescribeOutput'
        payload:
          $ref: '#/components/schemas/ChatCompletionPayload'
        usage:
          type: object
          description: Usage statistics for the completion request
          properties:
            prompt_tokens:
              type: integer
              description: Number of tokens in the prompt
            completion_tokens:
              type: integer
              description: Number of tokens in the generated completion
            total_tokens:
              type: integer
              description: Total number of tokens used in the request
    Error:
      required:
        - error
      type: object
      properties:
        error:
          type: string
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          description: The role of the message author
          enum:
            - system
            - user
            - assistant
        content:
          type: string
          description: The content of the message
        name:
          type: string
          description: The name of the author of this message
      required:
        - role
        - content
    DescribeOutput:
      type: object
      properties:
        visual_scene_description:
          type: array
          description: Array of visual descriptions
          items:
            $ref: '#/components/schemas/DescribeOutputPart'
        scene_text:
          type: array
          description: Array of scene text extractions
          items:
            $ref: '#/components/schemas/DescribeOutputPart'
        speech:
          type: array
          description: Array of speech transcriptions
          items:
            $ref: '#/components/schemas/SpeechOutputPart'
        audio_description:
          type: array
          description: Array of audio descriptions
          items:
            $ref: '#/components/schemas/DescribeOutputPart'
    ChatCompletionPayload:
      type: object
      properties:
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        temperature:
          type: number
          description: The temperature of the chat completion
        filter:
          $ref: '#/components/schemas/SearchFilter'
        collections:
          type: array
          items:
            type: string
            format: uuid
    DescribeOutputPart:
      type: object
      properties:
        text:
          type: string
          description: Text content
        start_time:
          type: number
          description: Start time in seconds
        end_time:
          type: number
          description: End time in seconds
    SpeechOutputPart:
      type: object
      properties:
        speaker:
          type: string
          description: Identified speaker
        text:
          type: string
          description: Transcribed speech text
        start_time:
          type: number
          description: Start time of speech in seconds
        end_time:
          type: number
          description: End time of speech in seconds
        words:
          type: array
          description: >-
            Word-level timestamps. Only present when
            include_word_timestamps=true. Not available for YouTube sources.
          items:
            $ref: '#/components/schemas/WordTimestamp'
    SearchFilter:
      type: object
      properties:
        metadata:
          type: array
          description: Filter by file metadata using JSON path expressions
          items:
            allOf:
              - $ref: '#/components/schemas/SearchFilterCriteria'
              - type: object
                properties:
                  scope:
                    type: string
                    enum:
                      - file
                      - segment
                    description: >-
                      Specifies scope of eligible search items (file/segment) to
                      check metadata filtering conditions
        video_info:
          type: array
          description: >-
            Filter by video information. Use scope 'file' to filter by source
            video properties, or 'segment' to filter by individual segment
            properties (e.g. segment duration).
          items:
            allOf:
              - $ref: '#/components/schemas/SearchFilterCriteria'
              - type: object
                properties:
                  path:
                    type: string
                    enum:
                      - duration_seconds
                      - has_audio
                  scope:
                    type: string
                    enum:
                      - file
                      - segment
                    description: >-
                      Scope of the filter. 'file' filters by source video
                      properties, 'segment' filters by segment properties. Only
                      duration_seconds is supported with segment scope.
        file:
          type: array
          description: Filter by file properties
          items:
            allOf:
              - $ref: '#/components/schemas/SearchFilterCriteria'
              - type: object
                properties:
                  path:
                    type: string
                    enum:
                      - bytes
                      - filename
                      - uri
                      - created_at
                      - id
    WordTimestamp:
      type: object
      description: A single word with its timing information
      properties:
        word:
          type: string
          description: The word text
        start_time:
          type: number
          description: Start time of the word in seconds
        end_time:
          type: number
          description: End time of the word in seconds
      required:
        - word
        - start_time
        - end_time
    SearchFilterCriteria:
      type: object
      required:
        - path
        - operator
      properties:
        path:
          type: string
          description: JSON path for the field to filter on
        operator:
          type: string
          enum:
            - NotEqual
            - Equal
            - LessThan
            - GreaterThan
            - ContainsAny
            - ContainsAll
            - In
            - Like
          description: Comparison operator to apply
        valueText:
          type: string
          description: >-
            Text value for scalar comparison (used with NotEqual, Equal,
            LessThan, GreaterThan, Like)
        valueTextArray:
          type: array
          items:
            type: string
          description: >-
            Array of values for array comparisons (used with ContainsAny,
            ContainsAll, In)
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````