API reference
Authentication, model ids, the memtro object, streaming, errors and limits, and an index of every endpoint: everything an OpenAI- or Anthropic-compatible client needs to talk to Memtro.
Memtro answers the OpenAI chat-completions and Responses shapes and the Anthropic Messages shape at https://platform.memtro.com/v1, so a client built for either works unchanged once its base URL and key point here. Behind every wire is the same pipeline: your organisation's memory, model routing, the connector tools your key may use, and agent mode. This page covers what every endpoint shares; each endpoint has its own page, listed under Endpoints. For a first request, see the Quickstart.
Base URL and authentication
The base URL is https://platform.memtro.com/v1. The MCP server is at https://platform.memtro.com/api/mcp.
Send the key in either header:
curl https://platform.memtro.com/v1/models -H "Authorization: Bearer $MEMTRO_API_KEY"
curl https://platform.memtro.com/v1/models -H "x-api-key: $MEMTRO_API_KEY"
Authorization: Bearer is what the OpenAI SDKs send and x-api-key what the Anthropic SDKs and Claude Code send; when both are present the bearer token is used. Keys start sk-memtro-; keys made before the rename start sk-brain- and still work. Create one under Dashboard → Profile → API keys (it acts as you) or Organisation → API keys (it acts for the organisation). See Getting started.
Every reply from the answering and memory endpoints, errors included, carries x-request-id and request-id headers with the same id: chatcmpl-…, resp-… or msg-… on the three answering wires (the same as the body's id), req-… elsewhere. Quote it when you ask for help. Each endpoint page says whether its route sets one.
Keys and what they reach
The key fixes what a request can reach, and it is a ceiling the request cannot raise. A personal key acts as you, with your memory and the organisation's, or, set to "mine only", with your own memory alone, so memtro.memory: "org" is held to "personal". An organisation key acts as an agent of the organisation and never reads or writes personal memory, so memtro.memory: "personal" is treated as "org". The same ceiling decides what GET /v1/memory and GET /v1/entities/{id} can see: a record the key cannot read is answered exactly as one that does not exist.
A key issued read only reads and never writes: importing an exchange and deleting a memory are refused with read_only_key, and the tools it is offered in chat and over MCP are the ones that change nothing. A few writes also need a permission the key's holder must have: importing into the organisation's shared memory, deleting shared memory, and reading the organisation's own figures on usage. See Teams and permissions.
A key can be given a life when it is made (30 days, 90 days, a year, or no expiry) and it cannot be extended afterwards: a key that has run out is replaced rather than renewed. An expired key is refused with its expiry date in the message, which is what tells a 401 at six in the morning apart from a revoked one.
Model ids
| Id | Meaning |
|---|---|
auto | Routing by difficulty across the organisation's ladder. See Model routing. |
auto/<provider> | Routing within one provider, for example auto/anthropic. Listed by GET /v1/models for each provider you hold a key for. |
memtro | The organisation's default model: auto unless an admin sets another. The default when a request names no model on chat completions and Responses. brain is accepted as an older alias. |
<provider>/<model> | A specific model through your key for that provider: openai, anthropic, google, meta, xai, openrouter, deepseek, and claude-code and codex, which run through those CLIs. For example anthropic/claude-opus-5 or claude-code/opus. |
bare ids | Ids such as gpt-…, o3, claude-…, gemini-…, grok-…, deepseek-… or muse-… are read as the provider they belong to. |
compat:<label>/<model> | A model on an OpenAI-compatible endpoint you configured under that label. |
<id>:agent, <id>:chat | A suffix on any id forces agent mode or a single reply for this request, for example auto:agent. Clients that can name a model but not send a body extension use this. |
The model lock
Organisations start with the model lock on. Under it a request that names a specific model is not refused: it is answered by memtro, and when the request is routed the reply's memtro.routing.locked is true. GET /v1/models then lists only memtro, auto and auto/<provider>. An organisation that turns the lock off can name models directly.
The memtro object
Add a memtro object to a chat completions, Responses or Messages request to control how Memtro behaves. Every key is optional. brain is still accepted as the field's name on chat completions, for older clients.
{
"model": "auto",
"messages": [{"role": "user", "content": "Summarise open VIP tickets"}],
"memtro": {
"mode": "agent",
"memory": "org",
"retrieve": true,
"tools": true,
"show_progress": true,
"cache": true
}
}
| Key | Values | Default | What it does |
|---|---|---|---|
mode | chat, agent | The organisation's default mode; chat when the request declares its own tools | agent runs the multi-step harness: plan, query every relevant system, cross-reference, answer once. A :agent or :chat suffix on the model id does the same. See Agent mode. |
memory | org, personal, off | org when the key belongs to an organisation, otherwise personal | Where facts learned from this exchange are stored, and a ceiling the key can lower but the request cannot raise: an organisation key never reads or writes personal memory, and a personal key set to "mine only" never reaches the organisation's. off stores nothing. |
retrieve | boolean | true | Put relevant memories and graph context in front of the model. |
tools | boolean or "memory" | true | Memtro's own tools: true for the memory tools and your connector tools, "memory" for the memory tools alone, false for none. |
show_progress | boolean | The organisation's agent setting, otherwise true | In agent mode, stream a text copy of the tool log as reasoning_content. The structured memtro.activity events are sent either way. |
show_thinking | boolean | Whatever the client asked for on its own wire | Return the model's thinking on wires that have a block for it. |
cache | boolean | true | Serve identical connector tool calls from the short-lived result cache. |
as_of | string | unset | A calendar date, YYYY-MM-DD: answer from memory as it stood at the end of that day. Retrieval and the memory tools report what was believed then, and nothing from the exchange is learned. Anything that is not a real date is refused with invalid_as_of. See Time travel. |
session | string | unset | An opaque id for this conversation, 1 to 200 characters, so repeated turns are recognised as one session: it groups usage and lets retrieval be reused between turns. |
project | string | unset | The repository or project this session is working in, 1 to 200 characters (for example owner/repo), so memory about it is preferred. Ignored when the graph has never heard of it. |
verify | boolean | false | Check the drafted answer against the retrieved context with a second model call before returning it, dropping claims nothing in the context supports. One extra model call per answer. |
POST /v1/memory takes a memtro object of its own, with memory, transcript, occurred_at and learn.
What comes back
Replies are the wire's own shape plus a memtro object, present when there is something to report:
| Key | Type | What it is |
|---|---|---|
mode | chat, agent | The mode the request ran in. |
engine | native, claude-code, codex | What ran the request: Memtro's own harness, or the Claude Code or Codex CLI. Present in agent mode and whenever a CLI ran it. |
routing | object | How the model was chosen. Present when a routing decision was made (auto, auto/<provider>, or memtro resolving to auto). |
routing.requested | string | The model id the request named. |
routing.locked | true | Present when the organisation's model lock replaced a named model with memtro. |
routing.model | string | The model that was picked. Sent before the run starts, so a hand-over during the run shows in answered_by instead. |
routing.complexity | integer | The difficulty level the request was placed at, 1 to 5. |
routing.method | heuristic, classifier, fallback, decision | What placed it. |
routing.reason | string | Why, in words. |
routing.signals | array of strings | The signals the decision read, when there were any. |
routing.fallbacks | array of strings | The ladder the request could fall back along. |
routing.kind | general, coding | Which ladder was used. |
routing.allowance_shift | object | Present when a spent allowance moved the request to another rung. |
routing.allowance_shift.from | string | The model that would have answered. |
routing.allowance_shift.role | string | The rung of the level that answered instead, such as secondary. |
routing.overhead | array of objects | Model calls the request made beside the answer itself, such as the routing decision, when there were any. |
citations | array of objects | The records retrieval put in front of the model, at most 12. |
grounding | object | Coverage, not correctness: how much of what the question named memory had anything behind. |
grounding.grade | number or null | The share of named things that memory covered, 0 to 1, or null when the question named nothing. |
grounding.uncovered | array of strings | The names memory had nothing on. |
grounding.figures | array of objects | Each certified figure the question touched, with name, state, verdict and, where there is one, why. See Measures. |
answered_by | string | The model that actually answered, when it differs from routing.model: a rung whose allowance ran out, or a backup after a failure. On a stream it arrives on the closing chunk. Chat completions and Responses only. |
tools | array of objects | Memtro's own tool calls during the run. Your client tools come back as tool calls instead. |
activity | object | Chat-completions streams only: one event per tool call as it starts (phase: "start", with input) and finishes (phase: "done", with ok, summary and any urls), each carrying the call's id and tool. |
bridged | true | Present when your own tools were bridged into a claude-code/* or codex/* run. |
routing.model is the model that was picked, and it is sent first because it is settled before the run starts. If the run then hands over (down the ladder because a rung's allowance ran out, or to a backup because the first model failed before answering) the reply carries memtro.answered_by with the model that actually answered. It is absent when they are the same, which is almost always.
Tools
- Memtro's tools run inside Memtro (every one, with its inputs, is on the Tools reference): the memory tools such as
memtro_searchandmemtro_remember, the job tools,memtro_delegatein agent mode, and one set per connector the key has access to (hubspot_search,helpscout_get_conversation,postgres_queryand so on). You do not declare them; they are there unlessmemtro.toolssays otherwise. Their calls are reported inmemtro.tools. - Your tools, declared in the request's
tools, work the way the wire defines: the reply returnstool_calls(chat completions),function_callitems (Responses) ortool_useblocks (Messages) for you to run. They work with every model,claude-code/*andcodex/*included, where they are bridged into the CLI's run. A request that declares its own tools runs inchatmode unless it asks foragent, because a client with tools is usually an agent itself.
Streaming
Set stream: true for server-sent events in the wire's own format: chat.completion.chunk data lines on chat completions, named events on Responses and Messages. On chat completions, stream_options: {"include_usage": true} adds a final usage chunk.
Memtro adds to the chat stream without changing its shape: the first chunk carries memtro with the mode and the routing decision, each of Memtro's own tool calls sends a memtro.activity event as it starts and finishes, agent progress arrives as reasoning_content (Open WebUI and most chat UIs show it as a collapsible "thinking" block), and a closing chunk lists the tools used.
If a run fails after the stream has started, the status is already 200, so the failure arrives as an error chunk, {"error": {"message", "type": "server_error", …}}, and the stream closes without data: [DONE]. A stream that ends without [DONE] did not finish.
Errors
The error body is the one the wire you asked on uses. Chat completions, Responses, embeddings, models, memory, entities and usage use OpenAI's envelope, where type is the broad class and code the specific reason:
{"error": {"message": "n: 2 is not supported — one choice is returned per request. Send 2 requests, or drop n.", "type": "invalid_request_error", "param": "n", "code": "unsupported_parameter"}}
| Code and type | Status | Meaning | What to do |
|---|---|---|---|
invalid_invalid_ | 401 | The key is missing, malformed, revoked or expired, or no longer belongs to the organisation. An expired key's message names its expiry date. | Send |
subscription_invalid_ | 402 | The organisation behind the key has no active Memtro subscription. | An owner starts one on Dashboard → Organisation → Billing. |
model_invalid_ | 404 | The model id is not one Memtro knows, or a | Use an id from Model ids; |
provider_invalid_ | 400 | There is no key for the provider the model needs, no embedding-capable key, no model to read an import with, or an OpenAI-compatible endpoint has no base URL. | Add a key under Dashboard → Providers. |
invalid_invalid_ | 400 | An OpenAI-compatible endpoint's stored base URL cannot be used: it cannot be read as a URL, is not | Correct the base URL under Dashboard → Providers. See OpenAI-compatible endpoints. |
provider_invalid_ | 400 | A model endpoint's host may not be used: an OpenAI-compatible endpoint's host is not approved for the organisation, is private or internal, does not resolve, or answered with a redirect; or another provider's base URL override names a host other than its own. Returned whether the endpoint was refused before the request was sent or during it. | An owner or admin approves the host under Organisation → Providers → Custom model hosts; a redirect's target goes in the base URL instead. See OpenAI-compatible endpoints. |
routing_invalid_ | 400 |
| Add a provider key, or set a ladder under Dashboard → Routing. |
unsupported_invalid_ | 400 | A parameter this endpoint cannot honour ( | Drop or correct the parameter the message names. |
invalid_invalid_ | 400 |
| Send |
not_invalid_ | 404 | No such memory or entity, or not one this key can read: another organisation's record looks the same as a deleted one. | Check the id, and that the key's scope reaches it. |
read_permission_ | 403 | The key was issued read only, and the request writes. | Use a key whose tool surface allows actions. |
insufficient_permission_ | 403 | Deleting shared memory needs the delete-memory permission. | Ask an admin, or delete only your own memories. |
memory_invalid_ | 403 | The key's memory ceiling leaves it nowhere to write. | Use a key that may write memory. |
allowance_insufficient_ | 429 | No rung of the request's level has allowance left this month. The message names the level and the month. | Wait for the month to turn, or ask an admin to raise the allowance. See Cost control. |
engine_server_ | 503 | The CLI a | Use an |
upstream_server_ | provider's | The model provider returned an error; the message carries its text. The provider's own status is passed through, except that its 401 and 403 become 502. | Read the provider's message: an invalid provider key, its rate limit, an overloaded model. |
no codeinvalid_ | 400 | The body failed validation. The message reads | Correct the field it names. |
no codepermission_ | 403 |
| Send |
no codeserver_ | 500 | Something failed inside Memtro. | Retry; quote the request id to support if it persists. |
A month's allowance running out is the code allowance_exhausted with the type insufficient_quota, so a client that branches on either finds it. Your own tools never cause an error of their own: they work with every model.
/v1/messages answers in Anthropic's envelope, {"type": "error", "error": {"type", "message"}}, with no code. The type is chosen from the status, in Anthropic's vocabulary, so an SDK or Claude Code reading error.error.type finds a word it has a case for:
| Status | error.type |
|---|---|
| 400 and other 4xx | invalid_request_error |
| 401 | authentication_error |
| 402 | subscription_inactive |
| 403 | permission_error |
| 404 | not_found_error |
| 413 | request_too_large |
| 429 | rate_limit_error |
| 529 | overloaded_error |
| 500 and above | api_error |
The MCP endpoint answers a refused key as a JSON-RPC error, code -32001, with the HTTP status set. Troubleshooting starts from symptoms rather than codes.
Limits
- Rate. Requests to
/v1and/apiare limited per client address at the edge: 30 a second, with bursts of up to 60 more. Past that the edge answers 429 itself, before the request reaches Memtro, so do not count on that 429 having the JSON body above; back off and retry. Memtro's own 429 isallowance_exhausted, which retrying will not fix until the month turns. - Time. Chat completions, Responses, Messages and memory import may run for up to five minutes, which agent runs need; the MCP endpoint for up to two. Keep client timeouts generous, and stream to see progress.
- Steps. Each agent request has a step budget, 30 unless the organisation's agent settings change it.
Compatibility with OpenAI and Anthropic clients
OpenAI clients
Memtro takes the OpenAI request shape, and some of it has nothing to act on here. These are read and do nothing, with no error and no warning, because clients send them by habit and refusing would break them for no gain:
| Parameter | Why nothing happens |
|---|---|
user | Already known: the key says who the request acts as. |
store, metadata | Memtro keeps no response store to put them in. |
seed | Not forwarded: the ladder may answer on any of several providers. |
frequency_penalty, presence_penalty, logit_bias | Sampling settings that not every provider behind the ladder offers. |
parallel_tool_calls | The model decides; Memtro does not override it. |
Two are refused with a 400 unsupported_parameter rather than ignored, because ignoring them returns an answer that is wrong rather than slightly different: n above 1 (one choice is returned per request, and code reading choices[1] would throw on a 200) and logprobs / top_logprobs (token probabilities are not returned).
response_format is honoured: json_object and json_schema are handed to the provider's own structured-output setting, and any other type is refused rather than answered in prose. reasoning_effort is read as two levels, deep (high, xhigh, max) and standard (medium, low), and set on the provider's own thinking setting; any other value leaves the provider's default. See Chat completions.
GET /v1/models, GET /v1/models/{model} and POST /v1/embeddings send no CORS headers, so call them from a server; the other /v1 endpoints answer browsers on any origin.
The Anthropic Messages API
POST /v1/messages takes Anthropic's request shape and answers in its message object and named-event stream, so Claude Code and the Anthropic SDKs can use Memtro as their model by setting ANTHROPIC_BASE_URL to https://platform.memtro.com. Both x-api-key and a bearer token are accepted, /v1/models carries the fields Anthropic clients read as well as OpenAI's, and POST /v1/messages/count_tokens answers for SDKs that budget before they ask. Errors arrive in Anthropic's shape, as above.
The Responses API
POST /v1/responses is for clients that speak only that wire, the Codex CLI among them. Memtro keeps no conversation state against a response id, so store and previous_response_id are accepted and ignored: send the whole input each turn.
Endpoints
Chat
POST /v1/chat/completions: Answer a conversation in the OpenAI chat-completions shape, through memory, routing, connector tools and agent mode, streamed or in one reply.
Responses
POST /v1/responses: The same pipeline in the OpenAI Responses shape, for clients such as the Codex CLI that speak only that wire.
Messages
POST /v1/messages: The same pipeline in the Anthropic Messages shape, for Claude Code and the Anthropic SDKs.POST /v1/messages/count_tokens: Count the input tokens of a Messages request: Anthropic's own count for an Anthropic model, otherwise an estimate marked as one.
Embeddings
POST /v1/embeddings: Embed text through your own OpenAI or Google key, in the OpenAI embeddings shape.
Models
GET /v1/models: The model ids this key can ask for, with context and output limits where they are known, in both OpenAI and Anthropic fields.GET /v1/models/{model}: One model by id, including ids that contain slashes.
Memory
GET /v1/memory: Page through the memories this key can read, newest first, or search them by meaning or by words.GET /v1/memory/{id}: Read one memory by id.POST /v1/memory: Hand Memtro a conversation it was not part of, and it learns from it as though it had been: no answer is generated.DELETE /v1/memory/{id}: Delete one memory permanently.
Entities
GET /v1/entities/{id}: One entity from the knowledge graph, with its recorded values, its relationships and its memories.
Usage
GET /v1/usage: What this key's holder has spent over a window, and the state of each capped allowance this month.
MCP
POST /api/mcp: Memtro as a stateless Streamable HTTP MCP server: memory and connector tools for any MCP client.
Two other surfaces have their own pages: SCIM 2.0 provisioning at /scim/v2/…, authenticated by its own token (Single sign-on and provisioning), and the erasure endpoints at /api/privacy/erasures (Privacy and erasure).
OpenAPI spec
The same reference is published as an OpenAPI 3.1 document, generated from the data these pages are drawn from, for Postman, Bruno or an SDK generator: /openapi.yaml and /openapi.json.