.env files is risky, and coding agents shouldn’t see your secrets. The credentials system keeps these secrets encrypted at rest in your repository as YAML files that you commit alongside your code — no external vault subscription needed. At runtime, a single encryption key decrypts everything. Each workflow can have its own scoped credentials that override shared defaults, giving you both team-wide consistency and per-workflow flexibility.
You manage credentials through the CLI and read them in your steps with a simple dot-notation API.
Setting Up Credentials
Initialize credentials for your project:config/credentials.key— your 256-bit encryption key (never commit this)config/credentials.yml.enc— the encrypted YAML file (safe to commit)
$EDITOR, and re-encrypts when you save. Fill in your secrets:
credentials.require() throws a MissingCredentialError if the path doesn’t exist. Use credentials.get(path, defaultValue) when you want a safe fallback instead:
Wiring LLM Keys to Environment Variables
LLM SDKs like the Anthropic and OpenAI clients read their API keys from environment variables. Rather than duplicating these keys in both your.env file and your encrypted credentials, you can wire credentials directly into environment variables using the credential: prefix.
In your .env file, set the variable to credential:<dot.path> instead of the actual key:
credential:<path> is replaced with the value at that path in the global credentials for the current environment: config/credentials/<NODE_ENV>.yml.enc when it exists, otherwise config/credentials.yml.enc. Workflow-scoped credentials are not used for env vars. By the time your first workflow runs, ANTHROPIC_API_KEY contains the real key — no code changes needed.
The worker logs confirmation on startup:
ANTHROPIC_API_KEY is already set in the shell or injected by your CI/CD pipeline, the credential reference is ignored. This gives you a safe override path for production deployments without touching files.
Scoping Credentials to Environments
You likely need different API keys for development and production. The credentials system supports environment-specific files that sit alongside the global defaults:config/credentials/ directory with per-environment files:
NODE_ENV and loads the matching environment file. Only "production" and "development" are recognized — other values fall back to the global file.
Edit environment-specific credentials the same way:
Scoping Credentials to Workflows
Sometimes a single workflow needs its own secrets — a dedicated API key with different permissions, or a third-party token that only one workflow uses. You can scope credentials to a specific workflow:payment_processing):
credentials.get() sees inside the workflow:
--environment and --workflow are mutually exclusive flags. Environment scoping applies at the global level; workflow scoping applies per-workflow.Deploying to Production
In local development, the.key files on disk handle decryption. In production, CI/CD, and Docker — where you don’t have key files — set the decryption key as an environment variable.
The system resolves keys with a fallback chain:
The resolution order is: environment variable first, then key file. Workflow keys fall back to the global key if neither a workflow-specific env var nor a key file is found.
Docker
The encrypted credentials file must be present in the image — the key alone isn’t enough. Make sure your Dockerfile includes:config/ directory is not cleaned up after the build because the encrypted file is read at runtime, not build time.
Pass the decryption key as an environment variable in your Docker Compose or container config:
CI/CD
Store the key in your CI provider’s secrets and expose it as an environment variable:Key Management
Never commit key files
Add this to your.gitignore:
.yml.enc files are safe to commit — they can’t be decrypted without the key.
Sharing keys with your team
Key files are created with0o600 permissions (owner read/write only). Share keys with teammates through a secure channel — a password manager, encrypted messaging, or your organization’s secret sharing tool. Each developer needs the key file at the expected path, or the matching environment variable set.
Rotating keys
To rotate a key:- Decrypt your current credentials:
output credentials show > /tmp/creds.yml - Re-initialize with
--forceto generate a new key:output credentials init --force - Edit and paste your secrets back:
output credentials edit - Distribute the new key to your team and update environment variables in production
- Securely delete the temporary file:
rm /tmp/creds.yml
Verifying credentials
Use the CLI to check that credentials are correctly set up:Custom Providers
The default provider reads encrypted YAML files from disk. You can replace it with a custom provider for alternative backends (e.g., AWS Secrets Manager, HashiCorp Vault) usingsetProvider():
setProvider() in a hook file listed under outputai.hookFiles. Hook files load before the worker resolves credential: env vars, so those resolve through your provider too.
Returning
null from loadForWorkflow means the workflow has no overrides, so global credentials are used as-is.
Security
Credentials are encrypted with AES-256-GCM using the@noble/ciphers library. Each encryption uses a fresh random nonce, so the same plaintext produces different ciphertext every time.
- Key files are created with file mode
0o600(owner read/write only). - During
output credentials edit, the temporary plaintext file is overwritten with null bytes before it is deleted.
API Reference
credentials
path is a dot-notation path into the decrypted YAML, e.g. 'anthropic.api_key'. Inside a step, the workflow’s credentials are merged over the global ones. Credentials are decrypted once per scope and cached for the life of the process.
Errors
All four errors extendFatalError, so a step that throws one fails without being retried.
For complete TypeScript API documentation, see the Credentials Module API Reference.