"where does this user live?" and it surfaces "User is based in Lagos, Nigeria" even though no words overlap. Use this mid-conversation when the user raises a specific topic and you need targeted context fast.
Request
Headers
| Name | Required | Description |
|---|---|---|
X-API-Key | Yes | Your MemLayer API key (ml_live_xxx) |
Query Parameters
Natural-language search query. Max 1,000 characters. Phrase it the way you’d describe what you want to know —
"user's dietary restrictions" works better than a raw keyword like "diet".Return memories belonging to this user only. Must exactly match the value used when storing.
Return memories associated with this agent only. Must exactly match the value used when storing.
Maximum number of results to return. Range: 1–20. Only memories scoring above
min_score are included, so you may receive fewer than top_k results.Minimum hybrid score threshold. Range: 0.0–1.0. Memories scoring below this value are excluded. Lower values return more (but less relevant) results; higher values return only strong matches.
Optional filter. One of
episodic, semantic, or summary. Omit to search across all types.Response
Success — 200
Array of matching memories, ordered by descending hybrid score.
The query string echoed back from your request.
Number of memories returned in this response (after applying
min_score and top_k filters).Errors
| Code | Meaning |
|---|---|
401 | Invalid or missing X-API-Key |
403 | Account suspended |
422 | Validation error — check parameter types and constraints |
Notes
Understanding score_detail
Understanding score_detail
Use If an unexpected memory ranks first, check whether it has a disproportionately high recency or importance score pulling it above more semantically relevant results. Adjust the memory’s
score_detail to diagnose ranking behaviour:importance with a PATCH /memories/ call if needed.Tuning min_score
Tuning min_score
The default
0.70 strikes a balance between precision and recall for most use cases.0.85+— strict. Only surfaces memories with high semantic overlap. Use when false positives are costly (e.g. injecting wrong medical context).0.70(default) — balanced. Works well for general assistants.0.50— loose. Good for broad topic matching.0.0— returns everything up totop_k. Useful when debugging why nothing is returned.
Debugging empty results
Debugging empty results
If you receive
"total": 0, work through this checklist:- Confirm
user_idandagent_idexactly match the values used when storing. - Use GET /memories to verify that memories actually exist for this pair.
- Temporarily set
min_score=0.0— if results appear, your threshold is too high for this query. - Check that the memories haven’t expired (
expires_atin the past). - Ensure the
memory_typefilter (if set) matches what was stored.
