API reference

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.

Open 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

IdMeaning
autoRouting 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.
memtroThe 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 idsIds 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>:chatA 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
  }
}
KeyValuesDefaultWhat it does
modechat, agentThe organisation's default mode; chat when the request declares its own toolsagent 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.
memoryorg, personal, offorg when the key belongs to an organisation, otherwise personalWhere 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.
retrievebooleantruePut relevant memories and graph context in front of the model.
toolsboolean or "memory"trueMemtro's own tools: true for the memory tools and your connector tools, "memory" for the memory tools alone, false for none.
show_progressbooleanThe organisation's agent setting, otherwise trueIn agent mode, stream a text copy of the tool log as reasoning_content. The structured memtro.activity events are sent either way.
show_thinkingbooleanWhatever the client asked for on its own wireReturn the model's thinking on wires that have a block for it.
cachebooleantrueServe identical connector tool calls from the short-lived result cache.
as_ofstringunsetA 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.
sessionstringunsetAn 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.
projectstringunsetThe 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.
verifybooleanfalseCheck 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:

KeyTypeWhat it is
modechat, agentThe mode the request ran in.
enginenative, claude-code, codexWhat ran the request: Memtro's own harness, or the Claude Code or Codex CLI. Present in agent mode and whenever a CLI ran it.
routingobjectHow the model was chosen. Present when a routing decision was made (auto, auto/<provider>, or memtro resolving to auto).
routing.requestedstringThe model id the request named.
routing.lockedtruePresent when the organisation's model lock replaced a named model with memtro.
routing.modelstringThe model that was picked. Sent before the run starts, so a hand-over during the run shows in answered_by instead.
routing.complexityintegerThe difficulty level the request was placed at, 1 to 5.
routing.methodheuristic, classifier, fallback, decisionWhat placed it.
routing.reasonstringWhy, in words.
routing.signalsarray of stringsThe signals the decision read, when there were any.
routing.fallbacksarray of stringsThe ladder the request could fall back along.
routing.kindgeneral, codingWhich ladder was used.
routing.allowance_shiftobjectPresent when a spent allowance moved the request to another rung.
routing.allowance_shift.fromstringThe model that would have answered.
routing.allowance_shift.rolestringThe rung of the level that answered instead, such as secondary.
routing.overheadarray of objectsModel calls the request made beside the answer itself, such as the routing decision, when there were any.
citationsarray of objectsThe records retrieval put in front of the model, at most 12.
groundingobjectCoverage, not correctness: how much of what the question named memory had anything behind.
grounding.gradenumber or nullThe share of named things that memory covered, 0 to 1, or null when the question named nothing.
grounding.uncoveredarray of stringsThe names memory had nothing on.
grounding.figuresarray of objectsEach certified figure the question touched, with name, state, verdict and, where there is one, why. See Measures.
answered_bystringThe 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.
toolsarray of objectsMemtro's own tool calls during the run. Your client tools come back as tool calls instead.
activityobjectChat-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.
bridgedtruePresent 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_search and memtro_remember, the job tools, memtro_delegate in agent mode, and one set per connector the key has access to (hubspot_search, helpscout_get_conversation, postgres_query and so on). You do not declare them; they are there unless memtro.tools says otherwise. Their calls are reported in memtro.tools.
  • Your tools, declared in the request's tools, work the way the wire defines: the reply returns tool_calls (chat completions), function_call items (Responses) or tool_use blocks (Messages) for you to run. They work with every model, claude-code/* and codex/* included, where they are bridged into the CLI's run. A request that declares its own tools runs in chat mode unless it asks for agent, 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 typeStatusMeaningWhat to do
invalid_api_keyinvalid_request_error401

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 Authorization: Bearer sk-memtro-…. Keys cannot be extended: create a new one on Dashboard → Profile → API keys (acts as you) or Organisation → API keys.

subscription_inactiveinvalid_request_error402

The organisation behind the key has no active Memtro subscription.

An owner starts one on Dashboard → Organisation → Billing.

model_not_foundinvalid_request_error404

The model id is not one Memtro knows, or a compat: id is malformed (400).

Use an id from Model ids; GET /v1/models lists the ones you can use.

provider_not_configuredinvalid_request_error400

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_provider_base_urlinvalid_request_error400

An OpenAI-compatible endpoint's stored base URL cannot be used: it cannot be read as a URL, is not https://, carries a user name or password, or names a port other than 443 or 1024–65535.

Correct the base URL under Dashboard → Providers. See OpenAI-compatible endpoints.

provider_base_url_not_allowedinvalid_request_error400

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_unavailableinvalid_request_error400

auto could not find a usable ladder.

Add a provider key, or set a ladder under Dashboard → Routing.

unsupported_parameterinvalid_request_error400

A parameter this endpoint cannot honour (n above 1, logprobs, top_logprobs, an unsupported response_format), or a value a memory route cannot read. param names it.

Drop or correct the parameter the message names.

invalid_as_ofinvalid_request_error400

memtro.as_of is not a calendar date.

Send YYYY-MM-DD.

not_foundinvalid_request_error404

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_only_keypermission_error403

The key was issued read only, and the request writes.

Use a key whose tool surface allows actions.

insufficient_permissionpermission_error403

Deleting shared memory needs the delete-memory permission.

Ask an admin, or delete only your own memories.

memory_disabledinvalid_request_error403

The key's memory ceiling leaves it nowhere to write.

Use a key that may write memory.

allowance_exhaustedinsufficient_quota429

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_unavailableserver_error503

The CLI a claude-code/* or codex/* model needs is not installed on this server.

Use an anthropic/* or openai/* model, or contact support.

upstream_errorserver_errorprovider'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_request_error400

The body failed validation. The message reads Invalid request: <field>: <problem>.

Correct the field it names.

no codepermission_error403

POST /v1/memory into shared memory without the import permission.

Send "memtro": {"memory": "personal"}, or ask an admin.

no codeserver_error500

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:

Statuserror.type
400 and other 4xxinvalid_request_error
401authentication_error
402subscription_inactive
403permission_error
404not_found_error
413request_too_large
429rate_limit_error
529overloaded_error
500 and aboveapi_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 /v1 and /api are 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 is allowance_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:

ParameterWhy nothing happens
userAlready known: the key says who the request acts as.
store, metadataMemtro keeps no response store to put them in.
seedNot forwarded: the ladder may answer on any of several providers.
frequency_penalty, presence_penalty, logit_biasSampling settings that not every provider behind the ladder offers.
parallel_tool_callsThe 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

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.

Where agents remember your company

Sign in, add a provider key, create an API key and point your tools at Memtro. It takes about five minutes.

7-day free trial · card on file, nothing charged until it ends · cancel any time