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 | Run Hybrid Search against one authorized knowledge base |
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 workspace 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":"How many days of paternity leave are available?","mode":"hybrid","limit":8,"min_score":0.18}'Request fields
| Field | Required | Description |
|---|---|---|
kb_id | Yes | Knowledge base ID to search |
query | Yes | Non-empty search text |
mode | No | Only hybrid is supported and it is the default |
limit | No | Defaults to 8 and is clamped to 1–50 |
min_score | No | Defaults to 0.18 and is clamped to 0–1 |
document_id | No | Restrict search to one document in the knowledge base |
Successful response:
{
"request_id": "req_abc123",
"data": {
"kb_id": "kb_xxx",
"query": "How many days of paternity leave are available?",
"limit": 8,
"min_score": 0.18,
"count": 1,
"mode": "hybrid",
"warnings": [],
"results": [{
"chunkId": "chunk_xxx",
"documentId": "doc_xxx",
"content": "Employees may request paternity leave...",
"score": 0.82,
"pageIndex": 2,
"pageImageUrl": null,
"figureImageUrl": null,
"metadata": {}
}]
}
}Result fields vary by chunk 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.
This endpoint retrieves chunks only; it does not call an answer model. To obtain a generated answer grounded in a knowledge base, call the OpenAI-compatible chat completions API with a Customize Model whose RAG is configured.
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 boost knowledge base chunk rankings and has no no-review/creator-review/admin-review modes. Those claims in the older document did not match the implementation.
- 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 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, Milvus, 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
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.