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.
- 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
AuthorizationstringrequiredBearer tm_…. A read key is enough.
X-Alexein-UserstringrequiredThe app user whose memory to read. See App users.
X-Request-IdstringYour id for this request, echoed on the response.
Body
taskstringrequiredThe task at hand, in plain words. 1 to 2,000 characters.
Response
taskstringThe 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 requestX-Alexein-User is missing or not a usable id.
401unauthorizedThe bearer is not a key this service issued.
403forbiddenThe organisation has been closed in the console.
422invalidA field is out of bounds. detail names the field.
429too many requestsToo many requests in flight, or reads too fast. Retry after Retry-After seconds. See
Limits.
503unavailableThe service is busy or briefly unavailable. Retry after Retry-After seconds, or with backoff when
there is none.
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" }'{
"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": []
}