Docs/Budget Ai/Keys

Keys

A Budget AI key is what an application or agent presents to the gateway. Keys are issued per project in Budget AI → Keys. A key can call only the model groups it is granted, only until it expires, and only within its limits.

Key format and use

  • Keys look like sk-ants- followed by 40 letters and digits.
  • Send the key as Authorization: Bearer <key> or as an api-key: <key> header. OpenAI SDKs do the first when you pass the key as api_key / apiKey.
  • The full key is shown once, when it is issued or collected. ANTS Platform stores only a salted hash and the last four characters, which the Keys table shows. A lost key cannot be recovered; rotate it instead.
  • Keys work only on the instance that issued them.

Issue a key

You need gatewayAi.keys:write. Placing the key in an org unit also needs gatewayAi.budgets:admin. A Department Owner must place every key they issue in their own unit or one beneath it, and cannot give it a budget.

Open the issue form

Go to Budget AI → Keys and select Issue key.

Choose how the key is delivered

  • Show me the key: the key is created now and shown to you to pass on.
  • Send a collection link: enter the Developer's email. No key exists until that person collects it. See Collection links.

Fill in the key

FieldNotes
AliasA name for the key, up to 64 characters, unique in the project. Shown in traces as gateway.key_alias.
Model groupsAt least one. The key may call only these groups, and GET /v1/models lists exactly these.
Expires inRequired. A number of hours or days. See Expiry.
Monthly budget (USD, optional)Creates a key budget. In a project that budgets in tokens the field is Monthly budget (tokens, optional). See Budgets on keys.

Under Advanced settings:

FieldNotes
RecordingProject default or Usage only - store no prompt or response text. See Recording mode.
Requests per minute (optional)Key RPM limit, 1 to 10,000,000. Empty means no key limit.
Tokens per minute (optional)Key TPM limit, 1 to 10,000,000. Empty means no key limit.
Org unitThe unit whose budgets also apply to this key, or None: an independent key. Units are listed in tree order, each sub-unit indented under its own parent. See Budgets & Limits.
Agent (optional)The agent the key belongs to, from the project's agents. Bind every key an agent uses, so that suspending the agent stops it. None: Suspend agent will not stop this key leaves the key unbound.
Tags (comma separated, optional)Up to 20 tags of up to 64 characters. Tags select tag budgets and filter the Keys table.
Allowed source networks (optional)See Allowed source networks.

Confirm

Select Issue key (or Create link) and complete step-up verification.

With Show me the key, the key is displayed with ready-made snippets for the OpenAI Python SDK, the OpenAI Node SDK and curl, using your gateway address. Copy it into your secret manager before closing the dialog.

A collection link lets a developer collect their own key, so the key is never handled by anyone else.

  • The link names one email address. Only a signed-in account with that address can collect the key, and only if the address is verified or the person signs in through your identity provider.
  • If email is configured on the instance, the link is emailed. Otherwise you copy it and send it yourself. The link is safe to send over chat: it does nothing without a sign-in as that person.
  • The link works for 72 hours and for one collection. Anyone else who opens it is told the link is not for them.
  • The key is created when the link is collected, and its expiry counts from that moment. The key's settings are checked again at collection against the project's current policy, for example the maximum expiry.
  • The developer sees Here is your key once, with the key's expiry, budget, rate limits and the model groups it can call.
  • If you can invite members, Also give them access to this project adds the person to the organization and project as End User, so they can sign in. Without it they can call the gateway but have nothing to sign in to.

Creating and collecting a link are both written to the audit log, with who issued the link and who collected the key.

Expiry

Every key has an expiry date.

SettingDefaultWhere
Default key expiry90 daysProject Settings → Budget AI → Key policy and limits
Maximum key expiry365 daysSame place, up to 3650 days

Expiry can be set in hours or in days, so a key can last only as long as the task it is for. A key's expiry must be in the future and within the project's maximum, whichever unit is used.

The gateway checks expiry on every request. At expiry it refuses the key with 401 key_expired, and the key's expiry is written to the audit log. Expired keys stay in the table so the refusal names the reason.

Keys with less than 24 hours left show a countdown to their expiry in the Keys table. The Keys page also counts keys expiring within the next seven days, and the Last used column shows when each key last made a request. To be told before a key expires, create an automation rule on the Budget AI key expiring event, which fires 30, 14, 7 and 1 days ahead and can notify the key's owner.

