LiteLLM with HashiCorp Vault and cloud secret managers

Move LiteLLM provider API keys and virtual keys out of environment variables and into a secret store you control, with the access mode and team settings planned before go-live.

On this page

How LiteLLM connects to HashiCorp Vault and cloud secret managers

LiteLLM can read provider API keys from, and write LiteLLM virtual keys to, a managed secret store such as HashiCorp Vault, AWS Secret Manager or KMS, Azure Key Vault, Google Secret Manager or KMS, or CyberArk Conjur. This is an Enterprise feature. The open-source edition does not provide this integration, so a team that wants provider keys out of environment variables and config files needs an Enterprise license before the store connection is configured. The integration is set in the proxy configuration through key_management_system, which names the store, and store_virtual_keys, which controls whether generated virtual keys are written there. Two related settings shape the result: a prefix for stored virtual keys, which keeps gateway secrets separate from other entries in a shared store, and access_mode, which accepts read_only (the default), write_only or read_and_write. Confirm the access mode with the security team before go-live, because it decides whether the gateway can create secrets at all.

Even with a secret manager connected, the gateway still needs a PostgreSQL database for virtual keys, budgets, spend tracking and key metadata. The store holds the secret values, while the database holds the records that tie each key to a team, a budget and a model list. Plan for both, and treat the database credentials and LITELLM_MASTER_KEY as secrets in their own right. The LiteLLM documentation recommends keeping LITELLM_MASTER_KEY in a secret manager, so decide early which store holds it and who can read it. Team-level secret manager settings can also be defined, so that virtual keys created for a given team are written to that team's own configuration. Map your teams to stores and prefixes in a written design before you configure anything, and confirm each setting against the LiteLLM secret managers overview for the release you deploy.

What you need before connecting LiteLLM to a secret store

Connecting LiteLLM to a secret store touches licensing, the gateway's own data stores, the secret store itself and the network between them. Each item below is a decision or check to close before any configuration begins, so the cutover does not stall partway through.

Enterprise license for secret managers

Reading provider keys from and writing virtual keys to an external secret store is an Enterprise feature, not part of the open-source tier. Confirm with LiteLLM which Enterprise license covers your Vault, cloud or CyberArk integration before planning the build. Ask whether the license terms cover every environment you intend to run, including staging and disaster recovery.

Enterprise docs

Running proxy with PostgreSQL

Virtual keys need a PostgreSQL database, so the proxy must already run against one before any key is stored externally. Confirm the database is reachable, backed up and sized for the key and spend tables. Decide early whether the external store will hold only the key values while PostgreSQL keeps the key metadata, budgets and spend records.

Virtual keys docs

Redis 7.0 or newer

Once more than one proxy instance runs, shared rate limits, router state and cache depend on Redis. Confirm the Redis version in your environment is 7.0 or newer, and check it against the current LiteLLM production guidance before you deploy. Plan the Redis deployment so that instances behind a load balancer see the same state during a secret store change.

Production guide

Secret store account or namespace

Create a dedicated identity for the proxy in the secret store, such as an AppRole for Vault, a service role for AWS, a managed identity for Azure or a service account for Google. Scope it to the paths or secrets the proxy reads and writes, and confirm whether your Vault deployment needs an Enterprise namespace for login and secret operations. Keep the identity separate from human administrators.

Vault setup docs

Network paths from the proxy

The proxy must reach the secret store API and the store's authentication endpoint from every node that runs it. Map the firewall rules, DNS names, egress routes and any proxies between your Kubernetes cluster or VMs and the store. Test the path from a pod or host that matches production, because a path that works from a laptop often fails from a restricted subnet.

TLS certificates for Vault

If Vault authenticates the proxy with a TLS certificate, you need a client certificate and key that Vault trusts, plus the CA chain the proxy uses to verify the Vault server. Track who issues and renews the certificate, where the private key is stored and how rotation is rehearsed. Confirm the certificate auth method with LiteLLM and your Vault version before choosing it over AppRole.

