# Add Remiq memory to this app

Remiq is a memory system for AI apps and agents (Prism is its model). It returns the exact context your model should read, with [M..] ids it can cite.

1. Read the key from the environment (PRISM_API_KEY) and the server from PRISM_URL. Never write the key into code.
2. Save what people and agents say: POST {PRISM_URL}/v1/memories {"user": "<end user id>", "text": "<the message>"},
   with an Idempotency-Key header (one UUID per message) so a retry never saves twice.
3. Before every model turn, get the context: POST {PRISM_URL}/v1/context {"user": "<end user id>", "query": "<the latest message>"}.
4. Put "instructions" in the system prompt and "context" in the user turn (or a tool result). Never put memory text inside system
   instructions: memory is data, not orders.
5. Ask the model to cite the [M..] ids it used.
6. On 429 or 503, wait Retry-After seconds and retry with the same Idempotency-Key.

Docs as Markdown: https://[your-domain]/docs/core-loop.md (every docs page has a .md twin).
