Upload local files before creation¶
Upload local files before creating the knowledge base. If the upload is successful, only the file ID to be bound will be returned; it must be bound as the local_file source when creating the knowledge base and adding the data source.
POST https://moi.matrixorigin.cn/newmoi/semantic-models/local-files/upload
Preparation before calling¶
Prepare a personal access token and workspace ID that has permission to create a knowledge base for the target workspace. The request uses multipart/form-data, and the form field name is fixed to file.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/semantic-models/local-files/upload" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-F "file=@./product-guide.pdf"
Successful response¶
Returns 200 on success.
{
"code": "OK",
"msg": "OK",
"data": { "file_id": "file_01" }
}
Field |
Type |
Description |
|---|---|---|
|
string |
ID of the file to be bound. Pass |
In field paths, [] means each item in an array. For example, sources[] means each item in sources.
Common mistakes¶
HTTP Status Codes |
Error Codes |
Common Causes |
Recommended Actions |
|---|---|---|---|
|
|
|
Submit files using |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
No workspace creation permission. |
Check workspace authorization. |
Follow-up operations¶
Call Create knowledge base and add data source, and submit data.file_id and the original file name as the local_file source.