Configuration sequence for a LiteLLM secret manager integration

This sequence moves provider API keys and LiteLLM virtual keys out of environment variables and into a secret store you control, with a check at each step so the team can confirm the gateway reads and writes the store as designed.

  1. Confirm the Enterprise license covers secret managers

    The client's platform owner and the LiteLLM account contact confirm that the license in place includes the secret manager integrations. Reading provider keys from, and writing virtual keys to, the supported stores is an Enterprise feature, so an open-source deployment cannot complete the rest of this sequence. Ask the vendor to confirm the license terms in writing for the exact stores in scope, including any cloud KMS option. The step is done when the license document names the integration you plan to use and the team has a copy on file.

  2. Create a least-privilege store identity

    The security team creates the identity the gateway uses to reach the store. For HashiCorp Vault, LiteLLM supports AppRole (the recommended method), TLS certificate or token authentication. Use an AppRole with read and write capability only on the paths the gateway needs, such as the provider key path and the virtual key prefix, and nothing else. If the deployment uses Vault Enterprise namespaces, set the namespace in the same configuration. The step is done when a login with the new AppRole succeeds from the gateway host and a read of a test path returns the expected value while a read outside the allowed paths is denied.

  3. Set key management and access mode in the proxy config

    The platform engineer adds the secret manager settings to the proxy configuration file. The main keys are key_management_system, store_virtual_keys, the prefix used for stored virtual keys and access_mode. The access_mode defaults to read_only, so set it deliberately: read_only if the gateway only needs provider keys, write_only or read_and_write if it must also store virtual keys. Keep the store address and credentials in environment or deployment secrets, not in the file. The step is done when the proxy starts cleanly and its startup log shows the configured secret manager without a connection error.

  4. Move LITELLM_MASTER_KEY into the secret manager

    The platform engineer removes LITELLM_MASTER_KEY from the container definition, Helm values or environment file and stores it in the secret manager, then injects it at runtime through the deployment's secret mechanism. LiteLLM documents that this key must start with sk-. Rotate the value as part of the move so the old copy in environment files, shell history and CI logs is no longer valid. The step is done when the deployment file contains no plaintext copy of the key, a restart succeeds, and an admin API call authenticated with the new key returns a successful response.

  5. Store a test provider key under the expected path

    The platform owner writes one non-production provider API key into the store at the path the proxy configuration expects. Use a key with a low spend limit at the provider, and label it as a test in the store's metadata. Then restart or reload the proxy and send one request to a model that uses that provider. The step is done when the store lists the secret at the expected path and the request succeeds, which shows the gateway read the key from the store rather than from an environment variable.

  6. Issue a test virtual key with storage enabled

    With store_virtual_keys enabled, the platform engineer creates a test virtual key through the proxy admin API or UI, tied to a test team with a small budget and a model restriction. Virtual keys require the PostgreSQL database. The step is done when the key authenticates a request and the secret store lists it under the configured prefix. Confirm that the stored value is the virtual key rather than a copy of the master key, and record the key ID so the team can match it to the store entry later.

  7. Check logs and confirm the read and write trail

    The operations engineer reviews the proxy log and the store's audit log for the test key and the test provider key. The proxy log should show successful secret reads at startup and on the test request, without the secret values appearing in the output. The store's audit trail should show the AppRole login and the write of the virtual key. Confirm the log retention in each system matches the team's policy before moving to production. The step is done when both logs show the expected entries and no secret value appears in either.

  8. Ask per-team settings and team owners to confirm

    Before production, the platform owner reviews team-level secret manager settings, which let each team use its own key management configuration when creating virtual keys tied to that team. Confirm with each team owner which store, path and prefix applies to them, and who may rotate their keys. Ask the vendor to confirm how team-level settings interact with the global configuration in the installed version. The step is done when every team in scope has a written mapping of store, path and owner, and the test keys have been removed from production configuration.

Choosing read_only, write_only or read_and_write access

