How a request travels through memtrunk
Follow one request from your coding tool through the memtrunk key check, routing rules and a provider account or key, and see what you set up as a developer.
Last updated
memtrunk sits between a coding tool and an AI provider. The tool sends its normal request to the memtrunk address. memtrunk checks the key, chooses a provider credential and forwards the request.
The request path#
The numbered list shows the path of one POST /v1/messages request.
- The client sends the request to the memtrunk address with a memtrunk key.
- The gateway reads the key from the
Authorization: Bearerheader or thex-api-keyheader. A missing or unknown key gets status 401. - The gateway checks the spend and token limits that apply to the key. If the key reached a limit, the gateway returns status 429 and forwards nothing.
- The gateway applies routing rules. A rule can send a request for one model to a different model, and it can name a fallback.
- The gateway chooses a credential. The credential is an account from an account pool or a provider key.
- The provider answers, and the gateway returns the answer to the client.
The other request formats use the same key check. See other clients.
Account pools and provider keys#
An account pool holds provider accounts that people connected to memtrunk. The console shows pools for Claude, ChatGPT and Antigravity. A provider key is an API key from a provider, which memtrunk uses to call that provider.
The settings of your memtrunk key can limit which providers may serve a request. A routing rule applies only when your key may use the provider that the rule names.
Some features apply to one pool only. For example, a request on POST /v1/messages can receive recalled memory notes only when the Claude pool serves it. Read the page for a feature before you rely on it for a provider.
Read account pools and provider keys for details.
Where memory fits#
memtrunk memory can add recalled notes to a request before the gateway sends it to the Claude pool. Memory has its own settings. Read memory for them.
Where the console fits#
The console is the web application for memtrunk. You use these pages:
- Dashboard shows the address of memtrunk next to Base URL. It also holds setup guides for coding tools.
- API keys lists your keys and creates new keys.
- API access shows SDK and HTTP examples for your connection.
- Request logs lists the requests that passed through memtrunk. An admin can switch request logging off.
What to configure#
Do these tasks once for each coding tool:
- Open the setup guide on the Dashboard. Copy your personal address. Claude Code, Codex CLI and Antigravity CLI connect through it.
- Give the address to the client. Claude Code reads environment variables. Codex CLI reads a provider block in its config file. Antigravity CLI reads environment variables and a settings file.
- If the console shows no personal address, create a memtrunk key on the API keys page. Use the key with the memtrunk address instead.
- Make sure that a provider account or a provider key is available to your key. The request can succeed only then.
Next steps#
- Send a first request with the quickstart.
- Connect a tool with Connect Claude Code, Connect Codex CLI or Use other clients.
- Look up headers in authentication headers.