API
Give it a document. Ask it questions. It answers from what it learned.
Authenticate with a bearer token, create a learner, teach it a source, and ask. The chat call is the shape most clients already speak, so an existing client usually works unchanged.
The facts
- Base URL
- https://api.learnerlabs.ai
- Authentication
- Authorization: Bearer YOUR_API_KEY
- Your learner
- learner-1.0:<learner_id>
- The untrained model
- qwen36-base
- Context window
- 8,192 tokens
- Before you are charged
- Every teaching call is quoted first. Nothing trains until you send it again with confirm
Point the same call at your learner or at the untrained model to ask both the same question and compare the two answers. That comparison is the fastest way to see whether teaching did anything.
Your keys
Mint, review and revoke the keys a machine uses to call this API. The secret is shown once, at mint. The server keeps only a hash of it, so there is nothing to show a second time.
Loading…
The path through it
Six calls, in this order, once. After that you are just asking questions.
-
Get a key
POST
/v1/keyswhile signed in as a person. The secret is shown once and never again; only a hash of it is stored. A machine key cannot mint another key, so an agent has to be handed one. -
Create a learner
POST
/v1/learnerswith a name. Keep thelearner_idthat comes back, because almost every later call takes it. -
Open a session, then activate it
POST
/v1/sessionswith the learner id, then POST/v1/sessions/{id}/activatewith no body. Activating asks for compute before you need it. Compute scales to zero, so without this step your first request against a cold learner carries the whole start-up wait and can time out. Activating turns that wait into a stage you can show someone. -
Add a source: quote first, then confirm
POST
/v1/sourceswith a file, a URL or a repository. Sent withoutconfirmit trains nothing and returns an estimate: how much material it found, roughly what it will cost, and roughly how long. Send the same call again withconfirmset and it starts. -
Watch the job
GET
/v1/jobs/{id}for the state, or GET/v1/jobs/{id}/eventsfor a live stream of it. When it finishes, the report tells you how much the learner gained on the material you gave it. -
Ask it something
POST
/v1/chat/completions, shaped like the chat call most clients already speak. Under load it answers with a job to poll instead of an answer, and with streaming turned on you get events as the text arrives.
One example, start to finish
Teach a page and ask about it. Two calls to teach, because nothing trains until you confirm, and one to ask.
# 1 · create a learner curl https://api.learnerlabs.ai/v1/learners \ -H "Authorization: Bearer $LEARNER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "product docs"}' # 2 · quote the source. Nothing trains, nothing is charged curl https://api.learnerlabs.ai/v1/sources \ -H "Authorization: Bearer $LEARNER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"learner_id": "YOUR_LEARNER_ID", "kind": "url", "url": "https://example.com/docs/changelog"}' # → { "confirmed": false, "quote": { "tokens": 21504, "est_usd": 0.31, # "est_seconds": 180 } } send it again with "confirm": true to start # 3 · ask it, once the job has finished curl https://api.learnerlabs.ai/v1/chat/completions \ -H "Authorization: Bearer $LEARNER_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "learner-1.0:YOUR_LEARNER_ID", "messages": [{"role": "user", "content": "What changed in v4?"}], "max_tokens": 256, "temperature": 0}'
For agentsComing soon
A hosted tool endpoint so an agent can teach a document, ask a learner and replay any of the published demonstrations without you writing a client.
# coming soon claude mcp add --transport http learner https://mcp.learnerlabs.ai/mcp \ --header "Authorization: Bearer sk-your-key"
Until it is live, the same tools install from a local configuration block. The demonstrations page carries the version that works today.
Endpoint reference
Keys
| Method | Path | What it does |
|---|---|---|
| POST | /v1/keys | Mint a key. Signed in as a person only |
| GET | /v1/keys | List your keys by prefix. Never the secret |
| DELETE | /v1/keys/{id} | Revoke one |
Learners
| Method | Path | What it does |
|---|---|---|
| POST | /v1/learners | Create one |
| GET | /v1/learners | List them |
| GET | /v1/learners/{id} | One learner and what it holds |
| DELETE | /v1/learners/{id} | Delete it and everything it learned |
Sessions
| Method | Path | What it does |
|---|---|---|
| POST | /v1/sessions | Open a session for a learner |
| POST | /v1/sessions/{id}/activate | Ask for compute before you need it |
| GET | /v1/sessions/{id} | Watch it come up |
Teaching
| Method | Path | What it does |
|---|---|---|
| POST | /v1/sources | Quote a source, then confirm it to start |
| POST | /v1/sources/upload | Upload a file directly |
| GET | /v1/sources | Everything this learner has been taught |
| GET | /v1/jobs/{id} | Job state |
| GET | /v1/jobs/{id}/events | Live stream of the job |
| GET | /v1/jobs/{id}/report | What it gained on the material |
Asking
| Method | Path | What it does |
|---|---|---|
| POST | /v1/chat/completions | Ask. The familiar chat shape |
| GET | /v1/chat/completions/jobs/{id} | Collect an answer that came back as a job |
| POST | /v1/chat/stream | Ask, streamed |
Conversations
| Method | Path | What it does |
|---|---|---|
| POST | /conversations | Start a conversation with a learner |
| GET | /conversations | List them |
| POST | /conversations/{id}/messages | Send a message |
| GET | /conversations/{id}/ab | The same question to the learner and to the untrained model |
| PATCH | /conversations/{id} | Rename it |
| DELETE | /conversations/{id} | Delete it |
Restore points
| Method | Path | What it does |
|---|---|---|
| GET | /v1/checkpoints | Every point you can go back to |
| POST | /v1/checkpoints/{id}/restore | Roll a learner back to one |
| POST | /v1/checkpoints/{id}/fork | Start a new learner from one |
| POST | /v1/checkpoints/{id}/preload | Warm it before you need it |
| GET | /v1/checkpoints/{id}/export | Take it away |
Billing and records
| Method | Path | What it does |
|---|---|---|
| GET | /v1/billing | Balance and usage |
| POST | /v1/billing/checkout | Add credit |
| GET | /v1/audit | Everything that happened, in order |
| GET | /v1/report | A summary across your learners |