POST /context returns a single ranked, citation-tagged text block sized to your token budget. It is designed to be prepended directly to an LLM system prompt without any further processing. The provider selects and ranks the most relevant memories for the given query, formats them as prose, and reports which memory IDs it drew from.
Request body
string
required
The user’s question or task description. The provider uses this to rank and select which memories to include in the context block.
string
required
The user whose memories to draw from. Context is always scoped to a single user.
string
Restrict the context to memories whose scope starts with this prefix (e.g.
coding to pull only coding-related memories).integer
default:"500"
Maximum number of tokens the provider should use when constructing the returned
text. The provider will truncate or omit lower-ranked memories to stay within this budget.Response — 200 OK
string
required
The ranked, citation-tagged text block ready for LLM prompt injection. Citations are embedded inline (e.g.
[mem_abc123]) so the model can reference them.object[]
required
List of memory sources used to build the context block.
integer
The actual token count of the returned
text. May be null if the provider does not track token counts.Example
Python SDK equivalent
LLM integration
Prependctx.text to your system prompt to ground the model in the user’s memory: