Add
Write memories to FishMem from chat messages or raw text, with optional inference and scoping.
Adding is how you put information into FishMem. You send either a chat transcript or a raw string, and FishMem decides what's worth remembering. By default it runs inference: it reads the input, extracts durable facts, and reconciles them against what it already knows — emitting an ADD, UPDATE, or NOOP for each result.
Messages vs content
You have two ways to phrase the body:
messages— an array of{role, content}objects, exactly like a chat completion. Use this when you want FishMem to extract facts from a conversation. This is the common path.content— a single string. Use this for a standalone statement you want remembered.
Send one or the other, not both.
curl -X POST https://fishmem.com/v1/memories \
-H "Authorization: Bearer fm_..." \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "I moved to Berlin and I am vegetarian"},
{"role": "assistant", "content": "Got it, noted."}
],
"user_id": "alice"
}'const client = new MemoryClient({ apiKey, host: "https://fishmem.com" });
await client.add(
[
{ role: "user", content: "I moved to Berlin and I am vegetarian" },
{ role: "assistant", content: "Got it, noted." },
],
{ user_id: "alice" }
);Inference
infer defaults to true. With inference on, FishMem extracts and reconciles facts — one input can produce several results, or none. Set infer: false to store the input verbatim as a single memory, skipping extraction. Use raw mode when you already know exactly what you want stored.
Scoping
Attach user_id, agent_id, and/or run_id to bind a memory to a person, an agent, or a single session. Scope is what you later filter and search on — see scoping.
Parameters
| Field | Type | Notes |
|---|---|---|
messages | array | {role, content} items. Use instead of content. |
content | string | Single statement. Use instead of messages. |
user_id | string | Optional scope. |
agent_id | string | Optional scope. |
run_id | string | Optional scope. |
metadata | object | Optional arbitrary key/values. |
infer | boolean | Default true. false stores raw. |
Response
{
"results": [
{ "id": "mem_123", "memory": "Lives in Berlin", "event": "ADD" },
{ "id": "mem_124", "memory": "Is vegetarian", "event": "ADD" }
]
}event is one of ADD, UPDATE, or NOOP.
Credits
An inferred add costs 2 credits. A raw add (infer: false) costs 1 credit. (1000 credits ≈ $1.)
See the full contract at /api-reference/add.