Chat with MemOS (Complete Response)
Chat with MemOS for a specific user. Returns complete response (non-streaming).
This endpoint uses the class-based ChatHandler.
curl --request POST \
--url https://api.example.com/product/chat/complete \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "<string>",
"query": "<string>",
"readable_cube_ids": [
"<string>"
],
"writable_cube_ids": [
"<string>"
],
"history": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>",
"chat_time": "<string>",
"message_id": "<string>"
}
],
"mode": "fast",
"system_prompt": "<string>",
"top_k": 10,
"session_id": "<string>",
"include_preference": true,
"pref_top_k": 6,
"model_name_or_path": "<string>",
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"add_message_on_answer": true,
"filter": {},
"internet_search": false,
"threshold": 0.5,
"mem_cube_id": "<string>",
"moscube": false
}
'import requests
url = "https://api.example.com/product/chat/complete"
payload = {
"user_id": "<string>",
"query": "<string>",
"readable_cube_ids": ["<string>"],
"writable_cube_ids": ["<string>"],
"history": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>",
"chat_time": "<string>",
"message_id": "<string>"
}
],
"mode": "fast",
"system_prompt": "<string>",
"top_k": 10,
"session_id": "<string>",
"include_preference": True,
"pref_top_k": 6,
"model_name_or_path": "<string>",
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"add_message_on_answer": True,
"filter": {},
"internet_search": False,
"threshold": 0.5,
"mem_cube_id": "<string>",
"moscube": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: '<string>',
query: '<string>',
readable_cube_ids: ['<string>'],
writable_cube_ids: ['<string>'],
history: [
{
content: '<string>',
role: '<string>',
name: '<string>',
chat_time: '<string>',
message_id: '<string>'
}
],
mode: 'fast',
system_prompt: '<string>',
top_k: 10,
session_id: '<string>',
include_preference: true,
pref_top_k: 6,
model_name_or_path: '<string>',
max_tokens: 123,
temperature: 123,
top_p: 123,
add_message_on_answer: true,
filter: {},
internet_search: false,
threshold: 0.5,
mem_cube_id: '<string>',
moscube: false
})
};
fetch('https://api.example.com/product/chat/complete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/product/chat/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => '<string>',
'query' => '<string>',
'readable_cube_ids' => [
'<string>'
],
'writable_cube_ids' => [
'<string>'
],
'history' => [
[
'content' => '<string>',
'role' => '<string>',
'name' => '<string>',
'chat_time' => '<string>',
'message_id' => '<string>'
]
],
'mode' => 'fast',
'system_prompt' => '<string>',
'top_k' => 10,
'session_id' => '<string>',
'include_preference' => true,
'pref_top_k' => 6,
'model_name_or_path' => '<string>',
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'add_message_on_answer' => true,
'filter' => [
],
'internet_search' => false,
'threshold' => 0.5,
'mem_cube_id' => '<string>',
'moscube' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/product/chat/complete"
payload := strings.NewReader("{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/product/chat/complete")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/product/chat/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
Request model for chat operations.
User ID
Chat query message
List of cube IDs user can read for multi-cube chat
List of cube IDs user can write for multi-cube chat
Chat history
- ChatCompletionSystemMessageParam
- ChatCompletionUserMessageParam
- ChatCompletionAssistantMessageParam
- ChatCompletionToolMessageParam
Show child attributes
Show child attributes
search mode: fast, fine, or mixture
fast, fine, mixture Base system prompt to use for chat
Number of results to return
Session ID for soft-filtering memories
Whether to handle preference memory
Number of preference results to return
Model name to use for chat
Max tokens to generate
Temperature for sampling
Top-p (nucleus) sampling parameter
Add dialogs to memory after chat
Filter for the memory, example:
{
"`and` or `or`": [
{"id": "uuid-xxx"},
{"created_at": {"gt": "2024-01-01"}},
]
}
Whether to use internet search
Threshold for filtering references
Cube ID to use for chat
(Deprecated) Whether to use legacy MemOSCube pipeline
Response
Successful Response
curl --request POST \
--url https://api.example.com/product/chat/complete \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "<string>",
"query": "<string>",
"readable_cube_ids": [
"<string>"
],
"writable_cube_ids": [
"<string>"
],
"history": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>",
"chat_time": "<string>",
"message_id": "<string>"
}
],
"mode": "fast",
"system_prompt": "<string>",
"top_k": 10,
"session_id": "<string>",
"include_preference": true,
"pref_top_k": 6,
"model_name_or_path": "<string>",
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"add_message_on_answer": true,
"filter": {},
"internet_search": false,
"threshold": 0.5,
"mem_cube_id": "<string>",
"moscube": false
}
'import requests
url = "https://api.example.com/product/chat/complete"
payload = {
"user_id": "<string>",
"query": "<string>",
"readable_cube_ids": ["<string>"],
"writable_cube_ids": ["<string>"],
"history": [
{
"content": "<string>",
"role": "<string>",
"name": "<string>",
"chat_time": "<string>",
"message_id": "<string>"
}
],
"mode": "fast",
"system_prompt": "<string>",
"top_k": 10,
"session_id": "<string>",
"include_preference": True,
"pref_top_k": 6,
"model_name_or_path": "<string>",
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"add_message_on_answer": True,
"filter": {},
"internet_search": False,
"threshold": 0.5,
"mem_cube_id": "<string>",
"moscube": False
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: '<string>',
query: '<string>',
readable_cube_ids: ['<string>'],
writable_cube_ids: ['<string>'],
history: [
{
content: '<string>',
role: '<string>',
name: '<string>',
chat_time: '<string>',
message_id: '<string>'
}
],
mode: 'fast',
system_prompt: '<string>',
top_k: 10,
session_id: '<string>',
include_preference: true,
pref_top_k: 6,
model_name_or_path: '<string>',
max_tokens: 123,
temperature: 123,
top_p: 123,
add_message_on_answer: true,
filter: {},
internet_search: false,
threshold: 0.5,
mem_cube_id: '<string>',
moscube: false
})
};
fetch('https://api.example.com/product/chat/complete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/product/chat/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => '<string>',
'query' => '<string>',
'readable_cube_ids' => [
'<string>'
],
'writable_cube_ids' => [
'<string>'
],
'history' => [
[
'content' => '<string>',
'role' => '<string>',
'name' => '<string>',
'chat_time' => '<string>',
'message_id' => '<string>'
]
],
'mode' => 'fast',
'system_prompt' => '<string>',
'top_k' => 10,
'session_id' => '<string>',
'include_preference' => true,
'pref_top_k' => 6,
'model_name_or_path' => '<string>',
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'add_message_on_answer' => true,
'filter' => [
],
'internet_search' => false,
'threshold' => 0.5,
'mem_cube_id' => '<string>',
'moscube' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/product/chat/complete"
payload := strings.NewReader("{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/product/chat/complete")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/product/chat/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"<string>\",\n \"query\": \"<string>\",\n \"readable_cube_ids\": [\n \"<string>\"\n ],\n \"writable_cube_ids\": [\n \"<string>\"\n ],\n \"history\": [\n {\n \"content\": \"<string>\",\n \"role\": \"<string>\",\n \"name\": \"<string>\",\n \"chat_time\": \"<string>\",\n \"message_id\": \"<string>\"\n }\n ],\n \"mode\": \"fast\",\n \"system_prompt\": \"<string>\",\n \"top_k\": 10,\n \"session_id\": \"<string>\",\n \"include_preference\": true,\n \"pref_top_k\": 6,\n \"model_name_or_path\": \"<string>\",\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"add_message_on_answer\": true,\n \"filter\": {},\n \"internet_search\": false,\n \"threshold\": 0.5,\n \"mem_cube_id\": \"<string>\",\n \"moscube\": false\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}