{
  "openapi": "3.1.0",
  "info": {
    "title": "Memtro API",
    "version": "1.0",
    "description": "OpenAI- and Anthropic-compatible endpoints over a company's memory, model routing and connector tools. Generated from the reference at https://www.memtro.com/docs/api/, which is the readable form of this document."
  },
  "externalDocs": {
    "url": "https://www.memtro.com/docs/api/"
  },
  "servers": [
    {
      "url": "https://platform.memtro.com"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Chat"
    },
    {
      "name": "Responses"
    },
    {
      "name": "Messages"
    },
    {
      "name": "Embeddings"
    },
    {
      "name": "Models"
    },
    {
      "name": "Memory"
    },
    {
      "name": "Entities"
    },
    {
      "name": "Usage"
    },
    {
      "name": "MCP"
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "operationId": "chatCompletions",
        "summary": "Chat completions",
        "description": "Answer a conversation in the OpenAI chat-completions shape, through memory, routing, connector tools and agent mode, streamed or in one reply.\n\nThe main endpoint. It takes the OpenAI chat-completions request, so any OpenAI-compatible client works unchanged, and runs it through Memtro: memories retrieved and put in front of the model, the model chosen by routing or named by you, Memtro's memory and connector tools available to it, and in agent mode a multi-step investigation before the answer. Facts from the exchange are learned afterwards, into the memory the key may write.\n\nSet `stream: true` for server-sent events. A request can run for up to five minutes, which agent runs need; keep client timeouts generous.",
        "tags": [
          "Chat"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/chat-completions/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "description": "A model id or routing id; see [Model ids](https://www.memtro.com/docs/api/#model-ids). A `:agent` or `:chat` suffix forces the mode. Under the organisation's model lock a named model is answered by `memtro` instead, without an error.",
                    "type": "string",
                    "default": "memtro"
                  },
                  "messages": {
                    "description": "The conversation, at least one message.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "description": "Who said it.",
                          "type": "string",
                          "enum": [
                            "system",
                            "developer",
                            "user",
                            "assistant",
                            "tool",
                            "function"
                          ]
                        },
                        "content": {
                          "description": "Text, or an array of content parts such as `{\"type\": \"text\", \"text\": …}` and `{\"type\": \"image_url\", \"image_url\": {\"url\": …}}`. An image URL must be a `data:` URI or an absolute http(s) URL, or the request is refused with a 400. Parts with no equivalent on the model's wire are dropped.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "description": "A name for the participant.",
                          "type": "string"
                        },
                        "tool_calls": {
                          "description": "On an assistant turn, the calls it made to your tools: `id`, `type` and `function` (`name`, `arguments`).",
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        },
                        "tool_call_id": {
                          "description": "On a `tool` turn, the call this result answers.",
                          "type": "string"
                        },
                        "cache_control": {
                          "description": "A cache breakpoint, `{\"type\": \"ephemeral\"}`: everything up to here is a stable prefix. Only Anthropic models take explicit breakpoints; elsewhere it is ignored.",
                          "type": "object"
                        }
                      },
                      "required": [
                        "role"
                      ]
                    }
                  },
                  "stream": {
                    "description": "Answer as server-sent events. See [Streaming](https://www.memtro.com/docs/api/chat-completions/#streaming).",
                    "type": "boolean",
                    "default": false
                  },
                  "stream_options": {
                    "description": "Stream settings.",
                    "type": "object",
                    "properties": {
                      "include_usage": {
                        "description": "Add a final chunk with `choices: []` and `usage` before `[DONE]`.",
                        "type": "boolean"
                      }
                    }
                  },
                  "temperature": {
                    "description": "Sampling temperature, passed to the provider.",
                    "type": "number"
                  },
                  "top_p": {
                    "description": "Nucleus sampling, passed to the provider.",
                    "type": "number"
                  },
                  "max_tokens": {
                    "description": "A ceiling on the answer's tokens; a positive integer.",
                    "type": "integer"
                  },
                  "max_completion_tokens": {
                    "description": "The same ceiling under its newer name; wins over `max_tokens`.",
                    "type": "integer"
                  },
                  "stop": {
                    "description": "Where to stop generating.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "tools": {
                    "description": "Your own tools. When the model calls one, the reply carries `tool_calls` for you to run, and you send the results back as `tool` messages. Memtro's own tools are separate and need no declaring. A request that declares tools runs in `chat` mode unless it asks for `agent`. With `claude-code/*` and `codex/*` models your tools are bridged into the CLI run.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "description": "Always `function`.",
                          "const": "function"
                        },
                        "function": {
                          "description": "The tool.",
                          "type": "object",
                          "properties": {
                            "name": {
                              "description": "Its name.",
                              "type": "string"
                            },
                            "description": {
                              "description": "What it does, for the model.",
                              "type": "string"
                            },
                            "parameters": {
                              "description": "Its arguments, as JSON Schema.",
                              "type": "object"
                            }
                          },
                          "required": [
                            "name"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "function"
                      ]
                    }
                  },
                  "tool_choice": {
                    "description": "`none`, `auto`, `required`, or `{\"type\": \"function\", \"function\": {\"name\": …}}` to force one tool.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object"
                      }
                    ]
                  },
                  "reasoning_effort": {
                    "description": "How hard to think. `high`, `xhigh` and `max` ask for deep thinking, `medium` and `low` for standard, and the provider's own thinking setting is set to match. Any other value, `none` included, leaves the provider's default.",
                    "type": "string"
                  },
                  "response_format": {
                    "description": "The shape the answer must take, handed to the provider's own structured-output setting. Any other `type` is refused with `unsupported_parameter`.",
                    "type": "object",
                    "properties": {
                      "type": {
                        "description": "`text` asks for nothing; `json_object` for some JSON object; `json_schema` for the schema below.",
                        "type": "string",
                        "enum": [
                          "text",
                          "json_object",
                          "json_schema"
                        ]
                      },
                      "json_schema": {
                        "description": "For `json_schema`. The same keys sent flat beside `type` are read too.",
                        "type": "object",
                        "properties": {
                          "name": {
                            "description": "A name for the schema. Default: `response`.",
                            "type": "string"
                          },
                          "description": {
                            "description": "What it describes.",
                            "type": "string"
                          },
                          "schema": {
                            "description": "A JSON Schema object.",
                            "type": "object"
                          }
                        },
                        "required": [
                          "schema"
                        ]
                      }
                    }
                  },
                  "n": {
                    "description": "Only `1` is accepted: one choice is returned per request, and `n` above 1 is refused with `unsupported_parameter` rather than answered with one choice.",
                    "type": "integer"
                  },
                  "logprobs": {
                    "description": "Refused with `unsupported_parameter`: token probabilities are not returned."
                  },
                  "top_logprobs": {
                    "description": "Refused with `unsupported_parameter`: token probabilities are not returned."
                  },
                  "user": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "store": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "metadata": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "seed": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "frequency_penalty": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "presence_penalty": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "logit_bias": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "parallel_tool_calls": {
                    "description": "Accepted and ignored. See [Compatibility](https://www.memtro.com/docs/api/#compatibility-with-openai-and-anthropic-clients)."
                  },
                  "memtro": {
                    "description": "Memtro's options; see [the `memtro` object](https://www.memtro.com/docs/api/#the-memtro-object). `brain` is accepted as an older name.",
                    "type": "object",
                    "properties": {
                      "mode": {
                        "description": "`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](https://www.memtro.com/docs/agent-mode/). Default: The organisation's default mode; `chat` when the request declares its own `tools`.",
                        "type": "string",
                        "enum": [
                          "chat",
                          "agent"
                        ]
                      },
                      "memory": {
                        "description": "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. Default: `org` when the key belongs to an organisation, otherwise `personal`.",
                        "type": "string",
                        "enum": [
                          "org",
                          "personal",
                          "off"
                        ]
                      },
                      "retrieve": {
                        "description": "Put relevant memories and graph context in front of the model.",
                        "type": "boolean",
                        "default": true
                      },
                      "tools": {
                        "description": "Memtro's own tools: `true` for the memory tools and your connector tools, `\"memory\"` for the memory tools alone, `false` for none.",
                        "anyOf": [
                          {
                            "type": "boolean"
                          },
                          {
                            "const": "memory"
                          }
                        ],
                        "default": true
                      },
                      "show_progress": {
                        "description": "In agent mode, stream a text copy of the tool log as `reasoning_content`. The structured `memtro.activity` events are sent either way. Default: The organisation's agent setting, otherwise `true`.",
                        "type": "boolean"
                      },
                      "show_thinking": {
                        "description": "Return the model's thinking on wires that have a block for it. Default: Whatever the client asked for on its own wire.",
                        "type": "boolean"
                      },
                      "cache": {
                        "description": "Serve identical connector tool calls from the short-lived result cache.",
                        "type": "boolean",
                        "default": true
                      },
                      "as_of": {
                        "description": "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](https://www.memtro.com/docs/time-travel/).",
                        "type": "string"
                      },
                      "session": {
                        "description": "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.",
                        "type": "string"
                      },
                      "project": {
                        "description": "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.",
                        "type": "string"
                      },
                      "verify": {
                        "description": "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.",
                        "type": "boolean",
                        "default": false
                      }
                    }
                  }
                },
                "required": [
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A `chat.completion`, plus a `memtro` object when there is something to report. With `stream: true`: `chat.completion.chunk` events, then `data: [DONE]`. See [Streaming](https://www.memtro.com/docs/api/chat-completions/#streaming).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "description": "`chatcmpl-…`, the same id as the `x-request-id` header.",
                      "type": "string"
                    },
                    "object": {
                      "description": "Always `chat.completion`.",
                      "const": "chat.completion"
                    },
                    "created": {
                      "description": "Unix time, in seconds.",
                      "type": "integer"
                    },
                    "model": {
                      "description": "The model that was picked.",
                      "type": "string"
                    },
                    "choices": {
                      "description": "Exactly one choice.",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "description": "Always `0`.",
                            "type": "integer"
                          },
                          "message": {
                            "description": "The answer.",
                            "type": "object",
                            "properties": {
                              "role": {
                                "description": "Always `assistant`.",
                                "const": "assistant"
                              },
                              "content": {
                                "description": "The text, or null when the model only called your tools.",
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tool_calls": {
                                "description": "Calls to your tools, each with `id`, `type: \"function\"` and `function` (`name`, `arguments` as a JSON string).",
                                "type": "array",
                                "items": {
                                  "type": "object"
                                }
                              }
                            }
                          },
                          "finish_reason": {
                            "description": "Why it ended.",
                            "type": "string",
                            "enum": [
                              "stop",
                              "length",
                              "content_filter",
                              "tool_calls"
                            ]
                          },
                          "logprobs": {
                            "description": "Always null.",
                            "type": "null"
                          }
                        }
                      }
                    },
                    "usage": {
                      "description": "Tokens.",
                      "type": "object",
                      "properties": {
                        "prompt_tokens": {
                          "description": "Input tokens.",
                          "type": "integer"
                        },
                        "completion_tokens": {
                          "description": "Output tokens.",
                          "type": "integer"
                        },
                        "total_tokens": {
                          "description": "The two added.",
                          "type": "integer"
                        },
                        "prompt_tokens_details": {
                          "description": "`cached_tokens`: input the provider served from its cache.",
                          "type": "object"
                        }
                      }
                    },
                    "memtro": {
                      "description": "Mode, routing, citations, grounding and Memtro's tool calls; see [What comes back](https://www.memtro.com/docs/api/#what-comes-back).",
                      "type": "object"
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The body failed validation. `unsupported_parameter`: `n` above 1, `logprobs`, `top_logprobs`, or a `response_format` type other than `text`, `json_object` or `json_schema`. `invalid_as_of`: `memtro.as_of` is not a calendar date. `routing_unavailable`: `auto` found no usable ladder. `provider_not_configured`: No key for the provider the model needs. `invalid_provider_base_url`: An OpenAI-compatible endpoint's base URL cannot be used: not a URL, not `https://`, a user name or password in it, or a port not accepted. `provider_base_url_not_allowed`: An OpenAI-compatible endpoint's host is not approved for the organisation, is private or internal, does not resolve, or redirected, whether refused before the request or during it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`model_not_found`: Unknown model id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`allowance_exhausted`: The month's allowance for the request's level is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An internal error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`engine_unavailable`: The CLI a `claude-code/*` or `codex/*` model needs is not installed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "`upstream_error`: The provider returned an error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "responses",
        "summary": "Responses",
        "description": "The same pipeline in the OpenAI Responses shape, for clients such as the Codex CLI that speak only that wire.\n\n`POST /v1/responses` takes the OpenAI Responses request and answers in its objects and events. Behind it is the same pipeline as chat completions: the same routing, memory, connector tools, agent mode and allowances. It exists because some clients speak only this wire, the [Codex CLI](https://www.memtro.com/docs/guide-codex/) among them.\n\nMemtro keeps no conversation state against a response id: send the whole input every turn, which is what these clients do anyway.",
        "tags": [
          "Responses"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/responses/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "description": "A model id or routing id; see [Model ids](https://www.memtro.com/docs/api/#model-ids). The older `brain` alias for the `memtro` field is not read on this wire.",
                    "type": "string",
                    "default": "memtro"
                  },
                  "input": {
                    "description": "A string (one user turn), or an array of items. Items that are not turns (`reasoning`, `item_reference`, a built-in tool's call, a compaction marker) are skipped, which is what a client replaying its own history sends.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "description": "`message` (or absent), `function_call` or `function_call_output`.",
                              "type": "string"
                            },
                            "role": {
                              "description": "For a message.",
                              "type": "string",
                              "enum": [
                                "system",
                                "developer",
                                "user",
                                "assistant"
                              ]
                            },
                            "content": {
                              "description": "For a message: text, or parts of type `input_text`, `output_text` (with `text`) or `input_image` (with `image_url`, a URL string or `{url}`; a `data:` URI or absolute http(s) URL).",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "array",
                                  "items": {
                                    "type": "object"
                                  }
                                }
                              ]
                            },
                            "name": {
                              "description": "For a `function_call`: the tool, its arguments as a JSON string, and the call's id (`id` is read when `call_id` is absent).",
                              "type": "string"
                            },
                            "arguments": {
                              "description": "For a `function_call`: the tool, its arguments as a JSON string, and the call's id (`id` is read when `call_id` is absent).",
                              "type": "string"
                            },
                            "call_id": {
                              "description": "For a `function_call`: the tool, its arguments as a JSON string, and the call's id (`id` is read when `call_id` is absent).",
                              "type": "string"
                            },
                            "output": {
                              "description": "For a `function_call_output`, with its `call_id`: your tool's result."
                            }
                          }
                        }
                      }
                    ]
                  },
                  "instructions": {
                    "description": "Becomes a system message.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tools": {
                    "description": "Function tools, `{\"type\": \"function\", \"name\", \"description\", \"parameters\"}`, returned to you as `function_call` output items. Other kinds (a `custom` freeform tool, built-ins such as `web_search`) cannot be carried and are left out of what the model is offered, without an error.",
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {
                    "description": "`none`, `auto`, `required`, or `{\"type\": \"function\", \"name\": …}`.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object"
                      }
                    ]
                  },
                  "stream": {
                    "description": "Answer as named server-sent events. See [Streaming](https://www.memtro.com/docs/api/responses/#streaming).",
                    "type": "boolean",
                    "default": false
                  },
                  "temperature": {
                    "description": "Passed to the provider.",
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "top_p": {
                    "description": "Passed to the provider.",
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "max_output_tokens": {
                    "description": "A ceiling on the answer's tokens. An answer cut short by it ends `incomplete`.",
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reasoning": {
                    "description": "`effort` is read as chat completions' `reasoning_effort`.",
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "effort": {
                            "description": "`high`, `xhigh`, `max`, `medium` or `low`.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "store": {
                    "description": "Accepted and ignored: nothing is stored against a response id."
                  },
                  "previous_response_id": {
                    "description": "Accepted and ignored: nothing is stored against a response id."
                  },
                  "memtro": {
                    "description": "Memtro's options, the same keys as on chat completions; see [the `memtro` object](https://www.memtro.com/docs/api/#the-memtro-object).",
                    "type": "object"
                  }
                },
                "required": [
                  "input"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A `response` object. With `stream: true`: named events, each also carrying `type` and a `sequence_number`. See [Streaming](https://www.memtro.com/docs/api/responses/#streaming).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "description": "`resp-…`, the same id as the `x-request-id` header.",
                      "type": "string"
                    },
                    "object": {
                      "description": "Always `response`.",
                      "const": "response"
                    },
                    "created_at": {
                      "description": "Unix time, in seconds.",
                      "type": "integer"
                    },
                    "status": {
                      "description": "`incomplete` when `max_output_tokens` cut the answer short.",
                      "type": "string",
                      "enum": [
                        "completed",
                        "incomplete"
                      ]
                    },
                    "model": {
                      "description": "The model that was picked.",
                      "type": "string"
                    },
                    "output": {
                      "description": "A `message` item with `output_text` content, and a `function_call` item (`name`, `call_id`, `arguments`) for each call to your tools.",
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "output_text": {
                      "description": "The answer's text, joined.",
                      "type": "string"
                    },
                    "usage": {
                      "description": "`input_tokens`, `output_tokens`, `total_tokens`.",
                      "type": "object"
                    },
                    "incomplete_details": {
                      "description": "When incomplete: `{\"reason\": \"max_output_tokens\"}`.",
                      "type": "object"
                    },
                    "memtro": {
                      "description": "As on chat completions; see [What comes back](https://www.memtro.com/docs/api/#what-comes-back).",
                      "type": "object"
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The body failed validation, or an image URL cannot be used. `invalid_as_of`: `memtro.as_of` is not a calendar date. `routing_unavailable`: `auto` found no usable ladder. `provider_not_configured`: No key for the provider the model needs. `invalid_provider_base_url`: An OpenAI-compatible endpoint's base URL cannot be used: not a URL, not `https://`, a user name or password in it, or a port not accepted. `provider_base_url_not_allowed`: An OpenAI-compatible endpoint's host is not approved for the organisation, is private or internal, does not resolve, or redirected, whether refused before the request or during it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`model_not_found`: Unknown model id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`allowance_exhausted`: The month's allowance for the request's level is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An internal error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "`engine_unavailable`: The CLI a `claude-code/*` or `codex/*` model needs is not installed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "`upstream_error`: The provider returned an error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "messages",
        "summary": "Messages",
        "description": "The same pipeline in the Anthropic Messages shape, for Claude Code and the Anthropic SDKs.\n\n`POST /v1/messages` takes Anthropic's request shape (`system`, `messages` of content blocks, a required `max_tokens`, `tools` with `input_schema`) and answers in Anthropic's message object or its named-event stream. Behind it is the same pipeline as every other wire: the same routing, memory, connector tools, agent mode and allowances.\n\nIt exists so [Claude Code](https://www.memtro.com/docs/guide-claude-code/) and the [Anthropic SDKs](https://www.memtro.com/integrations/anthropic-sdk/) can use Memtro as their model by setting `ANTHROPIC_BASE_URL` to `https://platform.memtro.com`. Errors come back in Anthropic's shape, with a type an Anthropic client has a case for.",
        "tags": [
          "Messages"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/messages/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "description": "A model id or routing id; see [Model ids](https://www.memtro.com/docs/api/#model-ids). This wire has no default.",
                    "type": "string"
                  },
                  "messages": {
                    "description": "The conversation.",
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "description": "`user` or `assistant`. `system` and `developer` turns are moved into the system prompt, and any other role is read as `user`.",
                          "type": "string"
                        },
                        "content": {
                          "description": "Text, or content blocks: `text`; `image` (`source` with `type` `base64` and `media_type` + `data`, or `type` `url` and `url`); `tool_use` (`id`, `name`, `input`); `tool_result` (`tool_use_id`, `content`, `is_error`). A block may carry `cache_control`. Unknown block types are dropped; an image URL that cannot be used is a 400.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object"
                              }
                            }
                          ]
                        }
                      },
                      "required": [
                        "role",
                        "content"
                      ]
                    }
                  },
                  "max_tokens": {
                    "description": "A ceiling on the answer's tokens; a positive integer.",
                    "type": "integer"
                  },
                  "system": {
                    "description": "The system prompt, as text or text blocks.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    ]
                  },
                  "tools": {
                    "description": "Your own tools, `{name, description, input_schema}`, returned as `tool_use` blocks for you to run. Anthropic's server tools (any other `type` than none or `custom`) are left out without an error.",
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {
                    "description": "`{\"type\": \"auto\" | \"any\" | \"tool\" | \"none\"}`, with `name` for `tool`.",
                    "type": "object"
                  },
                  "stream": {
                    "description": "Answer as Anthropic's named-event stream. See [Streaming](https://www.memtro.com/docs/api/messages/#streaming).",
                    "type": "boolean",
                    "default": false
                  },
                  "temperature": {
                    "description": "Passed to the provider.",
                    "type": "number"
                  },
                  "top_p": {
                    "description": "Passed to the provider.",
                    "type": "number"
                  },
                  "top_k": {
                    "description": "Accepted and not forwarded.",
                    "type": "number"
                  },
                  "stop_sequences": {
                    "description": "Where to stop generating.",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "metadata": {
                    "description": "`user_id` is accepted and ignored.",
                    "type": "object"
                  },
                  "thinking": {
                    "description": "Anthropic's thinking request (`type`, `budget_tokens`, `display`): asks for the thinking back and how hard to think.",
                    "type": "object"
                  },
                  "output_config": {
                    "description": "`effort`, as current Claude Code sends it, is read as `reasoning_effort`.",
                    "type": "object"
                  },
                  "memtro": {
                    "description": "Memtro's options; see [the `memtro` object](https://www.memtro.com/docs/api/#the-memtro-object). `{\"memtro\": {\"mode\": \"agent\"}}` gets a multi-step run.",
                    "type": "object"
                  }
                },
                "required": [
                  "model",
                  "messages",
                  "max_tokens"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An Anthropic `message`. With `stream: true`: Anthropic's named events. See [Streaming](https://www.memtro.com/docs/api/messages/#streaming).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "description": "`msg-…`, the same id as the `request-id` header.",
                      "type": "string"
                    },
                    "type": {
                      "description": "Always `message`.",
                      "const": "message"
                    },
                    "role": {
                      "description": "Always `assistant`.",
                      "const": "assistant"
                    },
                    "model": {
                      "description": "The model that was picked.",
                      "type": "string"
                    },
                    "content": {
                      "description": "`thinking` (when asked for), `text`, and a `tool_use` block for each call to your tools. Memtro's own tools ran on the server; their results are in the answer.",
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "stop_reason": {
                      "description": "Why it ended.",
                      "type": "string",
                      "enum": [
                        "end_turn",
                        "max_tokens",
                        "tool_use",
                        "refusal"
                      ]
                    },
                    "stop_sequence": {
                      "description": "Always null.",
                      "type": "null"
                    },
                    "usage": {
                      "description": "`input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens`.",
                      "type": "object"
                    },
                    "memtro": {
                      "description": "As on chat completions, without `answered_by`; see [What comes back](https://www.memtro.com/docs/api/#what-comes-back). On a stream it rides on `message_delta`.",
                      "type": "object"
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request_error`: The body failed validation, or another 400 from the [error catalogue](https://www.memtro.com/docs/api/#errors), such as a refused [OpenAI-compatible endpoint](https://www.memtro.com/docs/guide-openai-compatible/#refusals); the message says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "401": {
            "description": "`authentication_error`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "404": {
            "description": "`not_found_error`: Unknown model id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limit_error`: The month's allowance for the request's level is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "5XX": {
            "description": "`api_error`: The provider or Memtro failed; `overloaded_error` for a 529.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "operationId": "countTokens",
        "summary": "Count tokens",
        "description": "Count the input tokens of a Messages request: Anthropic's own count for an Anthropic model, otherwise an estimate marked as one.\n\nCounts the input tokens of a Messages request, so an SDK that budgets before it asks keeps working. Where the model is an `anthropic/*` model and you hold an Anthropic key, the count is Anthropic's own; otherwise, or if that call fails or takes over ten seconds, it is an estimate of about 3.6 characters a token, marked `memtro.estimated`.\n\nIt counts your request, not what Memtro sends upstream: the prompt, tools and recalled context Memtro adds are not yours to budget for, and they vary with where the request routes.",
        "tags": [
          "Messages"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/count-tokens/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "description": "The model the request is bound for.",
                    "type": "string"
                  },
                  "messages": {
                    "description": "As on [Messages](https://www.memtro.com/docs/api/messages/).",
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "system": {
                    "description": "The system prompt.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    ]
                  },
                  "tools": {
                    "description": "Your tools; their schemas count.",
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {
                    "description": "As on Messages.",
                    "type": "object"
                  }
                },
                "required": [
                  "model",
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The count.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "input_tokens": {
                      "description": "The number of input tokens.",
                      "type": "integer"
                    },
                    "memtro": {
                      "description": "`{\"estimated\": true}` when the number is an estimate rather than Anthropic's count.",
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request_error`: The body failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "401": {
            "description": "`authentication_error`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          },
          "402": {
            "description": "`authentication_error`: The organisation has no active subscription. This route types every refusal of the key that way.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "operationId": "embeddings",
        "summary": "Embeddings",
        "description": "Embed text through your own OpenAI or Google key, in the OpenAI embeddings shape.\n\nEmbeddings in the OpenAI shape, through **your own** OpenAI or Google key (or an OpenAI-compatible endpoint you configured), never the platform's. Memory itself needs no key of yours: this endpoint is for your own use of embeddings.",
        "tags": [
          "Embeddings"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/embeddings/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "description": "An embedding model id. `memtro` and `brain` mean the default. Default: The server's embedding model, then `openai/text-embedding-3-small`, then `google/gemini-embedding-001`, whichever you hold a key for.",
                    "type": "string"
                  },
                  "input": {
                    "description": "The text to embed, or several.",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "encoding_format": {
                    "description": "Accepted, but the reply is always arrays of floats.",
                    "type": "string",
                    "enum": [
                      "float",
                      "base64"
                    ]
                  }
                },
                "required": [
                  "input"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One vector per input, in order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `list`.",
                      "const": "list"
                    },
                    "data": {
                      "description": "`{\"object\": \"embedding\", \"index\", \"embedding\": [numbers]}` per input. OpenAI and Google models are asked for vectors of the server's configured dimension.",
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "model": {
                      "description": "`<provider>/<model>` that made them.",
                      "type": "string"
                    },
                    "usage": {
                      "description": "`prompt_tokens`, `total_tokens`.",
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not `{ input: string | string[] }`. `provider_not_configured`: No embedding-capable key: add an OpenAI or Google key. `invalid_provider_base_url`: An OpenAI-compatible endpoint's base URL cannot be used: not a URL, not `https://`, a user name or password in it, or a port not accepted. `provider_base_url_not_allowed`: An OpenAI-compatible endpoint's host is not approved for the organisation, is private or internal, does not resolve, or redirected, whether refused before the request or during it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "`upstream_error`: The provider returned an error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "models",
        "summary": "List models",
        "description": "The model ids this key can ask for, with context and output limits where they are known, in both OpenAI and Anthropic fields.\n\nThe model ids this key can ask for. Always `memtro` and `auto`; then `auto/<provider>` for each provider you hold a key for; then `<provider>/<model>` (or `compat:<label>/<model>`) for each key's models: the list saved with the key, otherwise the provider's own listing, otherwise a built-in list when the provider does not answer. Each row carries the fields OpenAI clients read and the ones Anthropic clients read, so model discovery works from either SDK. Under the organisation's model lock, only the routing ids and `memtro` are listed.",
        "tags": [
          "Models"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/models/"
        },
        "responses": {
          "200": {
            "description": "Every model, in one page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `list`.",
                      "const": "list"
                    },
                    "data": {
                      "description": "The models.",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "The id to send as `model`.",
                            "type": "string"
                          },
                          "object": {
                            "description": "Always `model`.",
                            "const": "model"
                          },
                          "created": {
                            "description": "Unix time, in seconds.",
                            "type": "integer"
                          },
                          "owned_by": {
                            "description": "The provider, or a description for the routing ids.",
                            "type": "string"
                          },
                          "limit": {
                            "description": "`context` and `output` token limits, where known. For `auto` and `memtro` these are the narrowest on the ladder, the only figures true whichever rung answers.",
                            "type": "object"
                          },
                          "type": {
                            "description": "Anthropic's field: always `model`.",
                            "const": "model"
                          },
                          "display_name": {
                            "description": "Anthropic's field: the id.",
                            "type": "string"
                          },
                          "created_at": {
                            "description": "Anthropic's field: `created` as an ISO date.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "has_more": {
                      "description": "Always `false`: there is one page.",
                      "const": false
                    },
                    "first_id": {
                      "description": "The first id, for Anthropic clients.",
                      "type": "string"
                    },
                    "last_id": {
                      "description": "The last id, for Anthropic clients.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An internal error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models/{model}": {
      "get": {
        "operationId": "modelsRetrieve",
        "summary": "Retrieve a model",
        "description": "One model by id, including ids that contain slashes.\n\nOne row of the model list, by id. The path takes the whole id, slashes included, so `GET /v1/models/anthropic/claude-opus-5` works, and so do `/v1/models/auto` and `/v1/models/memtro`. The row has no `limit`, and is not filtered by the model lock.",
        "tags": [
          "Models"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/models-retrieve/"
        },
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "description": "The model id. It may contain `/`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One model: `id`, `object`, `created`, `owned_by`, `type`, `display_name`, `created_at`, as in [List models](https://www.memtro.com/docs/api/models/).",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`model_not_found`: No model with that id is available to this key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An internal error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/memory": {
      "get": {
        "operationId": "memoryList",
        "summary": "List and search memories",
        "description": "Page through the memories this key can read, newest first, or search them by meaning or by words.\n\nWithout `q`, every memory this key can read, newest first, a page at a time. With `q`, a search: by meaning when an embedding model is available to the key, otherwise by words. `search.matched_on` says which was attempted: a search by meaning whose embedding call fails falls back to words and still reports `meaning`. The key's scope decides what is visible, exactly as it does in chat: an organisation key never sees personal memory, a \"mine only\" key never sees shared memory, and team and connection grants apply. A search, and a read by id, count as using the memories they return; a listing does not.",
        "tags": [
          "Memory"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/memory-list/"
        },
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search for this, at least two characters. Search results are not paged.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "Narrow to shared or personal memory. It narrows what the key can read and never widens it: `personal` on an organisation key, or `org` on a \"mine only\" key, is a 400.",
            "schema": {
              "type": "string",
              "enum": [
                "org",
                "personal",
                "all"
              ],
              "default": "all"
            }
          },
          {
            "name": "as_of",
            "in": "query",
            "required": false,
            "description": "A date: memory as it stood then.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Results per page, at most 100: a larger number reads as 100, and anything below 1 or not a number as 20.",
            "schema": {
              "type": "integer",
              "default": 20
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `next_cursor` from the previous page. A cursor that cannot be read starts again from the first page rather than failing.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of memory objects.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `list`.",
                      "const": "list"
                    },
                    "data": {
                      "description": "Memories; in a search each also has `score` (a number, or null).",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "description": "Always `memory`.",
                            "const": "memory"
                          },
                          "id": {
                            "description": "The memory's id.",
                            "type": "string"
                          },
                          "content": {
                            "description": "The statement, as remembered.",
                            "type": "string"
                          },
                          "kind": {
                            "description": "What sort of statement it is.",
                            "type": "string",
                            "enum": [
                              "fact",
                              "decision",
                              "preference",
                              "event",
                              "procedure"
                            ]
                          },
                          "scope": {
                            "description": "Who it belongs to: the organisation, a team, or one person.",
                            "type": "string",
                            "enum": [
                              "shared",
                              "team",
                              "personal"
                            ]
                          },
                          "source": {
                            "description": "Where it came from, such as `chat`, `sync` or `import`.",
                            "type": "string"
                          },
                          "system": {
                            "description": "The connected system it was read from, if any.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "description": "A link to the record it came from, if one was kept.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "description": "How sure the extractor was.",
                            "type": "number"
                          },
                          "importance": {
                            "description": "How much it matters, as the extractor judged it.",
                            "type": "number"
                          },
                          "trust": {
                            "description": "Whether it is believed outright or waiting to be confirmed.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "taint": {
                            "description": "Set when it was learned from outside content.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "corroborations": {
                            "description": "How many times something independent has confirmed it.",
                            "type": "integer"
                          },
                          "valid_from": {
                            "description": "Start of the period the statement is about.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "valid_to": {
                            "description": "End of that period, if it has one.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "superseded_by": {
                            "description": "The id of the memory that replaced it.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "superseded_at": {
                            "description": "When it was replaced.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subject_entity_id": {
                            "description": "The entity the statement is about.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_ids": {
                            "description": "Every entity it mentions.",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "connection_id": {
                            "description": "The connection it was synced through.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "episode_id": {
                            "description": "The exchange or import it was learned from.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "description": "When it was recorded.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "has_more": {
                      "description": "Whether there is another page.",
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "description": "Pass as `cursor` for the next page.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "as_of": {
                      "description": "Listing: the `as_of` you sent.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "search": {
                      "description": "Search only: `query`, `matched_on` (`meaning` or `words`) and `as_of`.",
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`unsupported_parameter`: `q` shorter than two characters, a `scope` the key cannot narrow to, or an `as_of` that is not a date. `param` names which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "memoryImport",
        "summary": "Import an exchange",
        "description": "Hand Memtro a conversation it was not part of, and it learns from it as though it had been: no answer is generated.\n\nTakes an exchange that happened somewhere else (a transcript you already hold, a conversation from another tool) and learns from it as though it had run through Memtro. No answer is generated; the only model call is the one that reads the transcript, charged to the organisation's background allowance and logged like any other. Afterwards the cards of up to four entities the exchange touched are refreshed, so a question about them minutes later reads the new facts.\n\nThe body is the chat-completions shape, with the **last message an assistant turn**, plus a `memtro` object with this endpoint's own options.",
        "tags": [
          "Memory"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/memory-import/"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messages": {
                    "description": "The exchange, in the [chat-completions message shape](https://www.memtro.com/docs/api/chat-completions/#request-body). The last message must be the assistant's, with text in it.",
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "memtro": {
                    "description": "This endpoint's options. (`off` is not a memory setting here, and the chat options do not apply.)",
                    "type": "object",
                    "properties": {
                      "memory": {
                        "description": "Where the facts go. The key's ceiling applies as in chat; a key with nowhere to write is refused with `memory_disabled`. Default: `org` when the key belongs to an organisation, otherwise `personal`.",
                        "type": "string",
                        "enum": [
                          "org",
                          "personal"
                        ]
                      },
                      "transcript": {
                        "description": "`exchange` reads the last turn for facts and the rest as context, as a chat turn does; `conversation` reads every turn. Use `conversation` for a history nothing has read before.",
                        "type": "string",
                        "enum": [
                          "exchange",
                          "conversation"
                        ],
                        "default": "exchange"
                      },
                      "occurred_at": {
                        "description": "When the exchange happened: an ISO date, or anything a JavaScript `Date` can read. Relative dates (\"next Tuesday\") are resolved against it, so set it for anything that did not happen today. Default: Now.",
                        "type": "string"
                      },
                      "learn": {
                        "description": "`always` overrides the check that skips exchanges with nothing memorable in them.",
                        "type": "string",
                        "enum": [
                          "auto",
                          "always"
                        ],
                        "default": "auto"
                      }
                    }
                  }
                },
                "required": [
                  "messages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What was learned, or why nothing was.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `memory.ingest`.",
                      "const": "memory.ingest"
                    },
                    "learned": {
                      "description": "Whether anything was stored.",
                      "type": "boolean"
                    },
                    "reason": {
                      "description": "When nothing was learned: why.",
                      "type": "string"
                    },
                    "episode": {
                      "description": "The id of the recorded exchange.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_ids": {
                      "description": "The memories written.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "entity_ids": {
                      "description": "The entities touched.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "cards": {
                      "description": "Entity cards refreshed.",
                      "type": "integer"
                    },
                    "memories": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "personal": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "entities": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "relationships": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "superseded": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "corroborated": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "attributes": {
                      "description": "Counts: memories stored, how many of them personal, entities, relationships, memories superseded, existing facts this exchange confirmed, and recorded values.",
                      "type": "integer"
                    },
                    "visibility": {
                      "description": "Where it went: `org`, `personal`, or `team:<id>` for a team key.",
                      "type": "string"
                    },
                    "usage": {
                      "description": "`input_tokens`, `output_tokens`, `total_tokens` spent reading it.",
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body failed validation. `unsupported_parameter`: The last message is not the assistant's or has no text (`param: messages`), or `occurred_at` is not a date. `provider_not_configured`: No model is available to read the exchange with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`read_only_key`: The key was issued read only. `memory_disabled`: The key may not write memory. Writing into shared memory without the import permission: send `\"memory\": \"personal\"`, or ask an admin.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`allowance_exhausted`: The background allowance is spent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "`upstream_error`: Reading the exchange failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/memory/{id}": {
      "get": {
        "operationId": "memoryRetrieve",
        "summary": "Retrieve a memory",
        "description": "Read one memory by id.\n\nOne memory, in the same shape as the list. A memory this key cannot read answers exactly as one that does not exist.",
        "tags": [
          "Memory"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/memory-retrieve/"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The memory's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A memory object.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `memory`.",
                      "const": "memory"
                    },
                    "id": {
                      "description": "The memory's id.",
                      "type": "string"
                    },
                    "content": {
                      "description": "The statement, as remembered.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "What sort of statement it is.",
                      "type": "string",
                      "enum": [
                        "fact",
                        "decision",
                        "preference",
                        "event",
                        "procedure"
                      ]
                    },
                    "scope": {
                      "description": "Who it belongs to: the organisation, a team, or one person.",
                      "type": "string",
                      "enum": [
                        "shared",
                        "team",
                        "personal"
                      ]
                    },
                    "source": {
                      "description": "Where it came from, such as `chat`, `sync` or `import`.",
                      "type": "string"
                    },
                    "system": {
                      "description": "The connected system it was read from, if any.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "description": "A link to the record it came from, if one was kept.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence": {
                      "description": "How sure the extractor was.",
                      "type": "number"
                    },
                    "importance": {
                      "description": "How much it matters, as the extractor judged it.",
                      "type": "number"
                    },
                    "trust": {
                      "description": "Whether it is believed outright or waiting to be confirmed.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "taint": {
                      "description": "Set when it was learned from outside content.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "corroborations": {
                      "description": "How many times something independent has confirmed it.",
                      "type": "integer"
                    },
                    "valid_from": {
                      "description": "Start of the period the statement is about.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valid_to": {
                      "description": "End of that period, if it has one.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "superseded_by": {
                      "description": "The id of the memory that replaced it.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "superseded_at": {
                      "description": "When it was replaced.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject_entity_id": {
                      "description": "The entity the statement is about.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "entity_ids": {
                      "description": "Every entity it mentions.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "connection_id": {
                      "description": "The connection it was synced through.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "episode_id": {
                      "description": "The exchange or import it was learned from.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "description": "When it was recorded.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: No such memory, or not one this key can read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "memoryDelete",
        "summary": "Delete a memory",
        "description": "Delete one memory permanently.\n\nDeletes one memory permanently: there is no undo and no soft delete. Your own personal memories can always be deleted; shared memory needs the delete-memory permission.",
        "tags": [
          "Memory"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/memory-delete/"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The memory's id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `memory.deleted`.",
                      "const": "memory.deleted"
                    },
                    "id": {
                      "description": "The id deleted.",
                      "type": "string"
                    },
                    "deleted": {
                      "description": "Always `true`.",
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`read_only_key`: The key was issued read only. `insufficient_permission`: A shared memory, and the key's holder lacks the delete-memory permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: No such memory, or not one this key can read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/entities/{id}": {
      "get": {
        "operationId": "entitiesRetrieve",
        "summary": "Retrieve an entity",
        "description": "One entity from the knowledge graph, with its recorded values, its relationships and its memories.\n\nOne entity from the knowledge graph (a person, a company, a project, a commitment), with the values recorded against it, its relationships with both ends named (ended ones included and marked), and its memories. Entity ids appear on memories as `subject_entity_id` and `entity_ids`. An entity this key cannot read answers exactly as one that does not exist.",
        "tags": [
          "Entities"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/entities-retrieve/"
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The entity's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "memories",
            "in": "query",
            "required": false,
            "description": "How many of its memories to include, at most 100 (read like `limit` on [List and search memories](https://www.memtro.com/docs/api/memory-list/)). Not a page.",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The entity.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `entity`.",
                      "const": "entity"
                    },
                    "id": {
                      "description": "The entity's id.",
                      "type": "string"
                    },
                    "type": {
                      "description": "`person`, `company`, `project` and so on.",
                      "type": "string"
                    },
                    "name": {
                      "description": "Its name.",
                      "type": "string"
                    },
                    "summary": {
                      "description": "A short description.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "card": {
                      "description": "A longer description written from its own memories, where there is enough to write from.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "card_at": {
                      "description": "When the card was written.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope": {
                      "description": "Who it belongs to.",
                      "type": "string",
                      "enum": [
                        "shared",
                        "team",
                        "personal"
                      ]
                    },
                    "aliases": {
                      "description": "Other names it goes by.",
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "external_ids": {
                      "description": "Its ids in the systems it came from, such as a Xero contact id or an email address.",
                      "type": "object"
                    },
                    "properties": {
                      "description": "Further properties.",
                      "type": "object"
                    },
                    "created_at": {
                      "description": "When it was first and last recorded.",
                      "type": "string"
                    },
                    "updated_at": {
                      "description": "When it was first and last recorded.",
                      "type": "string"
                    },
                    "values": {
                      "description": "Values recorded against it (\"ARR = 48,000 GBP since 2026-01-01\"), up to 60.",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "description": "Always `entity.value`.",
                            "const": "entity.value"
                          },
                          "key": {
                            "description": "What, the stated value, and its unit (`unit` may be null).",
                            "type": "string"
                          },
                          "value": {
                            "description": "What, the stated value, and its unit (`unit` may be null).",
                            "type": "string"
                          },
                          "unit": {
                            "description": "What, the stated value, and its unit (`unit` may be null).",
                            "type": "string"
                          },
                          "number": {
                            "description": "The value parsed as a number, if it parsed.",
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "description": "The value parsed as a date, if it parsed.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "valid_from": {
                            "description": "The period it holds for.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "valid_to": {
                            "description": "The period it holds for.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "description": "How sure.",
                            "type": "number"
                          },
                          "source": {
                            "description": "Where it came from.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "memory_id": {
                            "description": "Where it came from.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updated_at": {
                            "description": "When it was last recorded.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "relationships": {
                      "description": "Its relationships, up to 80.",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "The relationship's id.",
                            "type": "string"
                          },
                          "from": {
                            "description": "The entity ids at each end.",
                            "type": "string"
                          },
                          "to": {
                            "description": "The entity ids at each end.",
                            "type": "string"
                          },
                          "relation": {
                            "description": "What the relationship is.",
                            "type": "string"
                          },
                          "since": {
                            "description": "Dates, `YYYY-MM-DD`.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "until": {
                            "description": "Dates, `YYYY-MM-DD`.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ended": {
                            "description": "Present when the relationship has ended.",
                            "const": true
                          },
                          "direction": {
                            "description": "Whether this entity is the `from` (`out`) or the `to` end.",
                            "type": "string",
                            "enum": [
                              "out",
                              "in"
                            ]
                          },
                          "other": {
                            "description": "The other end: `id`, `name`, `type`.",
                            "type": "object"
                          }
                        }
                      }
                    },
                    "memories": {
                      "description": "Its memories, as in [Retrieve a memory](https://www.memtro.com/docs/api/memory-retrieve/): those still current first, then the most important, then the newest.",
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: No such entity, or not one this key can read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "usage",
        "summary": "Usage and allowances",
        "description": "What this key's holder has spent over a window, and the state of each capped allowance this month.\n\nWhat this key's holder has spent over a window (their own requests within the organisation), and the state of every capped allowance this calendar month. Rungs with no allowance are not listed; `active: false` means nothing is capped. The figures behind each rung (the cap, what was spent, what is left, who set it) are included only when the key's holder may read the organisation's costs.",
        "tags": [
          "Usage"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/usage/"
        },
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "The last this many days, 1 to 400. Anything else reads as 30, never an error.",
            "schema": {
              "type": "integer",
              "default": 30
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "A start date, `YYYY-MM-DD`, with `to`. A valid pair wins over `days`; a reversed pair is swapped, and a span over 400 days is cut to the last 400.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "An end date, `YYYY-MM-DD`, with `from`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The window and the allowances.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "description": "Always `usage`.",
                      "const": "usage"
                    },
                    "window": {
                      "description": "The window asked for.",
                      "type": "object",
                      "properties": {
                        "from": {
                          "description": "Its dates, `YYYY-MM-DD`.",
                          "type": "string"
                        },
                        "to": {
                          "description": "Its dates, `YYYY-MM-DD`.",
                          "type": "string"
                        },
                        "label": {
                          "description": "In words, such as `the last 30 days`.",
                          "type": "string"
                        },
                        "requests": {
                          "description": "The totals.",
                          "type": "integer"
                        },
                        "input_tokens": {
                          "description": "The totals.",
                          "type": "integer"
                        },
                        "output_tokens": {
                          "description": "The totals.",
                          "type": "integer"
                        },
                        "total_tokens": {
                          "description": "The totals.",
                          "type": "integer"
                        },
                        "tool_calls": {
                          "description": "The totals.",
                          "type": "integer"
                        },
                        "errors": {
                          "description": "The totals.",
                          "type": "integer"
                        }
                      }
                    },
                    "allowances": {
                      "description": "This month's allowances.",
                      "type": "object",
                      "properties": {
                        "period": {
                          "description": "The month they count in, `YYYY-MM`.",
                          "type": "string"
                        },
                        "period_label": {
                          "description": "The month in words.",
                          "type": "string"
                        },
                        "active": {
                          "description": "Whether anything is capped.",
                          "type": "boolean"
                        },
                        "org_figures": {
                          "description": "Whether the rungs carry the organisation's own figures.",
                          "type": "boolean"
                        },
                        "rungs": {
                          "description": "Each capped rung.",
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "description": "Which ladder.",
                                "type": "string",
                                "enum": [
                                  "general",
                                  "coding"
                                ]
                              },
                              "level": {
                                "description": "The difficulty level, 1 to 5.",
                                "type": "integer"
                              },
                              "role": {
                                "description": "Which rung of the level.",
                                "type": "string",
                                "enum": [
                                  "primary",
                                  "secondary",
                                  "tertiary"
                                ]
                              },
                              "state": {
                                "description": "`low` is 10% or less left.",
                                "type": "string",
                                "enum": [
                                  "ok",
                                  "low",
                                  "exhausted"
                                ]
                              },
                              "limit": {
                                "description": "Tokens, when `org_figures` is true.",
                                "type": "integer"
                              },
                              "used": {
                                "description": "Tokens, when `org_figures` is true.",
                                "type": "integer"
                              },
                              "remaining": {
                                "description": "Tokens, when `org_figures` is true.",
                                "type": "integer"
                              },
                              "set_by": {
                                "description": "When `org_figures` is true: who set the cap, `{kind: \"org\" | \"team\", id, name}`.",
                                "type": "object"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`invalid_api_key`: The key is missing, malformed, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "`subscription_inactive`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "MCP endpoint",
        "description": "Memtro as a stateless Streamable HTTP MCP server: memory and connector tools for any MCP client.\n\nMemtro is a [Model Context Protocol](https://modelcontextprotocol.io) server at `https://platform.memtro.com/api/mcp`: memory tools and every connector tool the key can use, as the key's holder. This page is the endpoint's transport facts; the [MCP server guide](https://www.memtro.com/docs/mcp/) has client setup, and the [Tools reference](https://www.memtro.com/docs/tools/) every tool.\n\nThe transport is Streamable HTTP, stateless, with JSON responses rather than an event stream: each request is complete in itself, with no session to keep. `POST`, `GET` and `DELETE` are all answered by the same handler. A request may run for up to two minutes.",
        "tags": [
          "MCP"
        ],
        "externalDocs": {
          "url": "https://www.memtro.com/docs/api/mcp/"
        },
        "parameters": [
          {
            "name": "tools",
            "in": "query",
            "required": false,
            "description": "`memory` serves the `memtro_*` tools alone.",
            "schema": {
              "type": "string",
              "enum": [
                "memory",
                "all",
                "true"
              ]
            }
          },
          {
            "name": "actions",
            "in": "query",
            "required": false,
            "description": "`none` drops every tool that changes anything.",
            "schema": {
              "type": "string",
              "enum": [
                "none",
                "false",
                "all",
                "true"
              ]
            }
          },
          {
            "name": "connectors",
            "in": "query",
            "required": false,
            "description": "A comma-separated list of connector kinds, such as `xero,github`: only those systems' tools.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "shape",
            "in": "query",
            "required": false,
            "description": "`system`: one tool per connected system; `operation`: one tool per operation. A key can store its own default.",
            "schema": {
              "type": "string",
              "enum": [
                "system",
                "operation"
              ],
              "default": "system"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "A JSON-RPC 2.0 message, as the MCP specification defines.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC response the MCP specification defines.",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "`-32001`: The key is missing, malformed, revoked or expired. The reply carries `WWW-Authenticate: Bearer realm=\"memtro\"`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            }
          },
          "402": {
            "description": "`-32001`: The organisation has no active subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "`Authorization: Bearer sk-memtro-…`"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "The same key, as the Anthropic SDKs send it."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "The OpenAI error envelope. See https://www.memtro.com/docs/api/#errors.",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "param": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "code": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "invalid_api_key",
                      "subscription_inactive",
                      "model_not_found",
                      "provider_not_configured",
                      "invalid_provider_base_url",
                      "provider_base_url_not_allowed",
                      "routing_unavailable",
                      "unsupported_parameter",
                      "invalid_as_of",
                      "not_found",
                      "read_only_key",
                      "insufficient_permission",
                      "memory_disabled",
                      "allowance_exhausted",
                      "engine_unavailable",
                      "upstream_error"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "message",
              "type",
              "param",
              "code"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "AnthropicError": {
        "type": "object",
        "description": "Anthropic's error envelope, on /v1/messages and /v1/messages/count_tokens.",
        "properties": {
          "type": {
            "const": "error"
          },
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "message"
            ]
          }
        },
        "required": [
          "type",
          "error"
        ]
      },
      "JsonRpcError": {
        "type": "object",
        "description": "A JSON-RPC 2.0 error, on /api/mcp.",
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "id": {
            "type": "null"
          }
        }
      },
      "MemtroOptions": {
        "description": "The `memtro` request object.",
        "type": "object",
        "properties": {
          "mode": {
            "description": "`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](https://www.memtro.com/docs/agent-mode/). Default: The organisation's default mode; `chat` when the request declares its own `tools`.",
            "type": "string",
            "enum": [
              "chat",
              "agent"
            ]
          },
          "memory": {
            "description": "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. Default: `org` when the key belongs to an organisation, otherwise `personal`.",
            "type": "string",
            "enum": [
              "org",
              "personal",
              "off"
            ]
          },
          "retrieve": {
            "description": "Put relevant memories and graph context in front of the model.",
            "type": "boolean",
            "default": true
          },
          "tools": {
            "description": "Memtro's own tools: `true` for the memory tools and your connector tools, `\"memory\"` for the memory tools alone, `false` for none.",
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "const": "memory"
              }
            ],
            "default": true
          },
          "show_progress": {
            "description": "In agent mode, stream a text copy of the tool log as `reasoning_content`. The structured `memtro.activity` events are sent either way. Default: The organisation's agent setting, otherwise `true`.",
            "type": "boolean"
          },
          "show_thinking": {
            "description": "Return the model's thinking on wires that have a block for it. Default: Whatever the client asked for on its own wire.",
            "type": "boolean"
          },
          "cache": {
            "description": "Serve identical connector tool calls from the short-lived result cache.",
            "type": "boolean",
            "default": true
          },
          "as_of": {
            "description": "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](https://www.memtro.com/docs/time-travel/).",
            "type": "string"
          },
          "session": {
            "description": "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.",
            "type": "string"
          },
          "project": {
            "description": "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.",
            "type": "string"
          },
          "verify": {
            "description": "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.",
            "type": "boolean",
            "default": false
          }
        }
      },
      "MemtroResponse": {
        "description": "The `memtro` object on a reply.",
        "type": "object",
        "properties": {
          "mode": {
            "description": "The mode the request ran in.",
            "type": "string",
            "enum": [
              "chat",
              "agent"
            ]
          },
          "engine": {
            "description": "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.",
            "type": "string",
            "enum": [
              "native",
              "claude-code",
              "codex"
            ]
          },
          "routing": {
            "description": "How the model was chosen. Present when a routing decision was made (`auto`, `auto/<provider>`, or `memtro` resolving to `auto`).",
            "type": "object",
            "properties": {
              "requested": {
                "description": "The model id the request named.",
                "type": "string"
              },
              "locked": {
                "description": "Present when the organisation's model lock replaced a named model with `memtro`.",
                "const": true
              },
              "model": {
                "description": "The model that was picked. Sent before the run starts, so a hand-over during the run shows in `answered_by` instead.",
                "type": "string"
              },
              "complexity": {
                "description": "The difficulty level the request was placed at, 1 to 5.",
                "type": "integer"
              },
              "method": {
                "description": "What placed it.",
                "type": "string",
                "enum": [
                  "heuristic",
                  "classifier",
                  "fallback",
                  "decision"
                ]
              },
              "reason": {
                "description": "Why, in words.",
                "type": "string"
              },
              "signals": {
                "description": "The signals the decision read, when there were any.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "fallbacks": {
                "description": "The ladder the request could fall back along.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "kind": {
                "description": "Which ladder was used.",
                "type": "string",
                "enum": [
                  "general",
                  "coding"
                ]
              },
              "allowance_shift": {
                "description": "Present when a spent allowance moved the request to another rung.",
                "type": "object",
                "properties": {
                  "from": {
                    "description": "The model that would have answered.",
                    "type": "string"
                  },
                  "role": {
                    "description": "The rung of the level that answered instead, such as `secondary`.",
                    "type": "string"
                  }
                }
              },
              "overhead": {
                "description": "Model calls the request made beside the answer itself, such as the routing decision, when there were any.",
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "citations": {
            "description": "The records retrieval put in front of the model, at most 12.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "system": {
                  "description": "The system the record lives in, as its connector names itself (`xero`, `linear`).",
                  "type": "string"
                },
                "label": {
                  "description": "What to call it in a list.",
                  "type": "string"
                },
                "url": {
                  "description": "Opens the record in its system, when the connector recorded one.",
                  "type": "string"
                },
                "record": {
                  "description": "The record's id in that system, when there is no URL.",
                  "type": "string"
                }
              }
            }
          },
          "grounding": {
            "description": "Coverage, not correctness: how much of what the question named memory had anything behind.",
            "type": "object",
            "properties": {
              "grade": {
                "description": "The share of named things that memory covered, 0 to 1, or null when the question named nothing.",
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "uncovered": {
                "description": "The names memory had nothing on.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "figures": {
                "description": "Each certified figure the question touched, with `name`, `state`, `verdict` and, where there is one, `why`. See [Measures](https://www.memtro.com/docs/measures/).",
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "answered_by": {
            "description": "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.",
            "type": "string"
          },
          "tools": {
            "description": "Memtro's own tool calls during the run. Your client tools come back as tool calls instead.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "tool": {
                  "description": "The tool's name.",
                  "type": "string"
                },
                "input": {
                  "description": "Its arguments, with long strings cut.",
                  "type": "object"
                },
                "ok": {
                  "description": "Whether it succeeded.",
                  "type": "boolean"
                },
                "summary": {
                  "description": "A one-line summary of the result (`3 issues`, `error: …`).",
                  "type": "string"
                },
                "blocked": {
                  "description": "Present when the organisation's action policy held the call rather than the system refusing it.",
                  "const": true
                },
                "urls": {
                  "description": "Links the result asserted, from its identifying fields, never its prose.",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "activity": {
            "description": "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`.",
            "type": "object"
          },
          "bridged": {
            "description": "Present when your own tools were bridged into a `claude-code/*` or `codex/*` run.",
            "const": true
          }
        }
      }
    }
  }
}
