Documentation Index
Fetch the complete documentation index at: https://docs.openmem.blog/llms.txt
Use this file to discover all available pages before exploring further.
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
The user’s question or task description. The provider uses this to rank and select which memories to include in the context block.
The user whose memories to draw from. Context is always scoped to a single user.
Restrict the context to memories whose scope starts with this prefix (e.g.
coding to pull only coding-related memories).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
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.List of memory sources used to build the context block.
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: