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

> 基于应用级别的对话响应

# Chat Completions



## OpenAPI

````yaml post /v1/spaces/completions/{space_id}
openapi: 3.0.2
info:
  title: Duplik Backend
  description: The API for Duplik Backend.
  version: 0.1.0
servers:
  - url: https://api.duplik.cn
security: []
paths:
  /v1/spaces/completions/{space_id}:
    post:
      tags:
        - openapi-space
      summary: Chat Completions
      operationId: create_space_chat_v1_spaces_completions__space_id__post
      parameters:
        - required: true
          schema:
            title: Space Id
            type: integer
          name: space_id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - HTTPBearer: []
components:
  schemas:
    ChatRequest:
      title: ChatRequest
      required:
        - session_id
        - message
      type: object
      properties:
        session_id:
          title: Session Id
          type: string
        external_user_id:
          title: External User Id
          type: string
        conversation_id:
          title: Conversation Id
          type: string
        message:
          title: Message
          type: string
        stream:
          title: Stream
          type: boolean
          default: false
        refine_question:
          title: Refine Question
          type: boolean
          default: true
        copilot:
          title: Copilot
          type: boolean
          default: true
        dataset_id:
          title: Dataset Id
          type: string
        dataset_ids:
          title: Dataset Ids
          type: array
          items:
            type: string
        document_id:
          title: Document Id
          type: string
        document_ids:
          title: Document Ids
          type: array
          items:
            type: string
        only_dataset_tool:
          title: Only Dataset Tool
          type: boolean
          default: false
        context_params:
          title: Context Params
          type: object
        context_documents_mode:
          title: Context Documents Mode
          type: integer
          default: 1
        retrieval_with_websearch:
          title: Retrieval With Websearch
          type: boolean
          default: false
    ChatResponse:
      title: ChatResponse
      required:
        - message_id
        - user_message
        - assistant_message
      type: object
      properties:
        message_id:
          title: Message Id
          type: string
        user_message:
          title: User Message
          type: string
        assistant_message:
          title: Assistant Message
          type: string
        document_chunks:
          title: Document Chunks
          type: array
          items:
            $ref: '#/components/schemas/langchain_core__documents__base__Document'
          default: []
        token_usage:
          $ref: '#/components/schemas/TotalTokenUsage'
    ErrorResponse:
      title: ErrorResponse
      required:
        - code
        - message
      type: object
      properties:
        code:
          title: Code
          type: integer
        message:
          title: Message
          type: string
    langchain_core__documents__base__Document:
      title: Document
      required:
        - page_content
      type: object
      properties:
        page_content:
          title: Page Content
          type: string
        metadata:
          title: Metadata
          type: object
        type:
          title: Type
          enum:
            - Document
          type: string
          default: Document
      description: Class for storing a piece of text and associated metadata.
    TotalTokenUsage:
      title: TotalTokenUsage
      type: object
      properties:
        model_name:
          title: Model Name
          type: string
          default: ''
        total_tokens:
          title: Total Tokens
          type: integer
          default: 0
        prompt_tokens:
          title: Prompt Tokens
          type: integer
          default: 0
        completion_tokens:
          title: Completion Tokens
          type: integer
          default: 0
        successful_requests:
          title: Successful Requests
          type: integer
          default: 0
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````