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

# Chat Completions

> Generate AI chat responses with video context awareness

Generate AI-powered chat responses with awareness of your video content. This endpoint enables interactive conversations about videos in your collections, combining video intelligence with conversational AI.

<CodeGroup>
  ```python Python theme={null}
  import requests
  import json

  payload = {
      "messages": [
          {
              "role": "user",
              "content": "Summarize the key moments in this video"
          }
      ],
      "collection_id": "default",
      "video_id": "m-xyz789"
  }

  response = requests.post(
      "https://api.videodb.io/chat/completions",
      json=payload,
      headers={"x-access-token": "your_api_key"}
  )

  chat_response = response.json()
  print(f"Response: {chat_response.get('choices')[0].get('message').get('content')}")
  ```

  ```javascript Node.js theme={null}
  const payload = {
    messages: [
      {
        role: "user",
        content: "Summarize the key moments in this video"
      }
    ],
    collectionId: "default",
    videoId: "m-xyz789"
  };

  const response = await fetch(
    "https://api.videodb.io/chat/completions",
    {
      method: "POST",
      headers: {
        "x-access-token": "your_api_key",
        "Content-Type": "application/json"
      },
      body: JSON.stringify(payload)
    }
  );

  const chatResponse = await response.json();
  const content = chatResponse.choices[0].message.content;
  console.log("Response:", content);
  ```
</CodeGroup>

<Note>
  * Requires `collection_id` to specify which collection to search
  * Optional `video_id` to focus on a specific video
  * Supports multi-turn conversations by including message history in the `messages` array
  * Returns response in OpenAI-compatible format with `choices` array
</Note>

<CardGroup cols={2}>
  <Card title="Health Check" icon="heart-pulse" href="/api-reference/utilities/health_check">
    Verify API availability
  </Card>

  <Card title="Async Response" icon="clock" href="/api-reference/utilities/get_async_response">
    Poll async operation results
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /chat/completions
openapi: 3.0.3
info:
  title: VideoDB Server API
  description: >
    VideoDB Server API for video, audio, and image processing with AI
    capabilities.

    This API provides comprehensive video management, search, indexing, and
    AI-powered features.
  version: 1.0.0
  contact:
    name: VideoDB Support
    url: https://videodb.io
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://api.videodb.io
    description: Production server
  - url: https://staging-api.videodb.io
    description: Staging server
security:
  - ApiKeyAuth: []
tags:
  - name: Authentication
    description: User authentication and API key management
  - name: Collections
    description: Collection management operations
  - name: Videos
    description: Video upload, processing, and management
  - name: Audio
    description: Audio management operations
  - name: Images
    description: Image management operations
  - name: Search
    description: Content search and indexing
  - name: AI Generation
    description: AI-powered content generation
  - name: Billing
    description: Billing and usage management
  - name: RTStream
    description: Real-time streaming operations
  - name: Utilities
    description: Utility endpoints
  - name: Meeting
    description: Meeting recording and management
  - name: Capture
    description: Capture session management for recording streams
  - name: Editor
    description: Timeline editor operations
  - name: Transcode
    description: Media transcoding operations
  - name: Assets
    description: Cross-collection asset listing
paths:
  /chat/completions:
    post:
      summary: OpenAI-compatible chat completions proxy
      description: Proxy endpoint for OpenAI chat completions API with VideoDB billing
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  type: string
                  enum:
                    - gpt-4o-2024-11-20
                  example: gpt-4o-2024-11-20
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                        example: user
                      content:
                        type: string
                        example: Hello, how are you?
                max_tokens:
                  type: integer
                  example: 100
                temperature:
                  type: number
                  example: 0.7
                stream:
                  type: boolean
                  example: false
      responses:
        '200':
          description: Chat completion response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: chatcmpl-123
                  object:
                    type: string
                    example: chat.completion
                  created:
                    type: integer
                    example: 1677652288
                  model:
                    type: string
                    example: gpt-4o-2024-11-20
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          example: 0
                        message:
                          type: object
                          properties:
                            role:
                              type: string
                              example: assistant
                            content:
                              type: string
                              example: Hello! I'm doing well, thank you for asking.
                        finish_reason:
                          type: string
                          example: stop
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                        example: 10
                      completion_tokens:
                        type: integer
                        example: 15
                      total_tokens:
                        type: integer
                        example: 25
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: API key for authentication (sk-xxx format)

````