Skip to content

Quickstart

In this tutorial you store two facts about a project’s database, months apart, and then ask Alvia which database the project uses. You see Alvia return the fact that applies now, not both facts. It takes about ten minutes.

To see Alvia answer before you write code, open the dashboard, then Demo Project, then Playground. The Demo Project holds about 25 sample memories about Tidepool, a fictional habit-tracking app, including facts that changed and two that contradict each other. Choose Context and ask “Which database does Tidepool’s backend use?” or “How many habits does the free tier allow?”. The Playground shows each call as code in every REST language.

Playground calls use your normal read and write allowances. The Demo Project and its sample memories sit outside the project limit and the stored-memory limit.

  1. Sign in to the dashboard and create a project. A project holds its own memories, apart from every other project.

  2. In the project, create an API key and copy it now: Alvia stores only a hash of it, so the dashboard shows the full key this once. The key starts with sk-mem-.

  3. Save the key in an environment variable, so that it stays out of your code:

    Terminal
    export ALVIA_API_KEY="sk-mem-..."

Send the first fact with POST /v1/memories. The occurred_at field says when the fact was true: here, March 2026. In Python, Node.js and C#, keep all the code on this page in one script. In Node.js, name it quickstart.mjs, so that await works at the top level, and run it with node quickstart.mjs. In Go, add the code of each later step at the end of main.

POST /v1/memories
curl https://api.alvia.ai/v1/memories \
-H "Authorization: Bearer $ALVIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "The Atlas service uses MySQL 8 as its primary database.",
"occurred_at": "2026-03-02T09:00:00Z"
}'

Alvia answers 202 with an empty body. It has accepted the text and forms the memory in the background.

Six months later, the team moves Atlas to a new database. Send that fact with its own date:

POST /v1/memories
curl https://api.alvia.ai/v1/memories \
-H "Authorization: Bearer $ALVIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "The Atlas service moved its primary database from MySQL 8 to PostgreSQL 17.",
"occurred_at": "2026-09-23T14:00:00Z"
}'

Alvia compares the new fact with the memories it already holds. When it finds that a new fact replaces an earlier one, it records the new fact as the next version of the same memory. The earlier version stays in the memory’s history.

Formation finishes in less than a minute. Then ask a question with POST /v1/memories/context:

POST /v1/memories/context
curl https://api.alvia.ai/v1/memories/context \
-H "Authorization: Bearer $ALVIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "query": "Which database does the Atlas service use?" }'

Alvia returns one to three sentences. Your answer reads like this one:

Response
{
"context": "The Atlas service uses PostgreSQL 17 as its primary database. It moved from MySQL 8 on September 23, 2026."
}

The answer names the current database and the change, where a search over stored text would return MySQL 8 as an equal option.

In the dashboard, open the project’s Memories, then the Atlas memory. Its History tab lists both versions, each with when it occurred, when it was recorded, how Alvia classified it (Supersession for a fact that replaces another) and the classifier’s explanation. Your application reads the same history through the API.

Error What to do
401 unauthorized The key is missing, mistyped, expired or revoked. Check that ALVIA_API_KEY is set without printing its value.
400 validation_error The body has a mistake. The errors object names each field.
400 invalid_argument
occurred_at_in_future
The occurred_at value is in the future. Use a past time, with its time zone offset.
404 not_found From the context call: the memories are still forming. Try again in a minute.
429 rate_limit_exceeded You sent requests too fast. Wait for the seconds in the Retry-After header.

See Troubleshooting and Errors.