curl -X POST https://api.60db.ai/memory/context \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": true
}'
const response = await fetch('https://api.60db.ai/memory/context', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-api-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: "What do you know about my preferences?",
top_k: 8,
max_context_length: 2000,
include_timeline: true,
}),
});
const data = await response.json();
console.log(data.data.prompt_ready);
import requests
response = requests.post(
"https://api.60db.ai/memory/context",
headers={
"Authorization": "Bearer your-api-key",
"Content-Type": "application/json",
},
json={
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": True,
},
)
data = response.json()
print(data["data"]["prompt_ready"])
{
"success": true,
"data": {
"context": {
"chunks": [
{
"chunk_id": "c_01HV...",
"source_id": "mem_01HV8K...",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
],
"sources": [
{
"source_id": "mem_01HV8K...",
"title": "Dietary preferences",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
]
},
"prompt_ready": "## User Memories\n- User prefers vegetarian food, lactose intolerant",
"message": "Context assembled from 1 memories and 0 recent events"
}
}
Memory & RAG
Assemble Context (RAG)
One-shot context assembly for LLM prompts — memories + timeline + graph
POST
/
memory
/
context
curl -X POST https://api.60db.ai/memory/context \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": true
}'
const response = await fetch('https://api.60db.ai/memory/context', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-api-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: "What do you know about my preferences?",
top_k: 8,
max_context_length: 2000,
include_timeline: true,
}),
});
const data = await response.json();
console.log(data.data.prompt_ready);
import requests
response = requests.post(
"https://api.60db.ai/memory/context",
headers={
"Authorization": "Bearer your-api-key",
"Content-Type": "application/json",
},
json={
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": True,
},
)
data = response.json()
print(data["data"]["prompt_ready"])
{
"success": true,
"data": {
"context": {
"chunks": [
{
"chunk_id": "c_01HV...",
"source_id": "mem_01HV8K...",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
],
"sources": [
{
"source_id": "mem_01HV8K...",
"title": "Dietary preferences",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
]
},
"prompt_ready": "## User Memories\n- User prefers vegetarian food, lactose intolerant",
"message": "Context assembled from 1 memories and 0 recent events"
}
}
Purpose-built for retrieval-augmented generation (RAG). Given a user query, the endpoint retrieves the most relevant memories, recent events, and graph relationships, then returns a pre-formatted context string ready to prepend to your LLM prompt.
This is the easiest way to add memory to your AI chat. One call → formatted context.
See Pricing & Billing for the full rate card.
Best practice: Always check if
Request
Headers
string
required
Bearer token with your API key
string
required
application/json
Body
string
required
The user’s query. This drives retrieval.
string
Chat session ID for hierarchical session context.
integer
default:"10"
Number of memories to retrieve. Max 100.
integer
default:"4000"
Maximum assembled context length in tokens. Older chunks truncated if exceeded.
boolean
default:"false"
Include knowledge-graph relationships.
boolean
default:"true"
Include recent events from EventStoreDB.
Response
string
The key field — a pre-formatted context string you can prepend directly to your LLM system message.
object
Structured context with separate
chunks, sources, graph_context, and timeline sections.string
Status message (e.g., “Context assembled from 8 memories and 3 recent events”).
Complete RAG example
curl -X POST https://api.60db.ai/memory/context \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": true
}'
const response = await fetch('https://api.60db.ai/memory/context', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-api-key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: "What do you know about my preferences?",
top_k: 8,
max_context_length: 2000,
include_timeline: true,
}),
});
const data = await response.json();
console.log(data.data.prompt_ready);
import requests
response = requests.post(
"https://api.60db.ai/memory/context",
headers={
"Authorization": "Bearer your-api-key",
"Content-Type": "application/json",
},
json={
"query": "What do you know about my preferences?",
"top_k": 8,
"max_context_length": 2000,
"include_timeline": True,
},
)
data = response.json()
print(data["data"]["prompt_ready"])
{
"success": true,
"data": {
"context": {
"chunks": [
{
"chunk_id": "c_01HV...",
"source_id": "mem_01HV8K...",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
],
"sources": [
{
"source_id": "mem_01HV8K...",
"title": "Dietary preferences",
"text": "User prefers vegetarian food, lactose intolerant",
"score": 0.92
}
]
},
"prompt_ready": "## User Memories\n- User prefers vegetarian food, lactose intolerant",
"message": "Context assembled from 1 memories and 0 recent events"
}
}
Billing
Flat **0.0005perquery∗∗—slightlyhigherthan‘/memory/search‘becausecontextassemblyalsoformatsanLLM−readypromptwithrecenteventsandoptionalgraphcontext.Achatapplicationdoing1,000turns/daycostsabout15/month. Response headers:| Header | Meaning |
|---|---|
x-credit-balance | Wallet balance after this charge |
x-credit-charged | 0.000500 |
x-billing-tx | Audit row UUID |
If the memory service is unreachable and the endpoint returns the graceful-degradation empty context (see below), you are not charged — the auto-refund guard reverses the deduction.
Graceful degradation
If the Memory service is unavailable,/memory/context returns prompt_ready: "" instead of failing. Your application can continue with no context — the SLM chat will still work, just without memory-grounded responses.
No-context response
{
"success": true,
"data": {
"context": { "chunks": [], "sources": [] },
"prompt_ready": "",
"message": "Memory system not ready — no context assembled"
}
}
prompt_ready is non-empty before prepending it.