Search a knowledge base
POST /v1/knowledge-bases/{kb_id}/search
Perform semantic search over a knowledge base. Returns ranked chunks with scores.
The search pipeline:
- Embed the query using Voyage AI
- Perform approximate nearest neighbor search via pgvector (HNSW)
- Optionally rerank results using Voyage AI Reranker (enabled by default)
- Apply score threshold filter
- Return top-k results with metadata
Reranking is enabled by default and significantly improves result quality.
Set rerank: false to skip reranking (faster but lower quality).
Metadata filtering supports operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin.
Filters are applied post-retrieval with adaptive over-fetch.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Example
kb_a1b2c3d4e5Knowledge base ID
Request Body required
Section titled “Request Body required ”object
Natural language search query
Example
How do I configure authentication?Number of results to return
Example
10Whether to apply cross-encoder reranking via Voyage AI Reranker.
Enabled by default for better result quality. Set to false for lower latency.
Example
trueMetadata filter object. Keys are metadata field names. Values are filter expressions
using operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin.
Example: {"department": {"$eq": "engineering"}, "version": {"$gte": 2}}
object
Example
{ "department": { "$eq": "engineering" }, "version": { "$gte": 2 }}Minimum score threshold. Results below this score are excluded.
Example
0.5Whether to include chunk and document metadata in results
Example
trueSearch mode. vector (default) uses semantic embedding similarity.
keyword uses PostgreSQL full-text search (no embedding call, faster/cheaper).
hybrid runs both in parallel and fuses results with Reciprocal Rank Fusion (RRF).
Example
hybridOptional keyword query for keyword/hybrid modes. If omitted, the query field is
used for both semantic and keyword search. Useful when you want different queries
for each search component.
Example
authentication configWeight for vector results in hybrid mode (0 = keyword only, 1 = vector only).
Only used when mode is hybrid. Default 0.6 (slightly favors semantic search).
Example
0.6Responses
Section titled “ Responses ”Search results returned
object
object
The original search query
Example
How do I configure authentication?object
Chunk ID (prefixed with chk_)
Example
chk_k1l2m3n4o5Source document ID
Example
doc_f6g7h8i9j0Source document file name
Example
product-guide.pdfThe chunk text content
Example
To configure authentication, navigate to Settings > Auth and enable...Relevance score (0 to 1). Higher is more relevant.
Example
0.94Chunk metadata (included when include_metadata is true)
object
Position of this chunk within the document
Example
3Starting page number
Example
5Ending page number
Example
5Section heading this chunk belongs to
Example
Authentication SetupDocument-level metadata (included when include_metadata is true)
object
Example
{ "department": "engineering", "version": 2}object
Number of tokens used for query embedding (0 for keyword-only mode)
Example
12Whether reranking was applied. May be false even if rerank: true was requested,
if the reranker timed out or encountered an error (graceful degradation).
Example
trueNumber of rerank API calls made (0 if reranking was not applied)
Example
1Total number of chunks searched
Example
1420The search mode that was used for this query
Example
vectorRequest validation failed
object
object
Machine-readable error code
Example
VALIDATION_ERRORHuman-readable error message
Example
Invalid request bodyAdditional error details (e.g., validation issues)
object
Example
{ "error": { "code": "VALIDATION_ERROR", "message": "Invalid request body", "details": { "issues": [ { "path": [ "name" ], "message": "Required" } ] } }}Authentication failed or missing
object
object
Machine-readable error code
Example
VALIDATION_ERRORHuman-readable error message
Example
Invalid request bodyAdditional error details (e.g., validation issues)
object
Example
{ "error": { "code": "AUTHENTICATION_ERROR", "message": "Invalid or missing API key" }}Resource not found
object
object
Machine-readable error code
Example
VALIDATION_ERRORHuman-readable error message
Example
Invalid request bodyAdditional error details (e.g., validation issues)
object
Example
{ "error": { "code": "NOT_FOUND", "message": "KnowledgeBase not found: kb_nonexistent" }}Rate limit or usage limit exceeded
object
object
Machine-readable error code
Example
VALIDATION_ERRORHuman-readable error message
Example
Invalid request bodyAdditional error details (e.g., validation issues)
object
Examples
Rate limit exceeded
{ "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded" }}Query usage limit exceeded
{ "error": { "code": "USAGE_LIMIT_EXCEEDED", "message": "Usage limit exceeded for search_queries. Upgrade your plan or wait for the next billing period.", "details": { "limit": 5000, "current_usage": 5000, "plan": "starter", "requested": 1 } }}External service error (embedding or reranking service unavailable)
object
object
Machine-readable error code
Example
VALIDATION_ERRORHuman-readable error message
Example
Invalid request bodyAdditional error details (e.g., validation issues)
object
Example
{ "error": { "code": "EXTERNAL_SERVICE_ERROR", "message": "Voyage AI: Request timed out" }}