Key status

StatusMeaning
activeThe key works
retiringThe key has been rotated and works until its grace window ends
blockedEvery request is refused with 401 key_blocked, or 401 agent_suspended when the key was blocked by suspending its agent
expiredPast its expiry or the end of its grace window; refused with 401 key_expired

Key actions

Each row's menu offers the actions you have permission for:

ActionWhat it doesPermissionStep-up
LimitsShows every budget that applies to the key, with period, amount, spend, remaining and which budget is bindinggatewayAi.budgets:read and gatewayAi.keys:readNo
Network accessEdits the allowed source networksgatewayAi.keys:writeYes
AI GuardrailsSets the key's inspection mode: Use the project setting, Always inspect or Never inspect. Shown when AI Guardrails is on for the organization. See Guardrails.gatewayAi.settings:adminOnly when setting Never inspect
RotateIssues a replacement key, see RotationgatewayAi.keys:writeYes
BlockRefuses every request with the key within a few seconds. The key, its limits and its spend are kept.gatewayAi.keys:admin or tenantSecurity.gatewayKeys:adminNo
UnblockPuts a blocked key back into service. Refused for a key of a suspended agent; resume the agent instead.gatewayAi.keys:admin or tenantSecurity.gatewayKeys:adminYes
DeleteRemoves the key. Any application still using it stops working immediately.gatewayAi.keys:adminNo

Blocking is the reversible way to stop a key. Prefer it to deleting when you may need the key's history or want to undo the action. Security & Compliance members can block and unblock keys through tenant security without being able to issue keys or change credentials.

Moving a key to another org unit is done from Budgets & Limits → Hierarchy and needs gatewayAi.budgets:admin.

Rotation

Rotation issues a new key with the same settings and gives applications time to switch.

Start the rotation

Select Rotate on an active key.

Choose when the old key stops

  • Keep the old key working for 24 hours: both keys work while you redeploy. The old key stops on its own when the window closes.
  • Revoke the old key immediately: anything still using the old key fails now. Choose this if the key may have leaked.

Choose the new key's lifetime

  • Keep the current expiry: rotating does not extend a date the project already set.
  • Start a fresh lifetime: pick a number of days up to the project maximum.

Choose whether to copy budgets and tags

Copy budgets and tags to the new key keeps the key budget's amount, period, enforcement and thresholds, and carries this period's spend over, so rotating cannot reset a cap. A key with a hard budget always carries it over.

Confirm

Select Rotate key and complete step-up verification. The new key is shown once.

Model groups, rate limits, recording mode, org unit, expiry, the network allow-list and the AI Guardrails mode always carry over. The new key's alias is the old alias with (rotated <date>) added. The old key shows as retiring until its window ends.

Blocked and expired keys cannot be rotated, and a key cannot be rotated again while a rotation is in progress.

⚠

While both keys are live during a grace window, each spends against its own budget, so combined spend can exceed the cap until the window closes. Revoke immediately to avoid that.

Short-lived keys for agents

An authorised system, such as an orchestrator that starts agents, can mint a short-lived key for one agent and one task through the key minting API. The request names the agent, the lifetime in minutes, the model groups and a budget. For example: agent invoice-reader, 120 minutes, the prod-chat model group, a 5 USD budget.

ℹ

The key minting API is off by default. Your ANTS deployment turns it on, and until then every call is refused with 403. It needs an organization API key, and the organization needs the API and Budget AI entitlements.

  • The key is bound to the named agent. See Keys bound to an agent. Its AI Guardrails mode is Use the project setting, so the agent's guardrail policy applies when the project inspects content.
  • A budget in USD is required. Like Monthly budget (USD, optional) on the issue form, it resets monthly and is alert only: it records threshold crossings but does not stop requests. To cap what minted keys can spend, place them in an org unit with a hard budget (orgUnitId), or rely on a hard project budget. See Budgets on keys. In a project that budgets in tokens, every mint is refused with 400 This project budgets in tokens.
  • Its lifetime is capped by the project's maximum key expiry, the same as keys issued in the Keys screen. Use at least 5 minutes, because a new key can take a moment to reach every gateway.
  • Limits: at most 100 active keys per agent, and at most 60 keys minted through the API per project per minute. Above either limit the request is refused with 429.
  • The key is returned once, in the API response. It then appears in the Keys table like any other key, with an API badge (created through the key minting API) and its expiry countdown.
  • Minting is written to the audit log with the API key that made the request. No person is recorded as the creator.

