BYOK (Bring Your Own Key)
Agentik Vault uses a Bring Your Own Key model where you maintain full custody of your API keys for AI providers (OpenAI, Anthropic, etc.).Your keys are encrypted at rest with AES-256-GCM and only decrypted inside your isolated instance.
Why BYOK?
Cost Control
You pay your AI provider directly. No markup or per-request fees from Agentik Vault.
Security
Keys never leave your control. They’re encrypted immediately upon upload and only decrypted in your instance.
Flexibility
Use any AI provider or service. Not locked into a specific vendor or pricing model.
Compliance
Meet regulatory requirements for key custody and data sovereignty.
Encryption Architecture
Encryption Details
- Algorithm: AES-256-GCM (Galois/Counter Mode)
- Key Size: 256 bits (32 bytes)
- IV Size: 96 bits (12 bytes, randomly generated per encryption)
- Auth Tag: 128 bits (16 bytes, for integrity verification)
- Master Key: Stored in
MASTER_KEY_ENCRYPTIONenv var (base64-encoded, 32 bytes)
Upload API Keys
Via Dashboard
- Navigate to Instances and select your instance
- Click Configure Keys
- Enter key name and value:
- Key name:
OPENAI_API_KEY - Key value:
sk-proj-...
- Key name:
- Click Add Key
- Repeat for other providers (Anthropic, etc.)
- Click Save — keys are encrypted immediately
Via API
Key Storage Format
Encrypted keys are stored inapi_keys_encrypted table:
Key Retrieval (Instance-Side)
Instances retrieve encrypted keys on startup:Keys are decrypted in-memory and never written to disk. They exist only in the instance’s RAM.
Key Rotation
Periodically rotate API keys for security:Manual Rotation
- Generate new API key from provider (OpenAI, Anthropic)
- Update key in Agentik Vault:
- Restart instance to load new key:
Automated Rotation (Enterprise)
Enterprise tier supports automated key rotation via webhooks:Delete Keys
Remove API keys from an instance:Security Best Practices
Use separate keys per instance
Use separate keys per instance
Don’t reuse the same API key across multiple instances. This limits blast radius if one instance is compromised.
Rotate keys regularly
Rotate keys regularly
Rotate keys every 90 days or when team members leave. Automate rotation for critical workloads.
Monitor key usage
Monitor key usage
Track API usage at your provider’s dashboard. Unusual spikes may indicate key compromise.
Never log raw keys
Never log raw keys
Backend and frontend never log plaintext keys. Only log key name + last 4 chars for debugging.
Protect master encryption key
Protect master encryption key
Store
MASTER_KEY_ENCRYPTION in secrets manager (AWS Secrets Manager, HashiCorp Vault). Never commit to Git.Audit Logging
All key operations are logged for audit:Plaintext key values are never logged. Only metadata (name, length, timestamp) for compliance.
Compliance & Regulations
Agentik Vault’s BYOK model helps meet regulatory requirements:- GDPR: You control data processing via your own API keys
- HIPAA: Encryption at rest + in transit (AES-256-GCM + TLS 1.3)
- SOC 2: Audit logs for all key operations
- PCI DSS: Key encryption meets Level 1 requirements
Troubleshooting
Keys not working in instance
Keys not working in instance
- Check key was uploaded successfully (status 200)
- Verify instance restarted after key update
- Check instance logs for decryption errors
- Ensure key format is correct (no extra spaces/newlines)
Encryption failed error
Encryption failed error
- Verify
MASTER_KEY_ENCRYPTIONis set correctly (32 bytes base64) - Check backend logs for crypto errors
- Ensure OpenSSL is available in backend environment
Cannot retrieve keys
Cannot retrieve keys
- Verify instance ID and secret are correct
- Check instance is in “running” state
- Ensure backend can connect to database
Next Steps
API Reference
Explore the complete API documentation for key management endpoints

