Provider keys for AI providers
Learn how provider keys work in memtrunk. See how to add a key, the private key limit, which paths use which type, and how a custom key serves /v1/messages.
Last updated
A provider key is an API key that you get from an AI provider. You add it to memtrunk. The gateway then uses it for the requests it sends to that provider. A provider key is different from a memtrunk key. Your client sends a memtrunk key to the gateway. Read Credentials for the difference.
Providers#
| Provider | How you pick it in the console |
|---|---|
| OpenAI | Quick fill |
| Anthropic | Protocol |
| DeepSeek | Quick fill |
| Azure OpenAI | Protocol |
| Qwen | Quick fill |
| OpenRouter | Quick fill |
| Mistral | Quick fill |
| xAI | Quick fill |
| Groq | Quick fill |
| AWS Bedrock | Quick fill |
| An OpenAI-compatible endpoint that you choose | Protocol, set to OpenAI-compatible. This is a custom key. |
The Protocol list and the Quick fill chips can show other providers that this page does not cover.
Add a provider key#
- Open Provider keys in the console.
- Select Add provider key.
- Choose a Protocol, or select a Quick fill chip.
- Enter a Name and the API key.
- Enter the Base URL. For Azure OpenAI, enter the Azure endpoint and the Deployment name. The API version is optional.
- For an OpenAI-compatible key, you can list Models. Enter a Model ID for each model.
- Select Add key.
An OpenAI-compatible (custom) key needs a Base URL. The console asks for it before you can add the key. If you add a custom key without models, the gateway tries to read the model list from the endpoint.
Private and shared keys#
A key that a member or org admin adds is private. The console shows Key pool only to a user who may add a shared key. The choices are Shared pool (serves every user) and Private (only you). A shared key needs an admin role that memtrunk allows for this action. An org admin does not have that role.
A user can own at most 10 private provider keys. The console shows how many you used. At the limit, the console says You have reached the limit of 10 private keys. Delete one to add another.
Who can draw a key#
A private key serves only the requests of its owner. Other users do not draw it.
Suppose a user owns a private key of one type. Then the requests of that user draw only their own private keys of that type. They do not fall back to a shared key of that type.
Switch a key off for gateway requests#
The Add and Edit dialogs have the setting Use this key for gateway requests. The setting is on by default.
Turn the setting off to keep the key for other features, such as memory. The gateway then does not pick the key for client requests.
A key that is switched off still works for these actions:
- Memory can still use the key.
- Validate and the model list of the key still work.
The console shows a Gateway off marker in the Status column of the table. The key details show Gateway off too.
A switched-off private key still counts as your private key. The gateway does not move your requests to a shared key of that type. When a request would use that key, the reply is HTTP 409 with Your private <provider> key is switched off for gateway routing.
Set a monthly limit on a key#
The Add and Edit dialogs let you choose Unlimited or Limit per month (USD). A new key is Unlimited. The Provider keys table has a Monthly limit column. It shows the spend as $X of $Y this month for a key with a limit.
The gateway adds up the estimated cost of the requests that the key served in the current UTC month. When the spend reaches the limit, the gateway stops using the key until the next UTC month. A limit of 0 blocks the key. The table then shows a Blocked badge. A key at its limit shows a Limit reached badge.
- A shared key at its limit is skipped. The gateway tries the next key.
- A private key at its limit does not serve its owner. The owner gets a 429 that names the key and carries a
Retry-Afterheader. The gateway does not move the request to a shared key.
The message reads Provider key "<name>" reached its monthly limit. It spent $X of its $Y limit this month. The limit resets at <time>. The body repeats the values as limit_usd, spend_usd, resets_at and retry_after.
These limits apply:
- The check runs before the gateway sends a request. Requests that are already running can push a key above its limit.
- The limit reads a monthly total that the gateway keeps for each key. Older spend counts only while it is in the usage history. The history keeps only the newest 2,000 rows for all users together.
- Memory features that use a key through the gateway count toward the limit. At the limit, the gateway refuses the memory request with HTTP 429.
- A memory feature that calls the provider with its own copy of the key does not count toward the limit.
Which request paths use which provider#
Chat completions and /v1/responses use more providers than /v1/messages.
| Request path | Providers that serve it |
|---|---|
/v1/chat/completions and /v1/responses | Include OpenAI, Azure OpenAI, DeepSeek, Qwen, OpenRouter, Mistral, xAI, Groq, AWS Bedrock and an OpenAI-compatible endpoint |
/v1/messages | Anthropic, and an OpenAI-compatible endpoint under the condition in the next section |
An app assignment can widen the key types that serve /v1/messages. This page does not cover app assignments.
A custom key on /v1/messages#
A custom key serves a /v1/messages request when all of these conditions are true:
- The
modelvalue in the request exactly matches a Model ID on the custom key. The match is case-sensitive. - The key is enabled, the caller may draw it and the key is not switched off for gateway requests.
- The memtrunk key has Custom & provider keys switched on.
- The key owner has Claude enabled.
- The gateway tries a usable subscription account first. The custom key serves the request when no usable subscription account matches the model family. The custom key can also serve the request after the subscription pool fails.
When several custom keys list the same model, the key with the fewest total requests serves the request.
What a provider key does not do#
- A provider key does not sign a client in to the gateway. A client needs a memtrunk key.
- A private provider key does not serve the requests of another user.
- An OpenAI key or an Azure OpenAI key does not serve
/v1/messages.
A memtrunk key carries its own spend limits, which are separate from the monthly limit of a provider key. Read Spend limits.