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

# Query

> Query the knowledge base and retrieve answers to user questions. Send a question and receive a synthesized answer or relevant document chunks from the knowledge base.



## OpenAPI

````yaml /specs/general-runtime/openapi.public.json post /knowledge-base/query
openapi: 3.0.0
info:
  title: General-runtime
  description: Voiceflow runtime service
  version: 1.0.0
  contact: {}
servers:
  - url: https://general-runtime.voiceflow.com
security: []
paths:
  /knowledge-base/query:
    post:
      tags:
        - Public-Docs
      summary: Query
      description: >-
        Query the knowledge base and retrieve answers to user questions. Send a
        question and receive a synthesized answer or relevant document chunks
        from the knowledge base.
      operationId: KnowledgeBaseController_query
      parameters:
        - name: authorization
          required: true
          in: header
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                projectID:
                  type: string
                question:
                  type: string
                instruction:
                  type: string
                chunkLimit:
                  type: integer
                  minimum: 1
                  maximum: 30
                synthesis:
                  type: boolean
                settings:
                  type: object
                  properties:
                    model:
                      type: string
                    temperature:
                      type: number
                    maxTokens:
                      type: integer
                      minimum: -9007199254740991
                      maximum: 9007199254740991
                    system:
                      type: string
                    reasoningEffort:
                      nullable: true
                      type: string
                filters:
                  type: object
                  additionalProperties: {}
                internalFilters:
                  type: array
                  items:
                    $ref: '#/components/schemas/CompiledAgentKnowledgeBaseFilter'
                projectEnvironmentIDOrAlias:
                  description: >-
                    The alias of the environment to target (ie. `main`). You can
                    find this in the environments page of your agent.


                    > **💡 Tip:** [Learn more about
                    Environments](/documentation/deploy/environments).
                  type: string
                versionVariant:
                  default: published
                  type: string
                  enum:
                    - draft
                    - published
                  x-enumNames:
                    - DRAFT
                    - PUBLISHED
              required:
                - question
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - completion
                    x-enumNames:
                      - COMPLETION
                  model:
                    type: string
                  output:
                    nullable: true
                    type: string
                  duration:
                    type: number
                  tokens:
                    type: number
                  queryTokens:
                    type: number
                  answerTokens:
                    type: number
                  cacheWriteTokens:
                    type: number
                  queryCachedTokens:
                    type: number
                  queryRemainderTokens:
                    type: number
                  inputMultiplier:
                    type: number
                  cacheMultiplier:
                    type: number
                  outputMultiplier:
                    type: number
                  cacheWriteMultiplier:
                    type: number
                  base:
                    type: object
                    properties:
                      queryTokens:
                        type: number
                      answerTokens:
                        type: number
                      cacheWriteTokens:
                        type: number
                      queryCachedTokens:
                        type: number
                    required:
                      - queryTokens
                      - answerTokens
                      - cacheWriteTokens
                      - queryCachedTokens
                  chunks:
                    type: array
                    items:
                      type: object
                      properties:
                        score:
                          type: number
                        chunkID:
                          type: string
                        documentID:
                          type: string
                        content:
                          type: string
                        source:
                          anyOf:
                            - $ref: '#/components/schemas/KBDocumentData'
                            - type: object
                              properties: {}
                        metadata:
                          type: object
                          additionalProperties: {}
                        internalMetadata:
                          type: array
                          items:
                            $ref: '#/components/schemas/DocumentMetadataFields'
                      required:
                        - score
                        - chunkID
                        - documentID
                        - content
                        - source
                        - metadata
                required:
                  - type
                  - model
                  - output
                  - duration
                  - tokens
                  - queryTokens
                  - answerTokens
                  - cacheWriteTokens
                  - queryCachedTokens
                  - queryRemainderTokens
                  - inputMultiplier
                  - cacheMultiplier
                  - outputMultiplier
                  - cacheWriteMultiplier
                  - base
                  - chunks
      security:
        - auth: []
components:
  schemas:
    CompiledAgentKnowledgeBaseFilter:
      type: object
      properties:
        key:
          type: string
        value:
          type: string
        operator:
          $ref: '#/components/schemas/KBMetadataFilterOperation'
      required:
        - key
        - value
        - operator
    KBDocumentData:
      oneOf:
        - $ref: '#/components/schemas/KBDocumentUrlData'
        - $ref: '#/components/schemas/KBDocumentDocxData'
        - $ref: '#/components/schemas/KBDocumentPDFData'
        - $ref: '#/components/schemas/KBDocumentTextData'
        - $ref: '#/components/schemas/KBDocumentMarkdownData'
        - $ref: '#/components/schemas/KBDocumentCSVData'
        - $ref: '#/components/schemas/KBDocumentXLSXData'
        - $ref: '#/components/schemas/KBDocumentTableData'
    DocumentMetadataFields:
      type: object
      properties:
        key:
          type: string
        values:
          type: array
          items:
            type: string
      required:
        - key
        - values
    KBMetadataFilterOperation:
      type: string
      enum:
        - is
        - is_not
        - contains
        - not_contains
      x-enumNames:
        - IS
        - IS_NOT
        - CONTAINS
        - NOT_CONTAINS
    KBDocumentUrlData:
      type: object
      properties:
        type:
          type: string
          enum:
            - url
          x-enumNames:
            - URL
        name:
          type: string
        url:
          type: string
        refreshRate:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseDocumentRefreshRate'
        lastSuccessUpdate:
          type: string
        accessTokenID:
          type: number
        integrationExternalID:
          type: string
        source:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseDocumentIntegrationType'
      required:
        - type
        - name
        - url
    KBDocumentDocxData:
      type: object
      properties:
        type:
          type: string
          enum:
            - docx
          x-enumNames:
            - DOCX
        name:
          type: string
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentPDFData:
      type: object
      properties:
        type:
          type: string
          enum:
            - pdf
          x-enumNames:
            - PDF
        name:
          type: string
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentTextData:
      type: object
      properties:
        type:
          type: string
          enum:
            - text
          x-enumNames:
            - TEXT
        name:
          type: string
        canEdit:
          type: boolean
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentMarkdownData:
      type: object
      properties:
        type:
          type: string
          enum:
            - md
          x-enumNames:
            - MD
        name:
          type: string
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentCSVData:
      type: object
      properties:
        type:
          type: string
          enum:
            - csv
          x-enumNames:
            - CSV
        name:
          type: string
        rowsCount:
          type: number
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentXLSXData:
      type: object
      properties:
        type:
          type: string
          enum:
            - xlsx
          x-enumNames:
            - XLSX
        name:
          type: string
        rowsCount:
          type: number
        url:
          nullable: true
          type: string
      required:
        - type
        - name
    KBDocumentTableData:
      type: object
      properties:
        type:
          type: string
          enum:
            - table
          x-enumNames:
            - TABLE
        name:
          type: string
        rowsCount:
          type: number
        url:
          nullable: true
          type: string
      required:
        - type
        - name
        - rowsCount
    KnowledgeBaseDocumentRefreshRate:
      type: string
      enum:
        - daily
        - weekly
        - monthly
        - never
      x-enumNames:
        - DAILY
        - WEEKLY
        - MONTHLY
        - NEVER
    KnowledgeBaseDocumentIntegrationType:
      type: string
      enum:
        - zendesk
        - shopify
      x-enumNames:
        - ZENDESK
        - SHOPIFY
  securitySchemes:
    auth:
      type: apiKey
      in: header
      name: authorization
      description: Voiceflow API key

````