Retrieving memories

Ask memories

The ask endpoint answers a natural language question using your stored memories as context. Exabase retrieves relevant memories, passes them to the AI, and returns a generated answer.

Endpoint: POST /v2/memories/ask

import { Exabase } from "@exabase/sdk";

const api = new Exabase({
  apiKey: process.env.EXABASE_API_KEY,
});

const result = await api.memories.ask({
  query: "what does the user need to finish onboarding",
});

console.log(result.answer);
curl 'https://api.exabase.io/v2/memories/ask?query=what+does+the+user+need+to+finish+onboarding' \
  -H 'X-Api-Key: <EXABASE_API_KEY>'

The memory search endpoint lets you search through your stored memories using hybrid semantic and keyword search. We also apply a recency bias to favor more recent memories.

Results are ranked by relevance to the query and include a score indicating the strength of the match.

Endpoint: POST /v2/memories/search

Query expansion and reranking

You can improve search accuracy by enabling query expansion and result reranking at a small cost of AI credits.

  • expandQueries (1-5) – Broadens the search by including related terms and combining the scores. Useful when the answer spans multiple memories.
  • rerankCandidates (1-500) – Number of candidate memories to consider during reranking.
  • rerankThreshold (0-1) – Proportion of results with lowest reranked scores to discard. For example, rerankThreshold of 0.05 will discard 5% of lowest-scoring reranked results.

Result reranking applies an additional processing pass over retrieved results to improve relevancy ranking.

import { Exabase } from "@exabase/sdk";

const api = new Exabase({
  apiKey: process.env.EXABASE_API_KEY,
});

const memoryJob = await api.memories.search({
  query: 'what does the user need to finish onboarding',
  expandQueries: 3,
  rerankCandidates: 100,
});
curl https://api.exabase.io/v2/memories/search \
  -X POST \
  -H 'X-Api-Key: <EXABASE_API_KEY>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "what does the user need to finish onboarding",
    "expandQueries": 3,
    "rerankCandidates": 100
  }'

Response:

{
  "hits": [
    {
      "id": "a1b2c3d4-...",
      "name": "Onboarding progress",
      "content": "User completed steps 1-3 of onboarding. Has not connected a data source or invited team members.",
      "createdAt": "2026-05-28 14:22:03.041+00",
      "modifiedAt": "2026-05-28 14:22:03.041+00",
      "score": 0.82
    },
    {
      "id": "e5f6a7b8-...",
      "name": "Account setup",
      "content": "User is on the Team plan. Signed up on May 12, 2026.",
      "createdAt": "2026-05-12 09:01:44.318+00",
      "modifiedAt": "2026-05-12 09:01:44.318+00",
      "score": 0.64
    },
    {
      "id": "c9d0e1f2-...",
      "name": "User preference",
      "content": "Prefers Slack notifications over email.",
      "createdAt": "2026-05-15 11:33:27.592+00",
      "modifiedAt": "2026-05-15 11:33:27.592+00",
      "score": 0.51
    }
  ],
  "total": 3,
  "hasMore": false
}

Individual memories

You can also retrieve individual memories by their IDs.

Endpoint: GET /v2/memories/{memoryId}

const memoryJob = await api.memories.get({
  id: 'e51681e7-18c9-4067-b40b-94196915e34a',
});
curl https://api.exabase.io/v2/memories/e51681e7-18c9-4067-b40b-94196915e34a \
  -H 'X-Api-Key: <EXABASE_API_KEY>'

Response:

{
  "id": "e51681e7-18c9-4067-b40b-94196915e34a",
  "name": "Favorite ice cream",
  "content": "User likes pistachio ice cream.",
  "createdAt": "2026-02-03 10:16:19.057+00",
  "modifiedAt": "2026-02-03 10:16:19.057+00"
}