Skip to content
Streamkap
Esc
↑↓navigate↵open⌘Jpreview

Retrieve Knowledge Base

Embed query and return the top-k matching chunks from the KB.

Auth: write:agents. Chunks are customer data, same threat model as /agents/{id}/logs.

Tenant scoping: a kb_id from another tenant returns 404 just like the read endpoint — no existence leak.

Rate limit: BUCKET_KB_RETRIEVAL at 30 req/min/tenant — same budget as the other outbound-call endpoints (MCP discovery, validate-llm, models-live).

Dual-surface model: this endpoint is one of three KB retrieval paths. The Java agent runtime queries Pinecone directly at deploy time via its own mirror (off the hot path through this BE); the streamkap-tools MCP server exposes streamkap_kb_retrieve and proxies through this endpoint for third-party agents.

POST/knowledge-bases/{kb_id}/retrieve
Authorization
AuthorizationBearer token · headerrequired
Path parameters
kb_idstringrequired
Request body
requiredapplication/json
querystringrequired
min length 1 · max length 4096
top_kinteger
min 1 · max 50 · default: 5
Responses
200

Successful Response

matchesKbRetrieveMatch[]required
Show properties
Array of KbRetrieveMatch
chunk_idstringrequired
textstring | null
Show properties
Any of:
string
string
null
null
scorenumberrequired
metadataobject | null
Show properties
Any of:
object
object
null
null
422

Validation Error

detailValidationError[]
Show properties
Array of ValidationError
locstring | integer[]required
Show properties
Array of string | integer
Any of:
string
string
integer
integer
msgstringrequired
typestringrequired
inputany
ctxobject
Request
curl -X POST 'https://api.streamkap.com/knowledge-bases/string/retrieve' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "query": "string",
  "top_k": 5
}'
Response
{
  "matches": [
    {
      "chunk_id": "string",
      "text": "string",
      "score": 0,
      "metadata": {}
    }
  ]
}