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

# Get Knowledge Base



## OpenAPI

````yaml get /knowledge-base/{id}
openapi: 3.0.0
info:
  title: cozmox API
  description: Voice AI for developers.
  version: '1'
  contact: {}
servers:
  - description: Cozmox APIs
    url: https://api.cozmox.ai
  - url: https://api.cozmox.ai
security: []
tags: []
paths:
  /knowledge-base/{id}:
    get:
      tags:
        - Knowledge Base
      summary: Get Knowledge Base
      operationId: KnowledgeBaseController_findOne
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/TrieveKnowledgeBase'
                    title: TrieveKnowledgeBase
                  - $ref: '#/components/schemas/CustomKnowledgeBase'
                    title: CustomKnowledgeBase
                discriminator:
                  propertyName: provider
                  mapping:
                    trieve: '#/components/schemas/TrieveKnowledgeBase'
                    custom-knowledge-base: '#/components/schemas/CustomKnowledgeBase'
      security:
        - bearer: []
components:
  schemas:
    TrieveKnowledgeBase:
      type: object
      properties:
        provider:
          type: string
          description: |-
            This knowledge base is provided by Trieve.

            To learn more about Trieve, visit https://trieve.ai.
          enum:
            - trieve
        name:
          type: string
          description: This is the name of the knowledge base.
        searchPlan:
          description: >-
            This is the searching plan used when searching for relevant chunks
            from the vector store.


            You should configure this if you're running into these issues:

            - Too much unnecessary context is being fed as knowledge base
            context.

            - Not enough relevant context is being fed as knowledge base
            context.
          allOf:
            - $ref: '#/components/schemas/TrieveKnowledgeBaseSearchPlan'
        createPlan:
          description: >-
            This is the plan if you want us to create/import a new vector store
            using Trieve.
          oneOf:
            - $ref: '#/components/schemas/TrieveKnowledgeBaseImport'
              title: Import
        id:
          type: string
          description: This is the id of the knowledge base.
        orgId:
          type: string
          description: This is the org id of the knowledge base.
      required:
        - provider
        - id
        - orgId
    CustomKnowledgeBase:
      type: object
      properties:
        provider:
          type: string
          description: This knowledge base is bring your own knowledge base implementation.
          enum:
            - custom-knowledge-base
        server:
          description: |-
            This is where the knowledge base request will be sent.

            Request Example:

            POST https://{server.url}
            Content-Type: application/json

            {
              "messsage": {
                "type": "knowledge-base-request",
                "messages": [
                  {
                    "role": "user",
                    "content": "Why is ocean blue?"
                  }
                ],
                ...other metadata about the call...
              }
            }

            Response Expected:
            ```
            {
              "message": {
                 "role": "assistant",
                 "content": "The ocean is blue because water absorbs everything but blue.",
              }, // YOU CAN RETURN THE EXACT RESPONSE TO SPEAK
              "documents": [
                {
                  "content": "The ocean is blue primarily because water absorbs colors in the red part of the light spectrum and scatters the blue light, making it more visible to our eyes.",
                  "similarity": 1
                },
                {
                  "content": "Blue light is scattered more by the water molecules than other colors, enhancing the blue appearance of the ocean.",
                  "similarity": .5
                }
              ] // OR, YOU CAN RETURN AN ARRAY OF DOCUMENTS THAT WILL BE SENT TO THE MODEL
            }
            ```
          allOf:
            - $ref: '#/components/schemas/Server'
        id:
          type: string
          description: This is the id of the knowledge base.
        orgId:
          type: string
          description: This is the org id of the knowledge base.
      required:
        - provider
        - server
        - id
        - orgId
    TrieveKnowledgeBaseSearchPlan:
      type: object
      properties:
        topK:
          type: number
          description: >-
            Specifies the number of top chunks to return. This corresponds to
            the `page_size` parameter in Trieve.
        removeStopWords:
          type: boolean
          description: >-
            If true, stop words (specified in server/src/stop-words.txt in the
            git repo) will be removed. This will preserve queries that are
            entirely stop words.
        scoreThreshold:
          type: number
          description: >-
            This is the score threshold to filter out chunks with a score below
            the threshold for cosine distance metric. For Manhattan Distance,
            Euclidean Distance, and Dot Product, it will filter out scores above
            the threshold distance. This threshold applies before weight and
            bias modifications. If not specified, this defaults to no threshold.
            A threshold of 0 will default to no threshold.
        searchType:
          type: string
          description: >-
            This is the search method used when searching for relevant chunks
            from the vector store.
          enum:
            - fulltext
            - semantic
            - hybrid
            - bm25
      required:
        - searchType
    TrieveKnowledgeBaseImport:
      type: object
      properties:
        type:
          type: string
          description: This is to import an existing dataset from Trieve.
          enum:
            - import
        providerId:
          type: string
          description: This is the `datasetId` of the dataset on your Trieve account.
      required:
        - type
        - providerId
    Server:
      type: object
      properties:
        timeoutSeconds:
          type: number
          description: >-
            This is the timeout in seconds for the request. Defaults to 20
            seconds.


            @default 20
          minimum: 1
          maximum: 300
          example: 20
        url:
          type: string
          description: This is where the request will be sent.
        headers:
          type: object
          description: |-
            These are the headers to include in the request.

            Each key-value pair represents a header name and its value.
        backoffPlan:
          description: >-
            This is the backoff plan if the request fails. Defaults to undefined
            (the request will not be retried).


            @default undefined (the request will not be retried)
          allOf:
            - $ref: '#/components/schemas/BackoffPlan'
    BackoffPlan:
      type: object
      properties:
        type:
          type: object
          description: |-
            This is the type of backoff plan to use. Defaults to fixed.

            @default fixed
          enum:
            - fixed
            - exponential
          example: fixed
        maxRetries:
          type: number
          description: >-
            This is the maximum number of retries to attempt if the request
            fails. Defaults to 0 (no retries).


            @default 0
          minimum: 0
          maximum: 10
          example: 0
        baseDelaySeconds:
          type: number
          description: >-
            This is the base delay in seconds. For linear backoff, this is the
            delay between each retry. For exponential backoff, this is the
            initial delay.
          minimum: 0
          maximum: 10
          example: 1
      required:
        - type
        - maxRetries
        - baseDelaySeconds
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: Bearer
      type: http
      description: Retrieve your API Key from [Dashboard](dashboard.cozmox.ai).

````