Knowledge Base and Feedback APIs
Search an authorized knowledge base from an external service and submit ratings or explicitly authorized feedback memories for a Customize Model.
The Runtime exposes two endpoints intended for backend integrations:
| Endpoint | Purpose |
|---|---|
POST /v1/kb/search | Search complete parsed text in one authorized knowledge base with KB Super |
POST /v1/feedback | Submit a good/bad rating and, when all conditions are met, store positive content as Customize Model memory |
Both use the Runtime Base URL and a Bearer API key. Call them from a trusted backend; never embed the key in a browser or mobile application.
Shared authentication
Authorization: Bearer sk-your-api-key
Content-Type: application/jsonAn API key does not grant additional asset permissions. Knowledge base search still checks whether the represented user or project or personal account can access the requested knowledge base. Feedback must resolve to an accessible Customize Model before it can create memory.
Search a knowledge base
curl -X POST "$UNIEAI_RUNTIME_BASE_URL/v1/kb/search" \
-H "Authorization: Bearer $UNIEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"kb_id":"kb_xxx","query":"paternity leave","mode":"unieai_kb_supra","limit":8}'Request fields
| Field | Required | Description |
|---|---|---|
kb_id | Yes | Knowledge base ID to search |
query | Yes | Non-empty search text |
mode | No | Defaults to unieai_kb_supra; hybrid is a compatibility alias that also runs KB Super full-text search |
limit | No | Defaults to 8 and is clamped to 1–50 |
min_score | No | Compatibility field: defaults to 0.18, is clamped to 0–1 and echoed in the response; it does not filter KB Super results |
document_id | No | Restrict search to one document in the knowledge base |
Successful response:
{
"request_id": "req_abc123",
"data": {
"kb_id": "kb_xxx",
"query": "paternity leave",
"limit": 8,
"min_score": 0.18,
"count": 1,
"mode": "unieai_kb_supra",
"warnings": [],
"results": [{
"chunkId": "supra:42",
"documentId": "doc_xxx",
"content": "Employees may request paternity leave...",
"score": 1,
"pageIndex": null,
"pageImageUrl": null,
"figureImageUrl": null,
"metadata": { "lineNumber": 42 }
}]
}
}Result fields vary by result type. For page or Figure assets, the Runtime materializes externally loadable image URLs and replaces inline knowledge base asset keys in content. These URLs can expire and should not be stored permanently.
score is a text-match signal, not vector similarity or the probability of a correct answer. min_score does not remove KB Super matching lines. For missing results, check the query, scope, parsing status and active document version. This REST API's limit is separate from the agent retrieval count and Playground's model-sampling top_k.
This endpoint returns matching text and source locations; it does not call an answer model. For a generated answer, connect a KB to an agent using UnieAI Harness or UnieAI Harness Lite and call the OpenAI-compatible chat completions API. The general-model engine does not call KB tools.
Submit feedback
curl -X POST "$UNIEAI_RUNTIME_BASE_URL/v1/feedback" \
-H "Authorization: Bearer $UNIEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rating":"good","request_id":"req_from_chat","model":"your-custom-model-slug","comment":"Correct answer","memorize":true,"memory_content":"This product has a two-year warranty."}'Request fields
| Field | Required | Description |
|---|---|---|
rating | Yes | Must be good or bad |
request_id | No | A previous Runtime request ID; requestId is also accepted |
model | No | Customize Model slug used to resolve memory ownership |
custom_model_id | No | Explicit Customize Model ID; customModelId is also accepted |
comment | No | Written to memory metadata only when memory is actually created |
memorize | No | Must be the JSON boolean true to attempt memory creation |
memory_content | No | Non-empty content to store; memoryContent is also accepted |
Memory is created and synchronized only when all these conditions hold:
ratingisgood.memorizeis exactlytrue.memory_contentis non-empty.- The Runtime resolves a Customize Model from
custom_model_id,model, orrequest_id.
Successful response:
{
"success": true,
"rating": "good",
"memorized": true,
"memoryId": "memory_xxx"
}An accepted rating still returns 200 when no memory is created, but memorized is false and memoryId is null. The Runtime request ID is returned in the x-request-id response header.
Important current feedback limitations
/v1/feedback does not automatically change knowledge-base search ranking and has no no-review, creator-review or admin-review modes.
- A
badrating is validated and acknowledged, but this public endpoint currently creates neither a repair item nor model memory. - When memory conditions are not met, this handler does not separately persist
commentas model data. - Playground thumbs use a separate session-authenticated flow. A thumbs-down can enter the repair queue, while positive content can become pending or explicitly saved memory. Do not assume it is identical to
/v1/feedback. - Memory index synchronization is best-effort. The memory row can exist even if the separate index sync fails; inspect
memorizedandmemoryIdand monitor server logs.
Common errors
| HTTP status | Common causes |
|---|---|
400 | Missing kb_id/query, a mode other than unieai_kb_supra or hybrid, or rating other than good/bad |
401 | Missing or invalid API key |
403/404 | The key cannot use the model or access the requested knowledge base |
500 | Unexpected retrieval, database or memory-write failure |
Security and data handling
- Search results can contain original document text and temporary image URLs. Return them only to authorized callers.
memory_contentcan be retrieved in later conversations. Remove passwords, API keys, personal data, and unapproved content before storing it.- Use separate keys and quotas for each environment, and regenerate a key immediately if exposure is suspected.
Related documentation
API Key Management
Search Strategies
Memory System
chunkId is a compatibility identifier for a search result. KB Super does not create persistent vector chunks.
Agents API (sessions)
Call an agent through server-kept sessions — create, continue, stream live and read the record. Same interface as OpenAI's Agents API, served by every execution mode (UnieAI Harness, Harness Lite, plain model).
Feedback API
Submit good or bad ratings from an external application and explicitly save positive content as custom-model memory.