GET
/
api
/
knowledgebases
/
query
curl --request GET \
  --url https://app.pathors.com/api/knowledgebases/query \
  --header 'x-api-key: <x-api-key>'
{
  "id": "<string>",
  "content": "<string>",
  "contentLength": 123
}

Query Chunks

Retrieves relevant chunks from your knowledgebase based on a semantic search query.

Endpoint

GET /api/knowledgebases/query

Headers

x-api-key
string
required

Your project API key for authentication

Query Parameters

q
string
required

The search query to match against the knowledgebase content

topK
number

Maximum number of results to return. Defaults to 5

scoreThreshold
number

Minimum relevance score for chunks to be included. Defaults to 0.3

Example request:

GET /api/knowledgebases/query?q=search_term&topK=5&scoreThreshold=0.3

Response

Returns an array of chunks that match the query, ordered by relevance.

id
string

Unique identifier for the chunk

content
string

The content of the chunk

contentLength
number

Length of the chunk content

Example response:

[
  {
    "id": "chunk_abc123",
    "content": "The product features include real-time analytics...",
    "contentLength": 82
  }
]

Error Responses

Status CodeDescription
400Invalid query parameters
401Invalid API key
404Knowledgebase not found
500Internal server error

How It Works

  1. The query text is converted into embeddings using the same model as the knowledgebase
  2. The embeddings are used to perform semantic similarity search against stored chunks
  3. The most relevant chunks are returned, ordered by similarity score
  4. Results are limited to the specified topK parameter

Usage Notes

  • Queries are processed using semantic search, not exact text matching
  • Results are returned in order of relevance to the query
  • The response includes the most relevant chunks from across all datasets
  • Use the topK parameter to control the number of results returned
  • Consider the context when formulating queries for best results