Skip to main content

Prerequisites

1. Encode a fact

Write a fact to the USER.gpu channel:
curl -X POST https://api.spectralmemory.com/encode \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "alice",
    "label": "USER.gpu",
    "value": "RTX5090"
  }'
{
  "status": "ok",
  "label": "USER.gpu",
  "value": "RTX5090",
  "channel": 3,
  "channel_count": 1
}
The fact is now encoded onto carrier channel 3 and persisted as a .mem file server-side.

2. Fetch the memory block

Retrieve the 512-token [MEM] block for system prompt injection:
curl "https://api.spectralmemory.com/context?user_id=alice" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "user_id": "alice",
  "fdm_block": "[MEM]magistrate yi GOP unprotected...[/MEM]",
  "channel_count": 1,
  "channel_labels": ["USER.gpu"],
  "plain_index": "USER.gpu=RTX5090"
}
Inject fdm_block into your agent’s system prompt. The Hermes3 reader model can decode it. Other models see an opaque token sequence.

3. Decode a fact

Read a specific channel value:
curl "https://api.spectralmemory.com/decode?user_id=alice&label=USER.gpu" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "user_id": "alice",
  "label": "USER.gpu",
  "value": "RTX5090",
  "source": "state",
  "latency_ms": 0
}
The default fast path reads from persistent state (~0ms). Pass use_model=true to verify via model inference instead.

4. Flush before compression

If your agent is about to compress its context, call /flush first:
curl -X POST https://api.spectralmemory.com/flush \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "alice"}'
{
  "status": "ok",
  "channel_count": 1,
  "lossless": true
}
A fresh [MEM] block is re-injected before compression fires. Facts survive into the next session intact.

Next steps

Install the Hermes plugin

Automate memory injection for every session.

Available channels

See all 40 labeled fact channels.