Use read_only when the gateway only needs to fetch provider API keys and other static settings from the store. This is the default, so a deployment that never sets access_mode is already in this mode. The gateway retrieves secrets at startup or as configured, but it never creates, changes or deletes entries. Provider credentials are typically created and rotated by the security or platform team directly in the store, which keeps write access in a small group of administrators.

  • Narrow write permission: Only administrators of the store can create or rotate provider keys. The gateway's identity needs read permission on the specific paths or secret names it uses.
  • Clear rotation ownership: Whoever rotates a provider key updates the store and then confirms the gateway picks up the new value, which is a process to document in the runbook.
  • Lowest blast radius: A compromised gateway identity can read provider keys but cannot alter them or mint virtual keys in the store.
  • Virtual keys stay in the database: Keys issued by the proxy are not written back, so they remain under LiteLLM's own key management.
  • Review focus: The security team reviews the read policy, the path scoping and the list of secrets the gateway can read.

Before approving this mode, confirm the exact secret paths and the identity's policy with the team that owns the store.

Giving each team its own key management configuration

Team-level secret manager settings let each team bring its own key management configuration, and LiteLLM uses that configuration when it creates virtual keys tied to the team. The decision to make first is whether a team needs its own store at all. Separate stores or prefixes make sense when a team's provider keys or issued virtual keys must be isolated from other teams for audit, data residency or contractual reasons. A shared store with distinct prefixes for stored virtual keys can be enough when the main concern is naming and clean separation rather than access boundaries. Confirm in the LiteLLM secret managers documentation which settings apply at team level and which remain global, because that determines what you can actually vary per team.

For each team that gets its own configuration, the platform team has to prepare the target store before the gateway can use it. That means a secret path or namespace for the team, a Vault role or cloud identity with only the permissions the team's keys need, and a decision on the access_mode for that team (read only, write only or read and write). Keep in mind that virtual keys are written to the store, so the write permission should be limited to the prefix or path the team owns. Test one team end to end, creating a key, confirming it lands at the expected location and confirming another team's identity cannot read it, before you repeat the pattern for the next team. Write down the store, prefix and identity for each team in your configuration as code so the mapping can be reviewed.

Per-team secret settings only keep teams apart if administrators are also restricted in the gateway itself. Organization and team role-based access control is an Enterprise feature, so the isolation you design in the secret store is weaker if any user can change another team's key management configuration in the proxy. Confirm with the vendor which roles can edit team settings and whether the admin UI enforces the boundary you expect. Review the LiteLLM Enterprise documentation to match the team RBAC features against your separation model before you sign off on a multi-team design.

Mapping LiteLLM settings to Vault paths and cloud secret objects

This table maps each LiteLLM secret manager setting to the store object it touches, the naming pattern to confirm, who owns it, and the proxy setting that reads it. Use it as a checklist before you enable a store, and confirm every store-specific name against the LiteLLM Vault and secret manager docs for your version. The main takeaway is that the access mode decides which side of the store the proxy may touch.

SettingStore object or nameOwnerProxy setting that reads or writes it
key_management_systemStore type selected for the proxy, such as HashiCorp Vault, AWS Secret Manager, Azure Key Vault, Google Secret Manager or CyberArk ConjurPlatform team, with the security team approving the choicekey_management_system in the proxy secret manager settings
store_virtual_keysWhether generated virtual keys are written to the store at all (a flag, not a store object)Platform team, with sign-off from the security owner of the storestore_virtual_keys in the proxy secret manager settings
Virtual key prefixPath or name prefix applied to each stored virtual key, for example a Vault KV path or a secret name prefix (confirm exact format per store)Store administrator, who sets naming and access policyThe configured prefix for stored virtual keys
access_mode: read_only (default)Read access to provider API key secrets only; the proxy does not write new virtual keysPlatform team for the proxy identity, store team for policyaccess_mode set to read_only
access_mode: write_onlyWrite access for virtual keys; confirm whether the proxy also needs read permission to validate themStore administrator, who scopes the write policyaccess_mode set to write_only
access_mode: read_and_writeRead and write access to the same store, which widens what a compromised proxy identity can changeSecurity team approves; store administrator narrows the policyaccess_mode set to read_and_write
Team-level secret manager settingsPer-team key management configuration used when creating virtual keys tied to that team (confirm how each team path or store is named)Each team lead for their store reference, platform team for the configurationTeam-level secret manager block, applied when a virtual key is created for the team
HashiCorp Vault authenticationAppRole credentials (recommended), TLS certificate or token, plus a namespace on Vault Enterprise (confirm exact field names)Vault administrator issues and rotates the credentialVault auth settings in the proxy configuration, loaded from a secret manager or environment

