Create a chat completion
Drop-in replacement for OpenAI's /v1/chat/completions, with Truememory's persona and memory layers applied to every turn. Supports tools, streaming and all standard parameters.
The response comes in one of two shapes, depending on stream:
stream: false(default) — a single JSONChatCompletionResponse.stream: true—text/event-streamofdata:lines, each an OpenAI-style chunk, terminated bydata: [DONE].
https://truememory-api.mvstg.com/v1/chat/completionsAuthorization
Header parameters
Request bodyJSONrequired
- max_history_tokensoptional
Cap the replayed thread history to roughly this many tokens, keeping the most recent turns (the window starts on a human turn). Older turns are dropped from the replay — callers that set this should supply their own running summary so older context is preserved. Omit (default) to replay the full history unchanged.
- system_prompt_cache_contractoptionallegacyorexplicit
How to read multi-block system content. "legacy" (default, unchanged behaviour): a block list with no
cache_controlmarker anywhere is treated as entirely STABLE — the historical reading, so existing callers that use block lists for structure are unaffected. "explicit": markers are the caller's cacheability declaration — blocks through the last marked one are stable, later blocks are dynamic, and a list with NO marker means nothing is cacheable. Opt in only if you place markers deliberately: under "explicit" an unmarked system prompt is delivered as per-request context inside the user turn, not as a system message.default: "legacy" - context_managementoptional
Context-management strategies for this request. At most one entry is supported. Include a
{"type": "compaction", ...}entry to enable thread compaction: when the upcoming request is over budget (compact_thresholdwhen set, else the model's context window minus a buffer), older turns fold into a rolling summary checkpoint before the model call runs; subsequent turns replay the checkpoint plus newer messages instead of the full transcript. The thread's stored history is never modified. Omit to disable. - parent_message_idoptional
ID of the last stored message the client received. When set, anything already stored after it is not appended again, so a request that failed mid-run can be re-sent unchanged.
messagesholds the messages after it, optionally preceded by replayed history that ends at it; that history is dropped exactly as it is without this field. Use themessage_idfrom the previous response. Ignored withoutthread_id: a turn with no thread has no stored state. - skill_selectionoptionalofforauto
autolets Truememory pick skills for this turn by matching the user's message against each visible skill'suse_caseanddetection_patterns. Only skills the caller could already list are considered, and only ones carrying trigger data. Combines withskills: explicit keys always apply, matches are added after them. Defaults tooff— no existing caller changes behaviour.default: "off" - skillsoptionalarray ofstring
Skill keys to resolve from the registry and inject, in the order given. Truememory reads each skill's stored
prompt, so the registry stays authoritative instead of each caller pasting a copy. A key you cannot see is a 404, never a silent drop. Resolved prompts are injected beforeskill_instructions, which still works and can be used alongside them for per-request text. - skill_filesoptionalboolean
Let the model read the files of this turn's skills (from
skillsandskill_selection): each such skill's file list follows its prompt, and the model gets aread_skill_filetool. Off by default, so a skill injects only itsprompt, as before. Ignored on a deployment without skill file storage.default: false - brain_idsoptional
Brain IDs whose knowledge packs are searched and injected into the system prompt. All named brains are resolved to one deduplicated set of knowledge_pack_ids before context injection. Every ID must be readable by the caller — an unknown or unreachable one is a 404, not a silent drop. Ignored when knowledge_pack_ids is also provided.
- mind_idsoptional
Minds whose memory namespaces are blended into per-message retrieval alongside the user's own memory. Each is resolved through the mind read gate, so only minds the caller can actually read take effect; an unknown or unreachable id is a 404, not a silent drop. Namespace facts appear in the injected memory context — conversation ingestion still writes only to the user's own graph.
Returns
200
A chat completion. JSON when stream is false; an SSE stream of chunks when it is true.