# Move from Supermemory

> Bring a Supermemory account into Alexein with one command, then change a few calls. How namespaces, documents, memories and profiles map, and what does not carry over.

Supermemory keeps documents and memories per namespace (`containerTag` before its v5 API). Alexein keeps items per
app user, named by the `X-Alexein-User` header. Moving takes two steps: one command copies every namespace's
documents and memories into an app user of the same id, and then your code swaps a handful of calls.

Supermemory's v3 and v4 API closes on 31 December 2026, and v5 changes every call. If you are rewriting those calls
anyway, you can write them for Alexein instead.

## 1. Import your Supermemory account

Set both keys, look at what would be added, then add it:

**Python**

```bash title="Terminal"
export SUPERMEMORY_API_KEY=sm_...    # your Supermemory API key
export ALEXEIN_API_KEY=ax_...        # a read and write API key, from the Console
uvx alexein-cli import supermemory --dry-run
uvx alexein-cli import supermemory
```
**TypeScript**

```bash title="Terminal"
export SUPERMEMORY_API_KEY=sm_...    # your Supermemory API key
export ALEXEIN_API_KEY=ax_...        # a read and write API key, from the Console
npx @alexein/cli import supermemory --dry-run
npx @alexein/cli import supermemory
```

```text title="Output"
Importing Supermemory into Acme/Production, reads and writes.
  user_4f8a -> user_4f8a  documents 212/212 read, 210 added
  user_4f8a -> user_4f8a  memories 540/540 read, 131 added
  user_9c1d -> user_9c1d  documents 18/18 read, 18 added
  user_9c1d -> user_9c1d  memories 61/61 read, 42 added
Added 401 items for 2 app users; left out 2 no text, 412 learned from an imported document, 16 inferred and never confirmed.
Each user's app user id is after its ->: your app sends it as X-Alexein-User.
```

It reads every namespace your key can see, and each one's documents, with their text, and memories. It adds the
documents, and the memories that did not come from them, to Alexein, 500 at a time. Namespaces written with `containerTag` on v3 or v4 are read the same way: they are the
same names. The dry run reads everything and prints the first item as it would be added, and adds nothing.

- **Run it again at any time.** Every item's id comes from its Supermemory id, so a second run edits the items the
  first one added and never copies them. An import that stops names the namespace it stopped at: run it again,
  with `--from` that namespace to carry on from there.
