Chat

Chat

POST
/
chat
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 = {
  "user_id": "memos_user_123",
  "conversation_id": "memos_chat_conv",
  "query": "Introduce MemOS to me"
}
headers = {
  "Content-Type": "application/json",
  "Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/chat"

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

print(f"result: {res.json()}")
{
  "code": 0,
  "data": {
    "response": "<string>"
  },
  "message": "<string>"
}

Authorizations

Authorization
string
header
required

Token API_key, available in API Console > API Keys

Body

application/json
user_id
string
required
Unique identifier of the user associated with the conversation.
conversation_id
string
required
Unique identifier of the conversation. Providing this clarifies the current session, prioritizing its memory over historical sessions. If omitted, cross-session memory retrieval is performed for more relevant responses.
query
string
required
User input content.
filter
object
Filter conditions, used to precisely limit the memory scope before retrieval. Available fields include: "agent_id", "app_id", "create_time", "update_time", and specific fields in "info". Supports logical operators (and, or) and comparison operators (gte, lte, gt, lt). For the "info" field, supports filtering by "business_type", "biz_id", "scene", and other custom fields.
Example:
"{"and": [{"create_time":{"gte":"..."}}]}"
knowledgebase_ids
string[]
Specifies the scope of Knowledge Bases accessible for the current search. Defaults to empty, meaning no Knowledge Bases are searched. Pass specific Knowledge Base IDs to search ordinary documents and uploaded Skills in those Knowledge Bases; pass "all" to search across all associated Knowledge Bases within the project.
memory_limit_number
number
default: 9
Maximum number of memories that can be recalled: as long as the relevance threshold (relativity) is met, up to this many memories may be returned. Default is 9, maximum is 25.
include_preference
boolean
default: true
Whether to recall preference memories. When enabled, the system intelligently recalls memories related to user preferences based on the query. Default = true.
preference_limit_number
number
default: 9
Maximum number of preferred memories that can be recalled: as long as the relevance threshold (relativity) is met, up to this many preference memories may be returned. Default is 9, maximum is 25.
relativity
number
default: 0.45
Relevance threshold (0–1) for recalled memories. Filters out low-relevance memories and, together with the maximum counts for factual and preferred recalls, constrains the final results. When omitted, the system default threshold is used. A value of 0 disables relevance filtering.
model_name
string
default: qwen2.5-72b-instruct
Specifies the concrete conversation model.
Enum:"qwen3-32b""deepseek-r1""qwen2.5-72b-instruct"
system_prompt
string
Custom system instructions.
stream
boolean
default: false
Whether to enable streaming response.
max_tokens
number
default: 8192
Indicates the maximum number of generated tokens.
temperature
number
default: 0.7
Controls generation randomness. Range: 0 ≤ x ≤ 2.
top_p
number
default: 0.95
Nucleus sampling parameter. Range: 0 ≤ x ≤ 1.
add_message_on_answer
boolean
default: true
Whether to automatically write user and assistant conversation content into memory. When enabled, developers do not need to call the add/message API to add messages as memory.
app_id
string
Unique identifier of the application associated with the conversation.
agent_id
string
Unique identifier of the Agent associated with the conversation.
tags
string[]
List of custom tags used to mark the topic or category of the conversation.
info
object
Custom metadata field capable of storing any structured data related to the conversation, such as location, source, version, etc., primarily for precise filtering or source tracking during retrieval.
allow_public
boolean
default: false
Whether to allow adding to public memory.
allow_knowledgebase_ids
string[]
List of knowledgebases where memories generated from added messages are allowed to be written.

Response

Successful Response

code
number
required

API status code. See Error Code List for details.

data
object
Show child attributes
message
string
required

Message