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

# OpenAI Chat Completion

> Create a new AI completion. You can find the supported models using [List all AI models](/api-reference/ai/list-all-ai-models).



## OpenAPI

````yaml /openapi.yaml post /v1/openai/chat/completions
openapi: 3.1.0
info:
  title: Nuwacom API
  description: API for Nuwacom application
  version: 1.0.0
servers:
  - url: https://{customer-tenant}.nuwacom.ai/
    description: Nuwacom API
security:
  - bearerAuth: []
paths:
  /v1/openai/chat/completions:
    post:
      tags:
        - Completion API
      summary: OpenAI Chat Completion
      description: >-
        Create a new AI completion. You can find the supported models using
        [List all AI models](/api-reference/ai/list-all-ai-models).
      operationId: postV1OpenaiChatCompletions
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  anyOf:
                    - type: string
                      nullable: true
                  description: >-
                    Use this in the API call to specify the model to use for the
                    completion request. Is generally the model ID from the LLM
                    provider (e.g., "gpt-4o", "o1").
                temperature:
                  type: number
                  description: >-
                    Sampling temperature. Higher values make responses more
                    adventurous; lower values keep them conservative.
                top_p:
                  type: number
                  description: >-
                    Nucleus sampling parameter. Use this instead of temperature
                    when you want to strictly cap how much of the probability
                    mass is considered.
                agentId:
                  anyOf:
                    - type: string
                      format: uuid
                      nullable: true
                  description: >-
                    Unique ID of the agent to use for the completion request.
                    Used to load the agent's full configuration (system prompt,
                    knowledge sources, etc.). NB: Agent must already be created
                    in the database and available for the space.
                voiceId:
                  anyOf:
                    - type: string
                      format: uuid
                      nullable: true
                  description: >-
                    UUID of the Voice to use for the completion request. NB:
                    Voice must already be created in the database and available
                    for the space.
                taskId:
                  anyOf:
                    - type: string
                      format: uuid
                      nullable: true
                  description: >-
                    ID of the Task to use for the completion request. Used to
                    tie the completion back to a workflow step or scheduled job.
                    NB: Task must already be created in the database and
                    available for the space.
                capabilities:
                  type: object
                  properties:
                    webSearch:
                      type: boolean
                    knowledgeBaseSearch:
                      type: boolean
                    visionEnabled:
                      type: boolean
                  required: []
                  description: >-
                    Provide an object of capabilities to enable the LLM perform
                    specific tasks better (e.g., web search, internal KB,
                    canvas, etc.).
                attachmentIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  description: >-
                    Array of asset IDs (files, snippets, etc.) that should be
                    injected into the completion request as supporting context.
                contentIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  description: >-
                    Array of Content document IDs to include in the RAG context.
                    Used to pass relevant document IDs so their content is
                    included as additional background information for the
                    completion request.
                folderIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  description: >-
                    Array of Folder IDs to include in the RAG context. When
                    provided, the LLM will use assets/documents within these
                    folders as additional background information for the
                    completion request.
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        enum:
                          - assistant
                          - user
                          - system
                      content:
                        anyOf:
                          - type: string
                          - type: array
                            items:
                              anyOf:
                                - type: object
                                  properties:
                                    type:
                                      enum:
                                        - text
                                    text:
                                      type: string
                                  required:
                                    - type
                                    - text
                                - type: object
                                  properties:
                                    type:
                                      enum:
                                        - image
                                    kbAssetId:
                                      type: string
                                      format: uuid
                                  required:
                                    - type
                                    - kbAssetId
                    required:
                      - role
                      - content
                  minItems: 1
                  description: >-
                    Ordered chat messages that make up the conversation history.
                    Always include the user’s latest turn; prepend prior turns
                    when you want additional context.
                stream:
                  type: boolean
                  description: >-
                    When true the API sends partial chunks as the model
                    generates them (ideal for typing indicators). Set to false
                    to receive a single response payload.
                parent_message_id:
                  anyOf:
                    - type: number
                      nullable: true
                  description: >-
                    Internal reference to the last assistant message in the
                    thread. Include this when you need the completion to
                    “continue” an earlier answer.
                conversation_id:
                  anyOf:
                    - type: string
                      format: uuid
                      nullable: true
                  description: >-
                    Conversation UUID tying multiple completions together.
                    Provide it to append to an existing thread; leave empty to
                    start fresh.
                space_id:
                  type: string
                  format: uuid
              required:
                - messages
                - space_id
      responses:
        '200':
          description: >-
            Successful completion response (see [OpenAI Completions
            Object](https://platform.openai.com/docs/api-reference/completions/object))
      externalDocs:
        description: OpenAI API documentation for chat completions
        url: https://platform.openai.com/docs/api-reference/chat/create
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````