MemoryKit

Query Memories (RAG)

Retrieve context and generate an answer using an LLM.

Request body

FieldTypeRequiredDescription
querystringYesThe question to answer
modestringNofast, balanced (default), or precise
maxSourcesnumberNoMax sources to retrieve
instructionsstringNoSystem instructions for the LLM
userIdstringNoScope retrieval to a user

Response

{
  "answer": "Based on the Q4 planning notes, the main goals are...",
  "sources": [
    {
      "id": "chunk_abc123",
      "content": "Q4 goals include...",
      "score": 0.95,
      "memory_id": "mem_abc123"
    }
  ],
  "usage": {
    "tokens_used": 1250
  }
}

On this page