.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:
process.env for any values starting with credential: and replaces them with the decrypted values from config/credentials.yml.enc. By the time your first workflow runs, ANTHROPIC_API_KEY contains the real key — no code changes needed.
This resolution is triggered by the output.hookFiles entry in your package.json:
package.json
hookFiles mechanism.
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:
| Scope | Environment Variable | Key File |
|---|---|---|
| Global | OUTPUT_CREDENTIALS_KEY | config/credentials.key |
| Environment | OUTPUT_CREDENTIALS_KEY_PRODUCTION | config/credentials/production.key |
| Workflow | OUTPUT_CREDENTIALS_KEY_PAYMENT_PROCESSING | src/workflows/payment_processing/credentials.key |
Docker
Pass the 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:@outputai/credentials package documentation.