Import knowledge base definitions and semantic entries¶
Create knowledge bases from definitions and write their semantic entries in the same batch.
POST https://api.moi.matrixorigin.cn/v5/semantic-models/import
Before you call this API¶
Prepare current Workspace credentials and resource privileges. See Shared information for variables, import files, and operation boundaries.
Request body¶
curl -X POST "https://api.moi.matrixorigin.cn/v5/semantic-models/import" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
--data-binary @"$MODELS_IMPORT_JSON"
The example reads one FAQ definition from a JSON array file. After prevalidating items and dependencies, the service creates models and entries in one tenant transaction. It does not update by ID or synchronously complete upload, parsing, or index rebuilding. The request describes supported definition fields only, not complete backup/recovery of drawing configuration, vector indexes, chunk history, or all knowledge base states. Query first for unknown outcomes or errors; do not assume every error means nothing was created.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object or object[] |
Yes |
One object imports one definition; a nonempty array imports multiple. Response shape follows the root type. |
|
string |
Required for each item |
Knowledge base name; must be nonempty after trimming during import. |
|
string |
No |
Description; trimmed before saving. |
|
object[] |
No |
Source table declarations. Each contains db_name and a nonempty table_names string array. |
|
object |
No |
Source file declaration containing a file_ids string array, not uploaded file contents. |
|
object[] |
No |
Semantic entries for this knowledge base; an empty list means none. |
|
string |
No |
Choose nl2sql or rag by entry kind. See shared information for defaults and rules. |
|
string |
Required when entries exist |
Entry kind allowed by this domain, such as standard_qa in the example. |
|
string |
Required when entries exist |
Entry identifier within the same domain and kind. |
|
string[] |
No |
Source tables referenced by the entry; must match the model’s table set. |
|
JSON |
Required when entries exist |
Entry definition matching domain/kind. |
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"items": [
{
"id": 101,
"name": "Operations FAQ",
"tables": [],
"created_at": 1794408000,
"updated_at": 1794408000,
"source_counts": {
"files": 0,
"tables": 0,
"total": 0
},
"semantic_model_kind": "standard",
"drawing_number_policy": "overwrite_current"
}
],
"total": 1
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
OK on success. |
|
string |
Response information. |
|
object |
Current operation result. Single-object imports return a knowledge base object directly. |
|
object[] |
Creation results for array requests. For a single-object request, data directly contains one knowledge base object. |
|
integer |
Number of created objects returned for this array request, not the Workspace total. |
|
integer |
New knowledge base ID for subsequent details and source operations. |
|
string |
Saved name. |
|
string |
Description when present. |
|
JSON |
Source table declarations. |
|
JSON |
Source file declarations when present. |
|
integer |
Unix timestamp in seconds. |
|
integer |
Unix timestamp in seconds. |
|
object |
Count projection in the current creation response; does not establish completed parsing/indexing. |
|
string |
Knowledge base type; current imported definitions use standard model configuration. |
|
string |
Current model metadata. This request provides no drawing-specific configuration fields. |
Error responses¶
Success returns HTTP 201. Validation, dependency, or permission errors do not mean successful import. Retain request information and read back as described in Errors and environments.