Security
This page summarises the security controls in Budget AI for security and compliance reviewers. Day-to-day use is covered in Keys and Providers & Credentials.
Keys
- Generation. Keys are
sk-ants-followed by 40 characters drawn uniformly from letters and digits with a cryptographic random source, about 238 bits of entropy. - Storage. Only a salted SHA-256 hash of the key and its last four characters are stored. The plaintext is shown once, at issue or collection, and is never stored, logged, traced or returned again.
- Lookup. The gateway looks a presented key up by its hash in memory. An unknown key costs one hash and is refused without a database read, and is never traced.
- Scope. A key can call only the model groups it is granted, only until it expires, and only within its rate limits and budgets. Every key has an expiry, set in hours or days and bounded by the project's maximum (365 days by default, configurable up to 3650). Expiry is checked on every request. Short-lived keys for one agent can be minted by API within the same maximum.
- Network confinement. A key can be limited to source networks. An address outside the list, or an address that cannot be determined, is refused before any provider is called. An empty list means unrestricted. On self-hosted deployments the trusted proxy setting must match the network path, or callers could forge their address. See Client addresses behind proxies.
- Order of checks. Block, then expiry, then network, so a blocked key reports
key_blocked(oragent_suspendedwhen its agent is suspended) without revealing anything about the caller's network. - Delivery. Collection links let developers collect their own key. A link is bound to one email address, needs a verified address or an identity-provider sign-in, works once and expires after 72 hours. The key does not exist until it is collected.
- Rotation. A replacement key keeps the old key's grants, limits, network list and hard budget, and carries the period's spend, so rotation cannot be used to shed a control or reset a cap. The old key's grace window cannot outlive its expiry, and the old key is refused as soon as the window ends.
- Incident response. Blocking a key takes effect on every gateway replica within about a second. Security & Compliance members can block and unblock keys through tenant security without being able to issue keys or change credentials.
- Agent suspension. Suspend agent blocks every key bound to an agent in one transaction and records who suspended it and when. Requests with those keys are refused with 401
agent_suspended. While the agent is suspended, no key can be issued, collected, rotated or unblocked for it. Resuming needs step-up verification and unblocks only the keys the suspension blocked, so a key blocked by hand stays blocked. Keys that are not bound to the agent, and credentials the agent holds outside ANTS Platform, are not affected. - Abuse of withdrawn keys. Refusals for blocked, expired and network-confined keys are traced at most once per minute per key and reason, so a withdrawn key cannot be used to flood a project's traces.
Content inspection
With inline AI Guardrails on, the gateway inspects each chat completion request before it reaches the model, and each response before or while it reaches the caller, with the same policies as AI Guardrails.
- Off by default. The organization's AI Guardrails feature, the project switch Inspect content with AI Guardrails and each key's mode decide whether a request is inspected. With the organization feature off, nothing is inspected whatever a key says.
- Scope. The text of the system prompt and of every user and tool turn, the response text, and tool call names against the agent's declared tools. File uploads, images, audio, earlier assistant turns, tool arguments and embeddings are not inspected.
- Streams. Streamed responses are inspected while they stream by default; a Block or Redact ends the stream, and some text may have reached the caller first. Hold until scanned sends nothing uninspected, at the cost of the first token arriving only after the whole response.
- Fail open or fail closed. Each project chooses what happens when inspection cannot finish within its time limit (1,500 ms by default, 100 to 10,000 ms). Fail closed refuses with 503
guardrail_unavailableand never forwards uninspected content; fail open forwards it and records the reason on the trace. An inspection that did not finish is never cached as a pass. - No policy, no inspection. A key whose agent has no Real-time Enforcement policy, in a project with no policy for keys without an agent, is served without content inspection under either setting, and its traces record
no_policy. - Weakening is guarded. Turning inspection off for a project, switching it to fail open and setting a key to Never inspect need
gatewayAi.settings:adminand step-up verification, and each has its own audit action.
Provider secrets
- At rest. Secrets are encrypted with AES-256-GCM under the platform's
ENCRYPTION_KEY, or stored in AWS Secrets Manager with only a reference in the database. The reference path is derived from the project and credential, never taken as input, and a reference outside its own project is refused without being fetched. - Never returned. Secrets do not appear in any API response, the UI (beyond the last four characters), logs, traces, audit entries or
/metrics. - Redaction. Logs are redacted by value against the live secrets the gateway holds, by the
sk-ants-key prefix, and by sensitive field names, so a secret inside an error message or URL is still masked. - Base URLs. A provider base URL receives the secret, so URLs pointing at loopback, private, link-local or cloud metadata addresses, or embedding credentials, are refused.
- Rotation and moves read the new value back before switching to it, so a failed write never leaves a credential pointing at a missing secret.
- In memory. While serving, the gateway holds provider secrets in process memory. This is inherent to any proxy. It is narrowed by the workload controls below.
Budget AI budgets apply to traffic through the gateway. A stolen provider secret used directly against the provider bypasses them. Set a spend cap in each provider's own console; the credentials list flags credentials with no cap recorded.
Fail-closed behaviour
- If a gateway replica cannot confirm its configuration is current within 5 seconds, it refuses requests with 503
gateway_config_stalerather than serving with possibly outdated keys, grants or limits. - If Redis, which holds limits, budgets and reservations, is unavailable, requests are refused and nothing reaches a provider.
- A key whose org unit budget chain cannot be built is refused rather than served without its unit's budget.
- A hard dollar budget refuses a model with no price rather than serving spend it cannot count.
- A hard token budget with Cap output to budget on sends every request with an output limit that fits the tokens left, so the provider's own default output length cannot run past the budget.
- With AI Guardrails inspection set to refuse what it cannot inspect, a request or response that cannot be inspected is refused with 503
guardrail_unavailable, and nothing uninspected is forwarded. - Turning off Serve gateway traffic for this project, or the organization losing the
llm-gatewayentitlement, stops every key of the project within a minute at most, usually within a second.
Step-up verification
These actions ask the person to verify their identity again with step-up verification before they take effect:
- issuing a key or creating a collection link;
- rotating a key;
- changing a key's allowed source networks;
- unblocking a key;
- resuming a suspended agent;
- turning AI Guardrails inspection off for a project, switching it to forward what it cannot inspect, or setting a key to Never inspect;
- creating, changing, rotating, moving or importing a provider credential;
- assigning or removing a Budget AI role.
Every check is made on the server, so it cannot be bypassed by calling the API directly. On a deployment that cannot send verification codes, an explicit confirmation is accepted instead and recorded in the audit log.
Audit logging
Every Budget AI change is written to the audit log in the same database transaction as the change, with who made it and the values before and after:
| Resource | Actions recorded |
|---|---|
| Keys | Create, collection link created and collected, minted through the API, rotate, block, unblock, delete, network change, org unit change, expiry, AI Guardrails mode |
| Agents | Suspend and resume, with the number of keys changed |
| Provider credentials | Create, update, import, rotate, move between stores, delete |
| Model groups and deployments | Groups created, updated (including routing, fallbacks, cache and the default output reserve) and deleted; deployments added, changed (including pause and resume) and removed |
| Budgets and org units | Create, update, delete; unit create, rename, move, delete |
| Budget AI roles | Role assigned and removed |
| Project settings | Serving on or off, budget unit, key policy and limits, health checks, AI Guardrails switch, failure setting, default policy, time limit and streaming mode |
A collected key records both who issued the link and who collected it, with the collector's address.
Access control
Budget AI uses per-page permission scopes for overview, keys, budgets, models and settings, with a separate incident-response permission for blocking keys and suspending agents. Budget AI roles can confine a member to one org unit and the units beneath it; every request is checked on the server against the caller's units, and a key or unit outside them is answered as not found. Every Budget AI action also re-checks the plan entitlement, the feature flag and module visibility on the server. See Access control, Members & Roles and Custom Roles.
Data handling
- Prompts and responses are stored on traces like any other trace in the project, subject to the project's data retention.
- Keys in usage-only recording mode store no prompt or response text, and never write to the response cache.
- With AI Guardrails inspection, a blocked request or response is not stored on the trace, a redacted one is stored masked, and no prompt or response text is put in a log or header. Inspected requests bypass the response cache.
- Caller metadata can never overwrite gateway metadata, so a caller cannot disguise gateway traffic as SDK traffic.
- The response cache is scoped to one model group in one project.
Workload hardening (self-hosted)
The Helm chart runs the gateway as non-root with no privilege escalation, a read-only root filesystem, all Linux capabilities dropped and the RuntimeDefault seccomp profile. /metrics is served only on the admin port, which is not on the Service or ingress. An optional egress network policy limits the gateway to DNS, the platform's data services, listed provider endpoints and, with AI Guardrails scanning on, the guardrail ML service and RabbitMQ. With AWS Secrets Manager, use a workload identity scoped to the secret prefix instead of static credentials. See Self-Hosting & Configuration.
Not yet available
Expiry reminders and budget threshold alerts are recorded in the product but not delivered by email or chat. Request-and-approve key issuance is not available. See the Roadmap.