secret() fetches the raw value of a key from the vault. It is the safety net for cases the proxy cannot (yet) route. As long as a provider works with configure(), always prefer it: with configure() the key never touches your process.
When to use it
configure() covers providers with a simple auth header (Authorization: Bearer …, x-api-key). secret() takes over for the rest:
Compound auth
Twilio (
Basic base64(SID:token)) and any two-value scheme the proxy cannot assemble.Custom header
Azure OpenAI (
api-key:), Token … schemes, or any non-standard auth header.SDK without baseURL
A client that exposes neither
baseURL nor a custom fetch — impossible to route through the proxy.One-off non-HTTP secret
A value used directly in-process, outside of an HTTP call.
The tradeoff
You give up zero-knowledge for that key. But it still beats a
.env: centralized, rotatable, encrypted at rest, audited fetch, and held in memory for 5 minutes max then wiped — instead of a .env present in the whole process for its entire lifetime.
Rule:
configure() by default. secret() only when the proxy cannot inject the key.Parameters
Returns
Promise<string> — the raw key value.