Gateway endpoints reference
Reference for the gateway request paths. It covers Anthropic Messages, count_tokens, OpenAI Chat Completions, OpenAI Responses, the model list and health.
Last updated
A client sends requests to the gateway at the paths on this page. Replace <your-memtrunk-address> with the address of your memtrunk instance. Each path except GET /health checks the memtrunk key in the request headers. The gateway accepts other request formats too. This page does not cover them.
Path summary#
Anthropic Messages#
| Method and path | What it serves | Reply |
|---|---|---|
POST /v1/messages | Anthropic Messages requests | Messages JSON or an event stream |
POST /v1/messages/count_tokens | A token estimate for a Messages body | {"input_tokens": N} |
OpenAI formats#
| Method and path | What it serves | Reply |
|---|---|---|
POST /v1/chat/completions | OpenAI Chat Completions requests | OpenAI-style JSON |
POST /v1/responses | OpenAI Responses requests | Responses JSON or an event stream |
POST /v1/responses/compact | OpenAI Responses compact requests | One JSON reply |
Models and health#
| Method and path | What it serves | Reply |
|---|---|---|
GET /v1/models | The model list for your key | A list object |
GET /models | The same model list | A list object |
GET /health | A health check without a key | A small JSON object |
Anthropic Messages#
POST /v1/messages#
This path serves Anthropic Messages requests. Send a JSON body in the Anthropic Messages format.
The gateway reads model to choose a route. It reads stream to choose the reply mode. It also reads other fields, such as metadata, messages and max_tokens. The gateway sends the request on to the provider. The provider defines the other field rules.
When stream is true, the reply is a server-sent event stream. Otherwise the reply is one JSON message.
Your accounts, provider keys and routing rules decide which provider serves the request. See routing rules and account pools.
curl https://<your-memtrunk-address>/v1/messages \
-H "Authorization: Bearer <your-memtrunk-key>" \
-H "content-type: application/json" \
-d '{"model":"<model-id-from-the-model-list>","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'POST /v1/messages/count_tokens#
This path returns a token estimate for a Messages-style body. The gateway computes the estimate itself. It reads system, tools and messages and counts about one token for every four characters. The number is an estimate and not the count of the provider.
{"input_tokens": 12}OpenAI formats#
POST /v1/chat/completions#
This path serves OpenAI Chat Completions requests. The gateway reads model to choose a route. The provider defines the other field rules.
ChatGPT accounts and provider keys serve this path. Claude and Antigravity accounts do not serve it. Some model names can use a free-model route if the instance allows it. The reply is OpenAI-style JSON. This page does not describe streaming on this path.
POST /v1/responses#
This path serves OpenAI Responses requests. The gateway reads model to choose a route. It reads stream to choose the reply mode. The provider defines the other field rules.
The reply is an event stream unless stream is false. Then the reply is one JSON object. The same handler also answers POST /responses.
ChatGPT accounts, provider keys, Claude accounts and Antigravity accounts can serve this path.
POST /v1/responses/compact#
This path serves OpenAI Responses compact requests. The reply is always one JSON object and never a stream. The same handler also answers POST /responses/compact.
Models and health#
GET /v1/models and GET /models#
Both paths run the same handler. The reply lists the models that your key can use. The list leaves out models from providers that your key does not allow. It also leaves out Claude models when no Claude account is usable.
{
"object": "list",
"data": [
{"id": "<model-id>", "object": "model", "owned_by": "<provider>"}
]
}Each entry has id, object and owned_by. An entry can also carry created and description.
curl https://<your-memtrunk-address>/v1/models \
-H "x-api-key: <your-memtrunk-key>"GET /health#
This path needs no key. It returns a JSON object. The status field is ok when the database answers and degraded when it does not. The db field is connected or unavailable. The object also carries version, total, active, pool, workers and inFlight.
curl https://<your-memtrunk-address>/healthRelated pages#
- Authentication headers lists the accepted key headers.
- Errors and status codes lists the replies when a request fails.
- Client variables lists the settings for Claude Code, Codex CLI and Antigravity CLI.