Skip to content

Lessons

What an assistant should know before a task like this one - how the person corrected assistants and the notes they left on answers - most relevant first.

POST/v2/memory/lessonsTry it in the Playground
Auth
read key
Cost
free; never refused for your plan

Lessons are what the person has taught assistants: how they corrected one ("keep drafts for Ada under 100 words"), and the notes they left on answers, through feedback among others. Call it with the task at hand before your agent starts it, such as drafting an email or planning a trip, so it does not repeat a mistake the person already pointed out.

The answer is cards, the lessons most like task first, each with the refs of the facts it cites, then lessons, what earlier attempts at similar tasks taught. Only what the person said becomes a lesson: what someone else asked for is theirs, and is not here.

Headers

Authorizationstringrequired

Bearer tm_…. A read key is enough.

X-Alexein-Userstringrequired

The app user whose memory to read. See App users.

X-Request-Idstring

Your id for this request, echoed on the response.

Body

taskstringrequired

The task at hand, in plain words. 1 to 2,000 characters.

Response

taskstring

The task as sent.

cardsobject[]

Lessons from the person, most like task first, each {kind: "lesson", text, from, refs}. from says what it came from: correction (the person correcting an assistant), feedback (a note they left on an answer) or said. Each text is a line for your model; don't parse it.

lessonsobject[]

What earlier attempts at similar tasks taught, each {kind, text}: kind is strategy (what worked), failure (what went wrong and how to avoid it) or workflow (a sequence of steps worth reusing).

For an app user with no memory yet it answers 200 with both lists empty.

Errors

400bad request

X-Alexein-User is missing or not a usable id.

401unauthorized

The bearer is not a key this service issued.

403forbidden

The organisation has been closed in the console.

422invalid

A field is out of bounds. detail names the field.

429too many requests

Too many requests in flight, or reads too fast. Retry after Retry-After seconds. See Limits.

503unavailable

The service is busy or briefly unavailable. Retry after Retry-After seconds, or with backoff when there is none.

Request
curl https://api.alexein.ai/v2/memory/lessons \
  -H "Authorization: Bearer $ALEXEIN_API_KEY" \
  -H "X-Alexein-User: user_42" \
  -H "Content-Type: application/json" \
  -d '{ "task": "Draft a reply to Ada about the launch" }'
200 OK (shortened)
{
  "task": "Draft a reply to Ada about the launch",
  "cards": [
    {
      "kind": "lesson",
      "text": "Keep drafts for Ada under 100 words",
      "from": ["correction"],
      "refs": ["mem_3wE8rT5yUi2"]
    }
  ],
  "lessons": []
}