Hardening the secret store connection

Connecting LiteLLM to a secret store moves the most sensitive values out of the environment, but the connection itself becomes the new trust boundary. The cards below cover how to authenticate the gateway, limit what it can read and write, protect the connection and keep the store auditable. Work through them together before the gateway handles production traffic.

Authenticate with AppRole

The LiteLLM Vault documentation recommends AppRole, with a TLS certificate or a token as alternatives. Use a role ID and a secret ID so the gateway logs in with credentials it can rotate without a code change. Ask your Vault team to set short token lifetimes so a leaked token expires quickly. Confirm the exact login settings with the LiteLLM Vault documentation before you configure them.

Vault docs

Scope policies to the paths LiteLLM uses

Write a Vault policy that grants read access only to the paths holding provider keys and the master key. LiteLLM only writes virtual keys when store_virtual_keys is enabled, so grant write permission only to the prefix used for stored virtual keys. Set access_mode to read_only unless writes are required. Review the policy whenever a team or model provider is added.

Keep the master key out of manifests

LITELLM_MASTER_KEY must start with sk- and it grants administrative access to the gateway. Store it in the secret manager and inject it at runtime, not in a plain Kubernetes manifest, Helm values file or Git repository. Confirm that your deployment tooling never prints it to logs or pipeline output. Restrict who can read that secret path separately from provider keys.

Limit write access to virtual keys

Because LiteLLM can write virtual keys to the store, a compromised gateway could create or overwrite stored credentials. Limit write permission to the virtual key prefix and deny writes to provider key paths. Use access_mode values deliberately, since read_and_write grants both directions on the configured paths. Test that a write to an unrelated path is denied.

Isolate teams with Vault namespaces

Vault Enterprise namespaces let LiteLLM log in and perform secret operations inside a defined boundary. Use separate namespaces, or separate paths, for teams that bring their own key management configuration. Confirm that each team's settings point only to that team's secrets. Namespace support requires Vault Enterprise, so confirm your Vault edition before design.

Encrypt every store connection

Every connection between the gateway and the store should use TLS, including the Vault address, the cloud endpoint and any private endpoint. Confirm certificate validation is on and that the trusted certificate authority is the one your security team controls. Avoid disabling verification to get a test environment working, because that setting often survives into production.

Audit reads and writes on the store

Enable audit logging on the secret store and send entries to your SIEM. Look for logins by the LiteLLM role, reads of provider key paths, and writes under the virtual key prefix. Alert on unexpected source addresses or reads outside normal gateway startup. Confirm retention with the store owner, since audit records are only useful if they outlive the incident window.

Rotate provider keys and secret IDs

Plan rotation for three things: provider API keys, the AppRole secret ID and the master key. Rotate provider keys at the provider and update the store, then confirm the gateway reloads them. Rotate the secret ID on a schedule and after any suspected exposure, and document how the gateway picks up the new value. Test rotation in a staging environment before the first production run.

How the LiteLLM proxy reads and writes secrets through the store

The diagram starts with a caller sending a request to the LiteLLM proxy, which looks up the virtual key in PostgreSQL. The proxy then crosses a trust boundary to reach the chosen secret store, authenticating with AppRole, a TLS certificate or a token. It reads provider API keys from the store and, when store_virtual_keys is set, writes new virtual keys back to it. Check that the access mode matches what the proxy should do, and that the store and proxy sit in the network paths you expect.

