Vault SecretRefs
The bundled Vault plugin lets OpenClaw resolveexec SecretRefs from
HashiCorp Vault at Gateway startup and reload time. OpenClaw stores Vault
references in config, keeps resolved values in the in-memory secrets snapshot,
and does not write the resolved API keys back to openclaw.json.
Use this when you already run Vault or want model provider keys to live outside
OpenClaw config files. For the SecretRef runtime model, see
Secrets management.
Before you begin
You need:- OpenClaw with the bundled
vaultplugin available - a reachable Vault server
- Vault auth that can produce a client token with read access to the secret paths OpenClaw should resolve
- the environment that starts the Gateway must include
VAULT_ADDRand eitherVAULT_TOKEN,OPENCLAW_VAULT_AUTH_METHOD=token_filewithVAULT_TOKEN_FILE, or a configured JWT/Kubernetes login
openclaw vault commands:
Store a provider key in Vault
OpenClaw defaults to KV v2 mounted atsecret, matching Vault dev-server
examples. For production Vault, set OPENCLAW_VAULT_KV_MOUNT to your actual KV
mount path before creating SecretRef ids. With the OpenClaw defaults, this
SecretRef id:
Make Vault visible to the Gateway
For an uncontainerized local Gateway, export Vault settings in the same shell that starts OpenClaw. The default auth method reads a Vault client token fromVAULT_TOKEN:
jwt:
kubernetes. This is intended for
Gateways running as Pods; the default mount is kubernetes, and the default JWT
file is the standard service account token path:
OPENCLAW_VAULT_AUTH_MOUNT only when Vault mounted Kubernetes auth somewhere
other than auth/kubernetes. Set OPENCLAW_VAULT_JWT_FILE only when the service
account token is projected at a custom path.
Optional settings:
openclaw vault status never prints VAULT_TOKEN; it reports only whether the
token, token file, and JWT file are set.
Generate and apply a SecretRef plan
Create a plan that maps OpenRouter’s model provider API key to Vault:--allow-exec because the Vault plugin resolves through an OpenClaw-managed
exec SecretRef provider.
If the Gateway is not running yet, start it normally after applying the plan
instead of running openclaw secrets reload.
Configure more provider keys
Built-in shortcuts:--provider-key:
--provider-key <provider=id> writes a SecretRef to
models.providers.<provider>.apiKey. For custom providers, it does not create
the provider’s baseUrl, api, or models settings; configure those first.
Use --target <path=id> for any known SecretRef target path:
openclaw.json. Use
auth-profiles:<agentId>:<path> for existing auth-profiles.json targets.
The target path must be a registered OpenClaw SecretRef target. The setup
command does not create arbitrary named secrets in OpenClaw; Vault remains the
secret store, and OpenClaw stores SecretRefs only on supported config fields.
SecretRef id format
Vault SecretRef ids use this convention:
The returned Vault field must be a string.
For KV v1, set:
providers/openrouter/apiKey reads:
What OpenClaw stores
Applying a Vault setup plan stores a plugin-managed provider:Containers and managed deployments
Containerized Gateways still use the same plugin and SecretRef config. The container must receive:VAULT_ADDR- one auth source:
VAULT_TOKENOPENCLAW_VAULT_AUTH_METHOD=token_fileplusVAULT_TOKEN_FILEOPENCLAW_VAULT_AUTH_METHOD=jwtplusOPENCLAW_VAULT_AUTH_MOUNT,OPENCLAW_VAULT_AUTH_ROLE, andOPENCLAW_VAULT_JWT_FILEOPENCLAW_VAULT_AUTH_METHOD=kubernetesplusOPENCLAW_VAULT_AUTH_ROLE; optionally overrideOPENCLAW_VAULT_AUTH_MOUNTorOPENCLAW_VAULT_JWT_FILE
- optional
VAULT_NAMESPACE,OPENCLAW_VAULT_KV_MOUNT, andOPENCLAW_VAULT_KV_VERSION
OPENCLAW_VAULT_AUTH_METHOD=kubernetes
when Vault has Kubernetes auth configured for the cluster. Use
OPENCLAW_VAULT_AUTH_METHOD=jwt only when Vault is configured to treat the cluster
as a generic JWT/OIDC issuer. Either option is better than a long-lived Vault
token in a Kubernetes Secret. Vault Agent sidecar or injector deployments can
use token_file instead.
For multi-tenant Vault setups, keep tenant routing in Vault policy and
deployment config. OpenClaw does not require a fixed mount, role, or path: each
Gateway environment can set its own OPENCLAW_VAULT_KV_MOUNT,
OPENCLAW_VAULT_AUTH_ROLE, and SecretRef ids. If one shared Gateway must resolve
different Vault users at the same time, use manually configured exec providers
that wrap distinct auth environments, or split tenants across Gateway
environments with separate Vault env.