- **Namespaces stay as they are.** A namespace becomes the app user of the same id. Only one that cannot be a
  header, longer than 128 characters or not plain ASCII, becomes a stable `u_…` digest: the output says which, so
  keep it. See [App users](/concepts/app-users#the-id-rule).
- **Some namespaces, or some of each.** `--from <namespace>` imports only that namespace (repeat it for more), so
  `sm_project_default` and test namespaces can stay behind. `--only documents` brings the documents alone, and
  `--only memories` every memory and no document. With `--user <id>`, the one namespace you name goes into the app user you choose. A
  [personal key](/concepts/personal-memory) imports one namespace into your own memory.
- **Keys stay private.** The Supermemory key is read from `SUPERMEMORY_API_KEY` only and is never printed. The
  Alexein key is the one the CLI already uses: `--key`, `ALEXEIN_API_KEY` or `alexein login`.

> **Which memories come across**
>
> Alexein learns its own facts from the documents you import, so a memory Supermemory learned from one of those
> documents would only say the same thing twice: it is left out. So is a memory Supermemory inferred and nobody
> confirmed. The memories that come across are the ones that came from no imported document: those your app added
> as memories, inferred ones a person confirmed, and those of a document that had no text to import. The last line
> counts each kind left out.

## How the concepts map

| Supermemory                                   | Alexein                                                                                          |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Namespace (`containerTag` in v3 and v4)       | The app user, named by the `X-Alexein-User` header. One app user per namespace.                  |
| A document (`content`, `title`)               | An item of kind `document`, with its text and `title`.                                           |
| A memory (`memory` text)                      | An item of kind `note`, when it came from no imported document. A static memory carries `supermemory_static: true` in `metadata`. |
| Document or memory `id` (`customId` before v5) | Item `id` `supermemory-doc-<id>` or `supermemory-mem-<id>`, and `supermemory_id` in `metadata`. |
| `system.createdAt`                            | `at`: when Supermemory took the item in. A document's own `date` is not in what the import reads. |
| `metadata`                                    | `metadata` as it was, with `imported_from: "supermemory"` and `supermemory_id` added, and a document's `supermemory_url` and `supermemory_type` when it has them. Filterable. |
| A conversation added under one `id`           | Items of kind `message`, one per turn, each with its `role`, in one `session`.                   |
| `date` (`documentDate` before v5), when you add | `at`, in the code you change.                                                                  |
| `filter`                                      | [`filters`](/concepts/filters), on `author`, `mentions` and `metadata` keys.                     |
| Profile (`static`, `dynamic`, buckets)        | [`profile`](/api/profile): what is true about the person now, as one text for a system prompt. [`summary`](/api/summary) has every line, and every search also starts with what is known. |

## 2. Change your code

Each Supermemory call has one counterpart. The namespace moves from the first argument to `user()`, and is sent as
the header, never as a field a model could fill in.

**TypeScript**

```ts title="Before: Supermemory v5"
import { Supermemory } from "supermemory";

const client = new Supermemory({ apiKey: process.env.SUPERMEMORY_API_KEY });

await client.add("user_123", {
  content: "user: I moved to Lisbon.\nassistant: Congratulations!",
  id: "conv_1",
});
const { results } = await client.search("user_123", { query: "Where does the user live?" });
const { profile } = await client.profile("user_123");
const { documents } = await client.list("user_123", "documents");
await client.documents.delete("user_123", { ids: ["conv_1"] });
await client.namespaces.delete("user_123");
```

```ts title="After: Alexein"
import { Memory } from "@alexein/sdk";

const user = new Memory().user("user_123"); // ALEXEIN_API_KEY

await user.add(
  [
    { text: "I moved to Lisbon.", role: "user", author: { self: true } },
    { text: "Congratulations!", role: "assistant" },
  ],
  { session: "conv_1" },
);
const found = await user.search("Where does the user live?");
const promptContext = found.context(); // ready for a system prompt
const { text: profile } = await user.profile(); // for your system prompt
for await (const item of user.iterItems()) console.log(item.id, item.text);
await user.forget({ sessions: ["conv_1"] });
await user.delete();
```
**Python**

```python title="Before: Supermemory v5"
from supermemory import Supermemory

client = Supermemory()  # SUPERMEMORY_API_KEY

client.add("user_123", content="user: I moved to Lisbon.\nassistant: Congratulations!", id="conv_1")
results = client.search("user_123", query="Where does the user live?")
profile = client.profile("user_123").profile
```

```python title="After: Alexein"
from alexein import Memory

user = Memory().user("user_123")  # ALEXEIN_API_KEY

user.add(
    [
        {"text": "I moved to Lisbon.", "role": "user", "author": {"self": True}},
        {"text": "Congratulations!", "role": "assistant"},
    ],
    session="conv_1",
)
found = user.search("Where does the user live?")
prompt_context = found.context()  # ready for a system prompt
profile = user.profile().text  # for your system prompt
everything = list(user.iter_items())
user.forget(sessions=["conv_1"])
user.delete()
```

| Supermemory v5                                | Alexein                                                                                          |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `add(namespace, { content, id })`             | [`add`](/api/add): a conversation's turns as `message` items in one `session`; a text as a `document` with a `title`; a single statement as a `note`. |
| `documents.batchAdd`                          | `add` with a list: up to 500 items a request, more sent in batches for you.                      |
| `search(namespace, { query })`                | [`search`](/api/search). `context()` gives the text to put in a prompt.                         |
| `profile(namespace)`                          | [`profile`](/api/profile): what is true about the user now, as text for a system prompt.         |
| `list(namespace, "documents")`                | [`items`](/api/items), newest first and paged: what you added, as you sent it.                   |
| `documents.get(namespace, id)`                | [`item`](/api/item), by its id.                                                                  |
| `documents.update` / add again with an `id`   | `add` again with the same `id`, only to fix the same statement. When something changed, add a new item. |
| `documents.delete(namespace, { ids })`        | [`forget`](/api/forget) with `items`, or `sessions` for a whole conversation.                    |
| `memories.forget(namespace, { ids })`         | [`forget`](/api/forget) with `refs`, for a fact search returned.                                 |
| `namespaces.delete(namespace)`                | [`users/delete`](/api/users/delete), or delete the app user in the console.                     |
| `namespaces.list()`                           | [`users`](/api/users): every app user of the project, with how much each holds.                  |
| `withSupermemory(model, …)`                   | [Automatic memory](/guides/automatic-memory): wrap the Anthropic or OpenAI client, or the AI SDK model. |

## What changes

- **Searchable at once.** An add is searchable within seconds, with nothing to set. Its facts follow, usually
  within minutes; [`status`](/api/status) says how far each item has got.
- **Search returns more than a list.** A search answers with what is known about the people and things asked
  about, dated facts and the excerpts behind them, each with a ref. There are no modes, thresholds or rewrites to
  set; `fast` trades a little precision for speed. See [Search](/concepts/search).
- **Nothing is overwritten for you.** A later value does not replace an earlier one: both are kept with the day each
  was said, and search shows the newest first. See [Values and history](/concepts/values-and-history).
- **An edit is for a mistake.** Adding again under a Supermemory `id` adds to that document. Here, the same `id`
  replaces the item's text, so send it again only to fix the same statement. New turns of a conversation are new
  items in the same `session`. See [Versions and edits](/concepts/versions).

## What does not carry over

- **Memories learned from an imported document.** Memory learns its own facts from the document, so these are
  left out and counted. `--only memories` brings every memory instead, with no documents.
- **Inferred memories nobody confirmed.** These are left out and counted; a confirmed one comes across.
- **Chunks and memory links.** Supermemory's chunks of a document, and the links between its memories, are not
  copied. Alexein searches a document in excerpts of its own and learns how things relate from what it holds.
- **Forgotten memories and earlier versions.** Supermemory lists only the newest version of each memory and hides
  forgotten ones, so neither is imported.
- **Documents with no text yet.** A document still processing for the first time, or whose first processing
  failed, has no text to bring: the output counts it as `no text`. Run the import again once it is done. One whose
  later replacement failed keeps its earlier text, and that comes across.
- **Files themselves.** An uploaded file comes across as the text Supermemory took from it, with its `url` in
  `metadata` as `supermemory_url`, not as the file.
- **Very large documents.** A document over 950 KB is left out and counted. Split it, and add the parts as
  documents of their own.
- **Profiles, buckets and settings.** Memory builds what it knows of each person from what is imported, so
  [`profile`](/api/profile) and [`summary`](/api/summary) fill in over time. Profile buckets, a namespace's
  `supportingContext`, connectors and organisation settings are not copied.

## 3. Check

Search for a namespace you know well, or ask how far an item has got:

**Python**

```bash title="Terminal"
uvx alexein-cli search "Where does the user live?" --user user_4f8a
uvx alexein-cli status supermemory-doc-conv_1 --user user_4f8a
```
**TypeScript**

```bash title="Terminal"
npx @alexein/cli search "Where does the user live?" --user user_4f8a
npx @alexein/cli status supermemory-doc-conv_1 --user user_4f8a
```

`stored` means searchable, and `processed` means its facts are ready.
