remember() method already runs this check internally; call this endpoint only when you need the result without the write.
Request
Headers
| Name | Required | Description |
|---|---|---|
X-API-Key | Yes | Your MemLayer API key (ml_live_xxx) |
Query Parameters
The candidate memory text to check. MemLayer embeds this text and compares it to existing memories for the given user-agent pair. Max 10,000 characters.
Check against memories belonging to this user.
Check against memories associated with this agent.
Cosine similarity threshold above which a memory is considered a duplicate. Range: 0.0–1.0. The default
0.95 matches the threshold used internally by POST /memories. Lower this to detect looser paraphrases; raise it to only flag near-identical text.Response
Success — 200
true if an existing memory scored at or above the threshold for the given content. false if no sufficiently similar memory was found — the content is safe to store.Errors
| Code | Meaning |
|---|---|
401 | Invalid or missing X-API-Key |
403 | Account suspended |
422 | Validation error — check parameter types and constraints |
Notes
remember() already checks for duplicates internally
remember() already checks for duplicates internally
You do not need to call
duplicate-check before every POST /memories. The store endpoint runs the same check automatically at the default threshold of 0.95 and returns a 409 if a duplicate is found. Use this endpoint when you specifically want to:- Check without committing (e.g. preview in a UI before storing)
- Use a different threshold than the default
0.95 - Track duplicate rates in your own analytics
- Gate a different code path based on whether the memory is new
Race condition between check and store
Race condition between check and store
There is a small window between a
duplicate-check returning false and your subsequent POST /memories call where another process could store the same memory. If you call both endpoints, handle a 409 from the store endpoint gracefully — it means a duplicate appeared in the interim. If strong deduplication guarantees matter, rely solely on the 409 from POST /memories rather than pre-checking.Tuning the threshold
Tuning the threshold
0.95(default) — catches near-verbatim duplicates. Paraphrases with different wording pass through.0.85— catches semantic paraphrases."User is in Lagos"and"User lives in Lagos, Nigeria"are likely flagged as duplicates.0.70— loose. Catches topically similar content even when phrased very differently. Use with care — may suppress genuinely distinct memories.