When the lifetime ends, the gateway refuses the key with 401 key_expired. Nothing has to revoke it.

⚠

Minting uses a long-lived organization API key. Unlike issuing a key in the console, it is not protected by an emailed code, because a machine cannot answer one. Keep the API key in a secret manager and revoke it if it leaks. The per-agent and per-minute limits, the minted keys' short lifetimes, and a hard budget on their org unit or project bound what a leaked key can do.

Keys bound to an agent

A key can be bound to one agent. Choose the agent in Agent (optional) when you issue the key. Keys minted through the key minting API are always bound to the agent named in the request. A key issued with None: Suspend agent will not stop this key is not bound to any agent.

Every request made with a bound key is recorded under its agent: the trace and the generation carry the agent's ID and name, so the request's cost counts for that agent in Agent Cost Analysis, the AI Agent Center and dashboards that group by Agent Id. The bound agent wins over any agent the caller names in langfuse-metadata. Requests on a key that is not bound to an agent show as Unattributed in Agent Cost Analysis, under AI Gateway and the model group. Binding a key does not change requests recorded before.

Rotating a bound key keeps the binding. When AI Guardrails inspection applies, a bound key is inspected with its agent's guardrail policy, and tool calls are checked against the agent's declared tools.

Suspending the agent

To stop an agent, select Suspend agent in its detail panel in the AI Agent Center. It needs the same permission as Block.

  • The confirmation says how many active keys in the project are not tied to any agent: those keys keep working after the suspension.
  • Every key bound to the agent that is not already blocked is blocked in one transaction. The gateways pick up the change within a few seconds, and requests with those keys are refused with 401 agent_suspended and the message "This agent has been suspended by an administrator."
  • In the Keys table these keys show blocked and a suspended badge next to the agent name.
  • While the agent is suspended, keys cannot be issued for it (in the console, by collecting a link or through the key minting API) or rotated, and its keys cannot be unblocked one by one.
  • Resume agent needs step-up verification and unblocks only the keys the suspension blocked. A key that was already blocked before the suspension stays blocked.

Only keys bound to the agent are affected. To stop a single key, use Block (see Key actions).

Allowed source networks

A key can be confined to source networks. Enter IPv4 or IPv6 addresses or CIDR ranges, up to 50, when issuing the key or later with Network access. Requests from any other address are refused with 403 ip_not_allowed before they reach a provider. The refused attempt is recorded with the caller's address (gateway.source_address) so you can see where it came from.

An empty list allows any source. The gateway determines the caller's address from the proxies in front of it; on a self-hosted deployment this must be configured correctly. See Self-Hosting & Configuration.

Recording mode

ModeWhat is stored
Full (project default)Prompts and responses are stored on the trace, like any SDK trace
Usage onlyNo prompt or response text is stored. Token counts, cost, model, latency, routing detail, limits and caller attribution are kept.

Choose Usage only for keys that carry sensitive content. A usage-only key also never writes to the response cache. Recording mode is chosen when the key is issued and carried over on rotation. Usage-only traces carry gateway.logging_mode = usage_only.

Budgets on keys

Monthly budget (USD, optional) on the issue form, or Monthly budget (tokens, optional) in a project that budgets in tokens, creates a key budget that resets monthly and is alert only: it records threshold crossings at 50 %, 80 % and 100 % but does not stop requests. To make it stop requests, or to change its period or thresholds, edit it in Budgets & Limits and set When reached to Stop requests. See Budgets & Limits.

The Spend vs budget column on the Keys table shows the key's spend against that amount.

What happens to refused requests

Refusals for blocked, expired or network-confined keys are recorded as traces at most once per minute per key and reason, so a withdrawn key cannot be used to fill your project with traces. Further attempts are counted in gateway metrics only. Requests with an unknown key are never traced.

Audit trail

Issuing, minting through the API, rotating, blocking, unblocking, deleting, changing networks, changing the AI Guardrails mode, moving a key between org units and expiry are each written to the audit log with before and after values. Suspending and resuming an agent write one entry each (resource type agent, actions suspend and resume) with the number of keys changed. Key material never appears in the audit log, traces or logs.

© 2026 ANTS Platform, Inc.Docs v1.0 · Last updated June 2026