---
title: "Query Knowledge Base"
method: POST
path: "/kb/v1/knowledge-bases/{id}/query"
tags: ["Knowledge Bases"]
---

# Query Knowledge Base

`POST /kb/v1/knowledge-bases/{id}/query`

Send a question to the specified knowledge base and receive a response. Optionally pass a conversation history for the assistant to take into consideration while generating responses.

## Path parameters

- `id` string, required

## Request body

- object
  - `model` 'gpt-4o' | 'gpt-4o-mini' — Optional parameter - The GPT model to use for generating responses
  - `prompt` string — [DEPRECATED. USE "messages" instead] The query prompt to send to the knowledge base.
  - `messages` KnowledgeBaseQueryMessageDTO[] — A list of messages to query with. Note that "messages" and "prompt" cannot be used together. If both are found in the request, "messages" takes precedence and "prompt" is ignored.
    - `role` 'user' | 'assistant', required — Use "role" = "user" for incoming queries, and "role" = "assistant" to provide the past responses from the knowledge base assistant
    - `content` string, required
  - `temperature` number — Temperature controls the randomness in the output of the underlying language model; while lower values produce predictable and factual replies, higher values allow the model to be creative and reword the responses.
  - `seed` integer — Seed initializes the random number generator in the underlying language model, ensuring reproducible outputs for the same prompt and settings.
  - `stream` boolean — Determines whether to stream the generated response back instead of returning it all at once. When stream = true, the response is a list of JSON objects of the form {"response": string} separated by newline characters

## Response `200`

Successful response

- object
  - `response` string — The response from the knowledge base.

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Knowledge base not found

---

[API](https://skmtc.net/interactly/apis/interactly-api.md) · [All operations](https://skmtc.net/interactly/apis/interactly-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/interactly/interactly-api/versions/f39cdcb1f4e4/schema)
