Send your first request
Sign in, create a memtrunk key, find your address and send a first POST /v1/messages request with curl. Then check GET /health and fix common errors.
Last updated
This guide takes you from sign-in to a first working request. You need a memtrunk account. The request can succeed only when a provider account or a provider key is available to your key.
Sign in#
Open the sign-in page of the console. Use the method that your admin enabled. The page can offer Sign in with Google, or the Email and Password fields. After you sign in, the console opens the Dashboard. See sign-in and accounts for details.
Create a key#
- In the console, open API keys.
- Select Create key.
- Enter a Name. You must complete this field. The other fields are optional.
- Select Create.
- Copy the key from the Key created dialog.
Store the key like a password. Claude Code, Codex CLI and Antigravity CLI connect through your personal address instead. The Dashboard setup guide can also create a key that it names after the tool. See connect Claude Code, connect Codex CLI and other clients.
Find the address#
The Dashboard shows the address next to Base URL, with a copy button. While the Dashboard waits for your first request, the setup guide shows the address in its snippets instead.
The address has no path and no trailing slash. The API access page shows a different address that ends in a path. Do not use that address in this guide.
Pick a model#
Request the list of models that your key can reach.
curl "<your-memtrunk-address>/v1/models" \
-H "x-api-key: <your-memtrunk-key>"The reply is a JSON object with "object": "list" and a data array. Each entry has an id. Use one id as the model value in the next request.
Send a request#
curl -X POST "<your-memtrunk-address>/v1/messages" \
-H "x-api-key: <your-memtrunk-key>" \
-H "content-type: application/json" \
-d '{
"model": "<model-id>",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Reply with OK if you can hear me"}
]
}'You can send the key in an Authorization: Bearer <your-memtrunk-key> header instead. The gateway reads the Authorization header first and the x-api-key header second.
The example sends model, max_tokens and messages. The provider that serves the request enforces the rules for the fields. When the Claude pool rejects a request as invalid, the gateway returns status 400. The body has type error and an error object of type invalid_request_error. The message holds the message of the provider. The gateway can add a note that starts with [MemTrunk].
The POST /v1/messages route is the Anthropic Messages endpoint of the gateway. The request appears on the Request logs page after a short delay. If an admin switched request logging off, the page shows no row. The Usage page can show the request instead, if the console offers that page to you.
Check the gateway#
The GET /health endpoint needs no key.
curl "<your-memtrunk-address>/health"The reply is JSON with these fields:
| Field | Meaning |
|---|---|
status | ok when the database answers, otherwise degraded. Only the database check sets this field. |
db | connected or unavailable. |
pool | ok when at least one Claude account is usable. empty when no account exists in any pool. Otherwise degraded. |
total | The number of accounts in all three pools. |
active | The number of usable Claude accounts. |
workers | ok, degraded, idle or unknown. |
version | The gateway version. |
inFlight | The number of requests that the gateway handles now. |
The reply uses HTTP status 200 when status is ok and when it is degraded. Read the status field. Use curl for this check. A browser tab can show a not-found page for /health.
Missing or wrong key#
The gateway answers with status 401 and a JSON body.
| Request | Body |
|---|---|
| The request carries no key | {"detail":"API key required"} |
| An unknown, disabled or expired key | {"detail":"Invalid API key"} |
| A key whose owner account is disabled | {"detail":"Account is disabled"} |
Troubleshooting#
| Symptom | Cause and fix |
|---|---|
401 API key required | The request carries no key, or the key value is empty. Add an x-api-key or Authorization: Bearer header. |
401 Invalid API key | The key is wrong, disabled or expired. Copy the key again, or create a new key. |
401 Account is disabled | The account of the key owner is disabled. Ask your admin. |
401 with authentication_error and Authentication failed. | memtrunk found no provider account or provider key for the request. Ask your admin to connect one. |
429 with rate_limit_error | The key reached a limit, or the accounts that the key can use are exhausted. The message reads Daily spend limit reached, Monthly spend limit reached or Monthly token limit reached for a key limit. Each limit adds retry_after, resets_at and a Retry-After header. Your own subscription accounts and private provider keys still serve requests. |
/health shows "db": "unavailable" | The gateway cannot reach its database. Tell your admin. |
Next steps#
- Connect Claude Code with Connect Claude Code.
- Connect Codex CLI with Connect Codex CLI.
- Connect Antigravity CLI with Use other clients.
- Look up all error bodies in errors and status codes.