Quick answer: Virtual keys in an LLM gateway are gateway-issued credentials that let applications authenticate without holding the underlying provider API keys. Depending on the gateway, a virtual key can also carry policies for budgets, rate limits, model access, routing, and usage attribution.
Every application that calls OpenAI, Anthropic, or Gemini directly needs a provider API key sitting in its code or environment variables.
That’s fine for one service and one developer.
It stops being fine the moment a second team spins up a project, a third integrates a coding agent, and a fourth asks finance why last month’s model spend tripled. Now there are provider keys scattered across repos, secret managers, and Slack messages, and revoking one means finding every service that depends on it first.
This is the exact problem virtual keys in an LLM gateway were built to solve. Instead of handing every application a raw provider credential, a gateway issues its own scoped credential, called a virtual key, and keeps the real provider keys locked behind it. Understanding what these are, how they work, and what they actually control matters before you evaluate any gateway implementation. That’s the goal here. This connects directly to the broader LLM gateway architecture question, and later on, to a boundary that trips up a lot of platform teams: what a gateway governs versus what only an AI agent governance layer can govern.

What are virtual keys in an LLM gateway?
A virtual key is a gateway-managed credential that an application presents when it wants to use an LLM through the gateway. Instead of giving that application a provider’s API key, the gateway authenticates the virtual key, checks the policies associated with it, and uses its own provider credentials to complete the request.
The result is a separation between the credential an application holds and the credentials the gateway uses upstream. The application can therefore be given its own access limits without exposing the provider secrets shared behind the gateway.
The application doesn’t need to know which provider actually services the request, what that provider’s real key looks like, or how many other applications share the same underlying credential.
Two things happen at once: the provider key stays centralized and hidden, and every request gets a policy check it wouldn’t get with a raw key. Each app gets its own virtual key that the gateway mints and can revoke independently, and if a virtual key leaks, you revoke just that one while the underlying provider secret never moves.
Terminology matters because “virtual key,” “proxy key,” and “gateway token” can refer to different implementation patterns. This guide uses “virtual key” specifically for a credential issued and enforced by the gateway.
How do virtual keys work?
Virtual keys work through a four-step cycle: create, configure, authenticate, and enforce. Here’s what each step actually does.
1. Create. A gateway administrator generates a virtual key for a specific application, team, project, or agent. This is a deliberate act, not an automatic byproduct of deployment. Someone decides that this consumer needs gateway access and issues a credential scoped to it.
2. Configure. The administrator attaches policy to the key: which models it can call, which providers it can route through, how much it can spend, and how fast it can send requests. Each virtual key can be mapped to a specific identity and policy.
3. Authenticate. The application sends its requests to the gateway using the virtual key, typically as a bearer token or a custom header. The application code doesn’t change based on which provider ultimately handles the request.
4. Enforce and route. When a request arrives, the gateway checks the virtual key, applies its policy, and either allows or rejects the request before forwarding anything to a provider. If it passes, the gateway attaches the real provider credential and sends the request on. The application never touches that credential at any point.

Here’s what that looks like in practice for a single request:
Application → POST /v1/chat/completions
Header: Authorization: Bearer vk_finance-app-prod
Gateway → validates vk_finance-app-prod
- model requested: gpt-4o (allowed)
- monthly budget: $340 of $500 used (allowed)
- RPM: 12 of 60 (allowed)
Gateway → attaches real OpenAI key → forwards request
Gateway → logs usage against vk_finance-app-prod
The application never sees the OpenAI key. The gateway sees everything: which key made the call, what it cost, and whether it stayed inside its limits.
What can you control with virtual keys?

You can control cost, rate, model access, provider access, usage attribution, and the lifecycle of the credential itself, all without touching application code. Each of these lives as a policy attached to the virtual key rather than something enforced downstream.
- Cost. Set a spending cap or token quota per key, so when a key hits its ceiling the gateway can reject further requests rather than letting spend run unchecked until an invoice arrives.
- Rate. Requests-per-minute and tokens-per-minute limits stop a single misconfigured loop or runaway script from consuming shared provider capacity. Rate limiting is available in many gateway implementations, although the way limits are configured and attached to virtual keys varies by product. Bifrost, for example, supports RPM and TPM limits at the virtual-key level.
- Models. Allow or deny specific models per key. A customer support bot might be allowed a lower-cost model but blocked from a more expensive frontier model, keeping cost predictable without a human reviewing every request.
- Providers. Restrict which upstream providers a key can route through. A regulated workload might be locked to a single approved provider, while a prototyping key gets broader access.
- Usage. Because every request carries a key identifier, spend and consumption attribute cleanly to a team, project, or application, not to a shared, anonymous pool.
- Lifecycle. Revoke or rotate an individual key without disrupting anyone else. When a team revokes a virtual key, every workload using it loses access immediately, and when budgets reset, every dependent service inherits the new window.
Some gateway implementations extend virtual keys beyond model access into tool-level controls. Bifrost, for example, supports MCP tool filtering alongside virtual-key budgets, rate limits, and model restrictions. These are implementation-specific capabilities rather than requirements of the virtual-key pattern itself.
Virtual keys vs provider API keys
A virtual key doesn’t replace the provider credential. It creates a controlled layer in front of it, and that distinction is where most of the practical value sits.
Provider API key vs virtual key: a quick comparison
| Capability | Provider API key | Virtual key |
| Issued by | Model provider | Gateway |
| Visible to application | Yes | Yes |
| Grants direct provider access | Yes | No |
| Central policy enforcement | Limited | Yes |
| Per-app attribution | Limited | Yes |
| Easy individual revocation | Depends | Yes |
A raw provider key can give an application direct access to the models and capabilities permitted by that provider account or key configuration. The exact scope varies by provider, but the application is still interacting directly with the provider rather than through an independent gateway policy layer. A provider key generally governs access within that provider’s own platform. It doesn’t provide the same cross-provider policy layer that a gateway can use to standardize model allowlists, budgets, routing, and attribution across multiple providers.
The tradeoff isn’t security versus convenience. It’s centralized, policy-driven access versus a flat, all-or-nothing credential. Once an organization has more than a handful of applications calling models, the flat model breaks down fast.
How do virtual keys improve LLM gateway security?

