Knowledge Base

Create Knowledgebase File

Upload files to a specified Knowledge Base. By default, files are uploaded as documents. When file[].type is skill, upload a Markdown Skill file or ZIP Skill package.

POST
/
add
/
knowledgebase-file
import os
import requests
import json

# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "knowledgebase_id": "basec32f88c6-9dd3-4061-82c8-f0fa0e85a284",  # Replace with the Knowledge Base ID to upload documents to
  "file": [
    {"content": "https://cdn.memtensor.com.cn/file/出差报销额度说明.docx"}
  ]
}
headers = {
  "Content-Type": "application/json",
  "Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/add/knowledgebase-file"

res = requests.post(url=url, headers=headers, data=json.dumps(data))

print(f"result: {res.json()}")
{
  "code": 0,
  "data": [
    {
      "id": "<string>",
      "type": "document",
      "name": "<string>",
      "sizeMB": 0,
      "status": "running"
    }
  ],
  "message": "<string>"
}

Authorizations

Authorization
string
header
required

Token API_key, available in API Console > API Keys

Body

application/json
knowledgebase_id
string
required
Target Knowledgebase ID
file
object[]
required
List of files to upload. Ordinary documents follow the document parsing pipeline; Skill files follow the Skill validation and parsing pipeline.
Show child attributes

Response

application/json

Successful Response

code
number
required

API status code. See Error Code for details.

data
object[]

Processing results for uploaded files.

Show child attributes
message
string
required

API response message