---
title: "What is a virtual key in an AI gateway?"
description: "A virtual key is a gateway-issued API key that stands in for provider keys and carries its own budget, rate limits, and model access. How virtual keys work."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/virtual-key"
markdown_url: "https://theaiengineering.com/glossary/virtual-key.md"
topic: "AI gateways and LLM routing"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-11"
keywords: ["Virtual key","virtual API key","gateway-issued key"]
citation: "The AI Engineering Editors. \"What is a virtual key in an AI gateway?\" The AI Engineering, updated Nov 11, 2026. https://theaiengineering.com/glossary/virtual-key"
---

# What is a virtual key in an AI gateway?

Also called virtual API key, gateway-issued key.

> **Definition of Virtual key:** A virtual key is an API key issued by an AI gateway that maps a caller to its allowed models, budget, and rate limits, while the gateway keeps the real provider credentials.

A virtual key is a credential that an [AI gateway](https://theaiengineering.com/glossary/ai-gateway) issues to an application, team, or user in place of a model provider's API key. The caller sends the virtual key with each request, and the gateway looks up the policy attached to it, adds the real provider credential, and forwards the call. Provider keys stay in one place, and each caller gets its own budget, [rate limits](https://theaiengineering.com/glossary/rate-limiting), and model access, which the gateway can change or revoke without touching the provider account.

## How virtual keys work

Virtual keys work as a policy lookup on every request. The gateway authenticates the key, checks that it is active and unexpired, confirms the requested model is allowed, checks the remaining budget and rate limits, and then selects a provider deployment and its credential. Usage and cost are recorded against the key, which produces spend reports per team or customer.

Gateway documentation describes similar fields:

- [Bifrost](https://docs.getbifrost.ai/features/governance/virtual-keys) calls virtual keys its primary governance entity. Provider access is deny-by-default, a key can be restricted to specific provider API keys, budgets and rate limits on tokens and requests apply per key, and a key can belong to a team or a customer. Clients send it in an `x-bf-vk` header or in a provider-style authorization header.
- [LiteLLM](https://docs.litellm.ai/docs/proxy/virtual_keys) creates keys through a `/key/generate` endpoint, with an allowed `models` list, model aliases, `max_budget` and `budget_duration`, `rpm_limit` and `tpm_limit`, a team or user owner, an expiry, and metadata. Key management requires a Postgres database. Provider credentials sit on the model entries in the proxy configuration, not on the key, and keys can also grant access to MCP servers.

The term is not fully standard across products. [Portkey](https://portkey.ai/docs/product/ai-gateway/virtual-keys) used "virtual key" for a securely stored provider credential and has since migrated the feature to its Model Catalog. Check what a product means by the term before comparing feature lists.

## Virtual key vs provider API key

A provider API key authenticates an organization to one model provider and draws on that organization's shared limits and billing. A virtual key authenticates one caller to the gateway and carries policy for that caller only. A leaked provider key exposes the account's whole quota; a leaked virtual key exposes one budget that the gateway can cap and revoke.

| | Provider API key | Virtual key |
|---|---|---|
| Issued by | Model provider | AI gateway |
| Grants access to | One provider's API | Models the gateway exposes, often across providers |
| Limits and budget | The organization's tier and spend limits | Set per key, team, or customer |
| Effect of revoking | Breaks every application using it | Cuts off one caller |
| Held by | The gateway | Each application, team, or user |

Concentrating provider keys in the gateway makes the gateway a high-value target, so keep those keys in a secret manager and restrict who can create virtual keys. Per-caller keys also make gateway logs attributable, so [LLM observability](https://theaiengineering.com/glossary/llm-observability) dashboards can break down tokens, latency, and cost by team or customer. The same pattern extends to agent tool traffic through an [MCP gateway](https://theaiengineering.com/glossary/mcp-gateway). [What is an AI gateway](https://theaiengineering.com/articles/what-is-an-ai-gateway) shows where key checks sit in the request path.

## Related terms

- [AI gateway](https://theaiengineering.com/glossary/ai-gateway): An AI gateway is a proxy layer between applications and model providers that exposes one API for many models and centralizes routing, failover, access control, cost tracking, caching, and logging.
- [Rate limiting](https://theaiengineering.com/glossary/rate-limiting): Rate limiting is the enforcement of a maximum number of requests or tokens a client may send to an API within a time window, with excess requests rejected, usually with HTTP 429.
- [LLM routing](https://theaiengineering.com/glossary/llm-routing): LLM routing is the practice of directing each request to one of several language models or providers, based on rules or a learned classifier, to balance cost, quality, latency, and availability.
- [LLM observability](https://theaiengineering.com/glossary/llm-observability): LLM observability is the practice of instrumenting LLM applications to record each request's prompts, responses, tool calls, token usage, latency, cost, and quality scores as traces that teams can search and analyze.
- [MCP gateway](https://theaiengineering.com/glossary/mcp-gateway): An MCP gateway is a proxy that sits between MCP hosts and many MCP servers, exposing them through one endpoint and centralizing authentication, tool access policy, and audit logging.

## Guides that cover virtual key

- [What is an AI gateway? How it works and when you need one](https://theaiengineering.com/articles/what-is-an-ai-gateway): An AI gateway is a proxy between your apps and model providers. Learn how it works, its core features, AI gateway vs API gateway, and open source options.
- [Bifrost vs LiteLLM: architecture, features, and performance compared](https://theaiengineering.com/articles/bifrost-vs-litellm): Bifrost vs LiteLLM compared: a Go single binary against a Python proxy, with deployment, routing, virtual keys, caching, MCP, benchmarks, and migration.
- [Semantic caching for LLMs: how it works and when it pays off](https://theaiengineering.com/articles/semantic-caching): Semantic caching returns a stored LLM response for prompts with similar meaning. Learn how a semantic cache works, how to tune it, and what never to cache.

Part of the [AI gateways and LLM routing](https://theaiengineering.com/topics/ai-gateways) topic hub.

## Cite this definition

The AI Engineering Editors. "What is a virtual key in an AI gateway?" The AI Engineering, updated Nov 11, 2026. https://theaiengineering.com/glossary/virtual-key

- Title: What is a virtual key in an AI gateway?
- Author: The AI Engineering Editors
- Publisher: The AI Engineering
- Updated: 2026-11-11
- URL: https://theaiengineering.com/glossary/virtual-key
- Markdown: https://theaiengineering.com/glossary/virtual-key.md
