Create Knowledgebase File
Upload a document to a specified knowledgebase.
POST
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()}")
# Ensure MemoS is installed (pip install MemoryOS -U)
from memos.api.client import MemOSClient
# Initialize client with API Key
client = MemOSClient(api_key="YOUR_API_KEY")
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"
}
]
res = client.add_knowledgebase-file(knowledgebase_id=knowledgebase_id,file=file)
print(f"result: {res}")
curl --request POST \
--url https://memos.memtensor.cn/api/openmem/v1/add/knowledgebase-file \
--header 'Authorization: Token YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"knowledgebase_id": "basec32f88c6-9dd3-4061-82c8-f0fa0e85a284",
"file": [
{
"content": "https://cdn.memtensor.com.cn/file/出差报销额度说明.docx"
}
]
}'
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 documents to upload
Show child attributes
Response
application/json
Successful Response
code
number
required
API status code. See Error Code for details.
data
object
Show child attributes
message
string
required
API response message
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()}")
# Ensure MemoS is installed (pip install MemoryOS -U)
from memos.api.client import MemOSClient
# Initialize client with API Key
client = MemOSClient(api_key="YOUR_API_KEY")
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"
}
]
res = client.add_knowledgebase-file(knowledgebase_id=knowledgebase_id,file=file)
print(f"result: {res}")
curl --request POST \
--url https://memos.memtensor.cn/api/openmem/v1/add/knowledgebase-file \
--header 'Authorization: Token YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"knowledgebase_id": "basec32f88c6-9dd3-4061-82c8-f0fa0e85a284",
"file": [
{
"content": "https://cdn.memtensor.com.cn/file/出差报销额度说明.docx"
}
]
}'