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

# Process Chat Completion

> Endpoint to process a chat completion request using NVIDIA NIM API
and store the result in MongoDB using the new schema with a single document
per project containing a messages array.



## OpenAPI

````yaml openapi.json post /codenull/ai/api/v1/chat-completion
openapi: 3.1.0
info:
  title: codenull-ai-backend
  version: 0.1.0
servers: []
security: []
paths:
  /codenull/ai/api/v1/chat-completion:
    post:
      tags:
        - chat-completion
      summary: Process Chat Completion
      description: >-
        Endpoint to process a chat completion request using NVIDIA NIM API

        and store the result in MongoDB using the new schema with a single
        document

        per project containing a messages array.
      operationId: api-process_chat_completion
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ChatCompletionRequest:
      properties:
        project_id:
          type: string
          title: Project Id
          description: Project ID as UUID
        user_prompt:
          $ref: '#/components/schemas/UserPrompt'
          description: User message including role and content
      type: object
      required:
        - project_id
        - user_prompt
      title: ChatCompletionRequest
    ChatCompletionResponse:
      properties:
        id:
          type: string
          title: Id
          description: UUID of the conversation document
        project_id:
          type: string
          title: Project Id
          description: Project ID as UUID
        messages:
          items:
            additionalProperties:
              type: string
            type: object
          type: array
          title: Messages
          description: Array of messages in the conversation
        created_at:
          type: string
          title: Created At
          description: Timestamp when the conversation was created
        updated_at:
          type: string
          title: Updated At
          description: Timestamp when the conversation was last updated
        ready_for_generation:
          type: boolean
          title: Ready For Generation
          description: >-
            Flag indicating if website requirements are confirmed and ready for
            generation
          default: false
      type: object
      required:
        - id
        - project_id
        - messages
        - created_at
        - updated_at
      title: ChatCompletionResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UserPrompt:
      properties:
        role:
          type: string
          title: Role
          description: Role of the message sender (should be 'user')
          default: user
        content:
          type: string
          title: Content
          description: Content of the user's message
      type: object
      required:
        - content
      title: UserPrompt
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````