Create Memory
curl --request POST \
--url https://api.example.com/api/v1/memories \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"metadata": {},
"agent_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/memories"
payload = {
"content": "<string>",
"metadata": {},
"agent_id": "<string>"
}
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({content: '<string>', metadata: {}, agent_id: '<string>'})
};
fetch('https://api.example.com/api/v1/memories', 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/api/v1/memories",
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([
'content' => '<string>',
'metadata' => [
],
'agent_id' => '<string>'
]),
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/api/v1/memories"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\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/api/v1/memories")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/memories")
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 \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}API Reference
Memories
添加记忆 - 异步队列处理
记忆添加操作通过 Celery 队列异步处理,防止 LLM 被打爆。 返回 task_id 可用于查询处理状态。
POST
/
api
/
v1
/
memories
Create Memory
curl --request POST \
--url https://api.example.com/api/v1/memories \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"metadata": {},
"agent_id": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/memories"
payload = {
"content": "<string>",
"metadata": {},
"agent_id": "<string>"
}
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({content: '<string>', metadata: {}, agent_id: '<string>'})
};
fetch('https://api.example.com/api/v1/memories', 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/api/v1/memories",
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([
'content' => '<string>',
'metadata' => [
],
'agent_id' => '<string>'
]),
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/api/v1/memories"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\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/api/v1/memories")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/memories")
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 \"content\": \"<string>\",\n \"metadata\": {},\n \"agent_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}The Memories API allows you to store, retrieve, search, and manage memories for your AI applications.
Create Memory
Create a new memory. The memory is processed asynchronously with AI classification.string
required
The memory content to store
string
default:"default"
Project ID for organizing memories
object
Additional metadata for the memory
Request
curl -X POST https://t0ken.ai/api/v1/memories \
-H "Content-Type: application/json" \
-H "X-API-Key: omx_your_api_key" \
-d '{
"content": "User prefers dark mode in all applications",
"project_id": "default",
"metadata": {
"source": "user_settings",
"category": "preferences"
}
}'
Response
{
"success": true,
"message": "Memory queued for processing",
"task_id": "abc123def456",
"status": "pending"
}
List Memories
Retrieve all memories for the authenticated user.string
Filter by project ID
integer
default:"100"
Maximum number of results
integer
default:"0"
Number of results to skip
Request
curl "https://t0ken.ai/api/v1/memories?limit=10" \
-H "X-API-Key: omx_your_api_key"
Response
{
"success": true,
"data": [
{
"id": "mem_123abc",
"content": "User prefers dark mode",
"project_id": "default",
"cognitive_sector": "semantic",
"importance_score": 0.85,
"created_at": "2026-02-13T10:00:00Z",
"updated_at": "2026-02-13T10:00:00Z"
}
],
"total": 1
}
Get Memory
Retrieve a specific memory by ID.curl https://t0ken.ai/api/v1/memories/mem_123abc \
-H "X-API-Key: omx_your_api_key"
Delete Memory
Delete a memory by ID.curl -X DELETE https://t0ken.ai/api/v1/memories/mem_123abc \
-H "X-API-Key: omx_your_api_key"
Response
{
"success": true,
"message": "Memory deleted successfully"
}
Search Memories
Search memories using vector similarity and keyword matching.string
required
Search query string
string
Filter by project ID
integer
default:"10"
Maximum number of results
Request
curl -X POST https://t0ken.ai/api/v1/memories/search \
-H "Content-Type: application/json" \
-H "X-API-Key: omx_your_api_key" \
-d '{
"query": "user preferences dark mode",
"limit": 5
}'
Response
{
"success": true,
"data": [
{
"id": "mem_123abc",
"content": "User prefers dark mode in all applications",
"score": 0.92,
"cognitive_sector": "semantic"
}
],
"query": "user preferences dark mode"
}
Cognitive Sectors
Memories are automatically classified into cognitive sectors:| Sector | Description | Example |
|---|---|---|
episodic | Specific events/experiences | ”User visited Paris in 2024” |
semantic | Facts and general knowledge | ”User prefers dark mode” |
procedural | Skills and how-to knowledge | ”User knows Python” |
emotional | Feelings and preferences | ”User enjoys sci-fi movies” |
reflective | Insights and summaries | ”User values privacy” |
Was this page helpful?