Virtual keys narrow the blast radius of a credential leak and keep provider secrets out of application code, but they are not a complete security boundary on their own. Their effectiveness depends entirely on how the gateway itself handles authentication, storage, rotation, and permissions.
What they do reliably: provider credentials stay centralized in one place instead of scattered across services, a leaked virtual key exposes only the scope attached to it rather than full provider access, keys can be revoked independently without a coordinated rotation across every dependent service, and applications no longer need to hold long-lived provider secrets at all.
What they don’t do automatically: guarantee the gateway itself is hardened, prevent misuse within a key’s granted scope, or replace the need for careful secret storage. A poorly built gateway that logs raw virtual key values on failed authentication attempts, or stores keys without encryption, undermines the benefit entirely. The control is only as strong as the layer enforcing it.
Virtual keys therefore reduce credential exposure and centralize policy enforcement, but they don’t eliminate the need for provider-side security, secret management, authentication, or application-level controls.
Virtual keys, agents, and the governance gap
A virtual key answers one question well: which application or client is allowed to call which models, under what limits. It does not answer a second, increasingly important question: which agent is behind that application, who owns it, what version is running, and what has it actually done with the access it was given.
That gap didn’t matter much when “applications calling models” meant a handful of backend services. It matters a great deal now that agents call models on their own initiative, chain tool calls together, and act with far less direct human review per request. Gartner predicts that 40% of enterprise applications will be integrated with task-specific AI agents by the end of 2026, up from less than 5% today. A virtual key scoped to “the customer service app” tells you nothing about which of the dozen agents running inside that app made a specific decision, or whether that agent was ever approved for production.
This is the boundary worth being precise about: an LLM gateway governs model traffic and API access. A control plane governs the agent and its lifecycle, before and after it ever calls a model. You can centralize model traffic with a gateway, but the harder question is who governs the AI agents built on top of it once there are dozens or hundreds running in production, and that’s a layer that operates independent of which LLM gateway or model sits underneath it, closer to what Lyzr’s Opencontroller Architecture is built around.
If your organization has moved past a handful of applications and now has agents accessing models through one or more gateways, the next challenge is visibility into the agents themselves, not just the traffic they generate. Lyzr’s Opencontroller provides a registry, identity, policy, evaluation, lifecycle, and audit layer for agents running across your existing infrastructure, regardless of which gateway or framework sits underneath. Book a Demo to see it yourself.
For a deeper look at production-ready gateway governance, the Agents to Production playbook covers how access control decisions at the gateway layer connect to the broader work of getting agents live and accountable.
Frequently asked questions
Virtual keys in an LLM gateway are credentials issued by the gateway itself, rather than by a model provider, that applications use to authenticate requests. The gateway validates the key, applies its attached policy, and forwards the request using the real provider credential, which the calling application never sees directly.
Virtual keys work through a create, configure, authenticate, and enforce cycle. An administrator creates a key, attaches budgets and model or provider permissions to it, the application authenticates with that key, and the gateway validates and enforces policy before routing the request upstream.
Provider API keys grant broad, unscoped access and are difficult to revoke individually once shared across services. Virtual keys let a gateway apply per-application budgets, rate limits, and model restrictions, and revoke a single key without affecting any other application.
Yes. Model allowlists attached to a virtual key determine exactly which models a given key can call, so an application can be limited to lower-cost models or blocked from specific providers entirely.
Yes. Most gateway implementations, including Bifrost rate limiting, attach requests-per-minute and tokens-per-minute limits directly to each virtual key, preventing a single application or agent from consuming shared provider capacity.
Yes. Because every request carries a virtual key identifier, the gateway can attribute cost and token consumption to a specific application, team, or project, and enforce a spending cap before that cost gets out of hand.
Virtual keys narrow the impact of a leaked credential and keep provider secrets out of application code, but they are not a complete security boundary on their own. Their effectiveness still depends on how well the gateway itself handles storage, rotation, and permission enforcement.
Bifrost is an open-source LLM gateway built in Go that uses virtual keys to apply controls such as budgets, rate limits, model restrictions, and MCP tool filtering. It is one example of how gateways can implement virtual-key-based access control.
A provider API key is issued directly by a model vendor and grants unscoped access to that provider’s models. A virtual key is issued by the gateway, sits in front of the provider key, and carries its own budget, rate limit, and access policy that the gateway enforces before any request reaches the provider.
Book A Demo: Click Here
Join our Slack: Click Here
Link to our GitHub: Click Here

