Overview
By default, requests through Layer use Layer’s platform keys. With BYOK (Bring Your Own Keys), you can provide your own provider API keys. Requests are then billed directly to your provider account. Why use BYOK?- Bypass platform rate limits — Use your own quota
- Direct billing — Charges appear on your provider account
- Compliance — Some organizations require direct provider relationships
- Control — Maintain your own API key lifecycle
Supported Providers
| Provider | Key Format | Validation Method |
|---|---|---|
| OpenAI | sk-proj-... | Lists models (free operation) |
| Anthropic | sk-ant-... | Minimal message request |
AIza... | Minimal content generation | |
| Mistral | API key | Lists models (free operation) |
Adding a Provider Key
From the Dashboard
- Go to Dashboard → Provider Keys
- Find the provider you want to configure
- Enter your API key in the input field
- Click Test to validate the key against the provider’s API
- Click Save
sk-proj-...abc123).
Key Management
- One key per provider — Each provider can have one active key
- Enable/Disable — Toggle a key without deleting it
- Test Connection — Validate your key works at any time
- Delete — Soft-deleted (recoverable for 90 days, then permanently removed)
How Keys Are Used
When you make a request through Layer:- Layer checks if you have an active BYOK key for the target provider
- If yes → your key is decrypted and used for the provider API call
- If no → Layer’s platform key is used as a fallback
Security
Encryption
All provider keys are encrypted using AES-256-GCM — the same standard used by AWS KMS, Google Cloud KMS, and 1Password.- Fresh IV generated for every encryption operation
- Auth tag detects any tampering with stored data
- Master key stored separately from the database as an environment variable
What Layer Stores
| Data | Storage |
|---|---|
| Full API key | Encrypted (AES-256-GCM) |
| Key prefix | Plaintext (for display, e.g., sk-proj-...abc) |
| Provider name | Plaintext |
| Active status | Plaintext |
Trust Model
Layer’s BYOK uses platform-controlled encryption, which is the industry standard for API proxies. Your keys are encrypted at rest but decrypted server-side when making provider API calls on your behalf — the same model used by Stripe, Vercel, and similar platforms.Cost Tracking
When BYOK is active, the actual provider charges appear on your provider account. Layer still tracks estimated costs in the dashboard for analytics and spending limit enforcement, but these are calculated from token counts and published pricing — your actual provider bill may vary slightly.Fallback Behavior
If your BYOK key becomes invalid (expired, revoked, rate-limited):- Layer detects the authentication error
- The key is marked as invalid in the dashboard
- Requests fall back to Layer’s platform key (if available)
- You’re notified to update your key