UnieAI Studio

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:

EndpointPurpose
POST /v1/kb/searchSearch complete parsed text in one authorized knowledge base with KB Super
POST /v1/feedbackSubmit 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/json

An 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

FieldRequiredDescription
kb_idYesKnowledge base ID to search
queryYesNon-empty search text
modeNoDefaults to unieai_kb_supra; hybrid is a compatibility alias that also runs KB Super full-text search
limitNoDefaults to 8 and is clamped to 1–50
min_scoreNoCompatibility field: defaults to 0.18, is clamped to 0–1 and echoed in the response; it does not filter KB Super results
document_idNoRestrict 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

FieldRequiredDescription
ratingYesMust be good or bad
request_idNoA previous Runtime request ID; requestId is also accepted
modelNoCustomize Model slug used to resolve memory ownership
custom_model_idNoExplicit Customize Model ID; customModelId is also accepted
commentNoWritten to memory metadata only when memory is actually created
memorizeNoMust be the JSON boolean true to attempt memory creation
memory_contentNoNon-empty content to store; memoryContent is also accepted

Memory is created and synchronized only when all these conditions hold:

  1. rating is good.
  2. memorize is exactly true.
  3. memory_content is non-empty.
  4. The Runtime resolves a Customize Model from custom_model_id, model, or request_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 bad rating 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 comment as 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 memorized and memoryId and monitor server logs.

Common errors

HTTP statusCommon causes
400Missing kb_id/query, a mode other than unieai_kb_supra or hybrid, or rating other than good/bad
401Missing or invalid API key
403/404The key cannot use the model or access the requested knowledge base
500Unexpected 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_content can 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.

chunkId is a compatibility identifier for a search result. KB Super does not create persistent vector chunks.