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/searchRun Hybrid Search against one authorized knowledge base
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 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

FieldRequiredDescription
kb_idYesKnowledge base ID to search
queryYesNon-empty search text
modeNoOnly hybrid is supported and it is the default
limitNoDefaults to 8 and is clamped to 1–50
min_scoreNoDefaults to 0.18 and is clamped to 0–1
document_idNoRestrict 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

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 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 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 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, 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_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.