Secret reads and virtual key writes cross the proxy-to-store trust boundary.

Common failures when LiteLLM cannot reach its secret store

This table pairs each common failure with its likely cause, the check to run and the fix when LiteLLM cannot read provider keys or write virtual keys to its secret store. Work down the rows in order, because authentication and namespace problems often hide the permission and prefix problems behind them. Confirm exact error text against the LiteLLM and Vault logs in your own environment before changing settings.

FailureLikely causeCheck and fix
AppRole login failsWrong role ID or secret ID, or the secret ID has expired or been used upConfirm the role ID and secret ID the proxy holds match the AppRole in Vault. Issue a new secret ID, store it in the proxy's own secret source, and restart the proxy so it logs in again.
Login works but namespace errors appear on Vault EnterpriseLiteLLM is using a namespace for login that differs from the one holding the secrets, or the namespace setting is missingConfirm the namespace used for AppRole login and the namespace used for secret reads are the ones your Vault administrator set up. Correct the namespace setting in the LiteLLM configuration and test one read.
Provider keys cannot be readThe Vault policy attached to the AppRole does not grant read on the provider key path, or the path in config is wrongCompare the configured secret path with the path in the policy. Add read capability for that path to the policy only, then retry a single provider key read before restarting the gateway.
Virtual keys do not appear under the prefixstore_virtual_keys is off, the access_mode is read_only, or the configured prefix differs from the path the team checksConfirm store_virtual_keys is enabled and access_mode allows writes (write_only or read_and_write). Create one test virtual key, then list the secret path using the same prefix the gateway uses.
Write fails while reads succeedThe policy grants read but not create or update on the virtual key pathAdd create and update capabilities scoped to the virtual key prefix. Keep delete off unless your team has confirmed what LiteLLM removes when keys are deleted.
TLS certificate errorsVault uses a certificate from an internal CA that the proxy host does not trust, or the certificate name does not match the address in configInstall the internal CA certificate in the proxy's trust store or point the configuration at it, and confirm the address matches a name on the certificate. Do not disable verification to get past the error.
Team-specific settings are not appliedTeam secret manager settings were not saved, the virtual key was created before the team setting existed, or the team uses a different key management configuration than expectedCheck the team record for its key management configuration, then create a new virtual key for that team. Keys issued before the change keep the settings they were created with.
Gateway works after restart but fails laterThe Vault token or AppRole session expired, or a secret ID was single useReview token lifetime and secret ID usage limits with your Vault administrator. Plan rotation and confirm the proxy re-authenticates without a manual restart.

Questions buyers ask before connecting LiteLLM to a secret store

Does the open-source edition of LiteLLM support secret manager integration?

No, the secret manager integrations with HashiCorp Vault, AWS, Azure, Google and CyberArk are listed as an Enterprise feature, so the open-source edition does not give you this out of the box. The open-source edition still runs with keys supplied as environment variables or in your own deployment configuration, which is the setup you would be moving away from. Confirm the current edition boundary in the LiteLLM Enterprise documentation and with LiteLLM before you plan the rollout, because packaging can change between releases.

What does LiteLLM Enterprise add, and what does it cost?

Enterprise adds the secret manager integrations along with SSO and SCIM beyond the free limit, audit logs, team RBAC, IP allowlisting and team-level guardrails and logging. Pricing is not published on a list, so request a written license quote from LiteLLM that names the features, user counts and support terms you need. Ask whether the license covers each store you plan to connect, since CyberArk and cloud stores may be scoped differently in the order form. Support tiers, including optional 24/7 SLAs, are priced separately and should appear in the same quote.

How long does a HashiCorp Vault or cloud secret manager integration take?

