Skip to Content

Context

Assemble context

Get an engine's answer and the memories that relate to it in one call, and save the turn to memory.

POST/v1/context/assemble

Answers a question from an engine, recalls the related memories from a memory space, and saves the question and answer back to that space, all in one call. Use it to build an assistant turn without separate query, recall, and write requests.

Body

engine_idstring<uuid>required

The engine to answer from.

querystringrequired

The question, up to 4,000 characters.

memory_space_idstring<uuid> | null

The memory space to recall from and save the turn to. Leave it out to get only the engine's answer.

user_refstring | null

Your own reference for the person asking, stored with the saved turn.

top_kintegerdefault: 8

How many chunks the engine searches for, from 1 to 50.

query_modestringdefault: precise

The answer mode. See Answer modes.

write_to_memorybooleandefault: true

Save the question and answer as a memory in memory_space_id.

Memory context comes from the space's space-level memory. To recall one person's memories in a multi-user space, call Search memories with an end_user.

Response

answerstringrequired

The engine's answer.

citationsobject[]required

The chunks the answer is based on.

confidencenumberrequired

How well the sources support the answer, from 0 to 1.

memory_contextobject[]required

Up to 5 related memories, each with id, content, memory_type, and confidence_score. Empty without a memory_space_id.

memory_writtenbooleanrequired

Whether the turn was saved to memory.

query_modestringrequired

The answer mode that was used.

Status codes

StatusMeaning
200The engine answered, and memory was read and written as requested.
400The question couldn't be answered as sent.
401The key is missing, malformed, or revoked.
403The key's capability or scope doesn't allow reading this engine or using this memory space.
404The engine or memory space doesn't exist in the key's workspace.
422A field is missing or invalid.