The duration depends mainly on how many secret stores you connect, how many teams need their own key management configuration, and how many existing keys must move. A single shared store with one read-only path is a much smaller job than separate per-team stores with read and write access for virtual keys. Other drivers include Vault namespaces, network paths from the gateway to the store, approval cycles for AppRole credentials and the testing you need before cutover. Ask for a fixed-scope plan that lists each store, each team and each cutover step, and treat any single duration without that breakdown as unverified.

What must the security team provide for the integration?

The security team typically owns the decisions that set the boundaries of the integration. These include which secret stores are approved, which AppRole or certificate identities the gateway receives, which paths or secret prefixes each identity can read or write, and how access is reviewed. They also decide whether virtual keys may be written to a store at all, and which team gets its own key management settings. Expect to supply network routes from the gateway to the store, TLS trust material for Vault and the approval record for any token or certificate used. Document these before implementation so the gateway configuration matches the access model you approved.

Can our platform team connect LiteLLM to a secret store without outside help?

Often yes, if the team already runs Vault or a cloud secret manager, operates Kubernetes or a similar runtime, and has experience with the LiteLLM proxy configuration. The work that tends to need a second pair of hands is the access design: setting per-team secret manager settings, separating read-only and read-and-write roles, and proving that a revoked identity stops working. Teams new to these stores often underestimate the testing for failure modes such as expired AppRole secret IDs and unreachable stores. A written scope from a partner can help you decide which parts to keep in-house and which to hand over.

What happens to existing environment-variable keys during migration?

Existing provider keys can usually stay in place while you move them, but the migration should be planned as a sequence rather than a single switch. A common approach is to copy each provider key into the store, point the gateway at the store in read-only mode, verify requests route correctly and then remove the environment variables from the deployment and any container images or manifests. Virtual keys already issued need a decision on whether they are re-stored, and spend history and budgets stay in the PostgreSQL database rather than moving with the secret. Confirm the exact behavior for your LiteLLM version with the secret managers overview before you schedule the cutover.

What drives the cost of this work, and what should a quote include?

Cost is driven by the number of stores, the number of teams with their own settings, the amount of testing, the state of your existing deployment and the operations handover you need afterward. Some costs are one-time, such as design, configuration and cutover, while others recur, such as license renewals, support tiers and any retainer for upgrades. A quote should list who does each task, the stores and teams in scope, the environments covered, the test cases, the rollback steps and the deliverables such as configuration as code and a runbook. Ask for the exclusions in writing, including who pays for store licenses and cloud charges, so the quote can be compared with an internal estimate.

How DeployOpen scopes the LiteLLM secret manager integration

DeployOpen scopes this work as a fixed-scope engagement with a written agreement before any configuration starts. The scope starts with the store decision: which of the supported stores (HashiCorp Vault, AWS Secret Manager or KMS, Azure Key Vault, Google Secret Manager or KMS, or CyberArk Conjur) holds provider keys, which holds virtual keys, and whether the same store serves both. The agreement then records the access mode for each store (read_only, write_only or read_and_write), the store_virtual_keys setting, the prefix used for stored virtual keys, and the per-team secret manager settings for every team that issues its own virtual keys. Each of these is written down as a named decision with an owner, so the security and platform teams review the same configuration the gateway will run.

Implementation happens in your cloud accounts, data centers or Vault clusters, with DeployOpen working under access you grant. For Vault, that means setting up the AppRole login (the recommended method), or the TLS certificate or token method if your standards require one, and confirming any Vault Enterprise namespace the gateway must use. The test plan covers reading a provider key, writing a virtual key, denying writes in read-only mode, revoking a team's access, and what happens when the store is unreachable. Confirm with your store owners which of these operations the gateway may perform, since permissions in the store, not the gateway setting alone, decide what can be written or deleted.

After handover, the same written scope covers retesting, for example after a LiteLLM upgrade, a change in store policy or a new team, and it can move into an ongoing retainer for continuing support and testing. Ask any partner to show how retests are recorded and which configuration changes trigger one. DeployOpen does not issue audit reports or certifications for this configuration; if an assessor needs evidence, the scope should list the configuration exports and test records you will hand over.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.