Short answer. BYOK means your organisation controls the key that protects data at rest, usually through a cloud KMS or HSM. The provider wraps and unwraps data keys through that service. It changes custody, not the need for access control, audit and rotation. Verify the key-wrap protocol, regions, operator access and failover behaviour in the current contract; do not treat the label as a certification.
Two meanings of BYOK
| Meaning | What you bring | What it controls | What it does not control |
|---|---|---|---|
| Gateway BYOK | Your own OpenAI, Anthropic or cloud key | Which upstream account pays and which quota applies | How the gateway stores prompts or logs |
| Encryption BYOK / CMEK | A key in your KMS or HSM | Who can unwrap the data-encryption keys | Application access, retention or model behaviour |
| HYOK | Key material held outside the provider | Provider cannot use the key without your service | Availability if your key service is down |
Most enterprise RFPs mean the second row. If a vendor answers “yes, BYOK” but cannot name the KMS, the key-wrap algorithm, the region and the audit events, the answer is not yet an architecture.
Key custody models
| Model | Who holds the KEK | Provider can read? | Operational cost |
|---|---|---|---|
| Provider-managed | Provider | Yes, under its controls | Lowest |
| CMEK / BYOK | Customer KMS, provider calls it | Only through your key policy | Medium; key policy and region drift |
| HYOK / external | Customer HSM or key service | No, unless your service releases the key | High; availability and latency |
| Client-side | Customer application | No; provider sees ciphertext | Highest; limited model features |
Plugsky documentation describes customer-managed keys through AWS KMS, GCP KMS, Azure Key Vault, HashiCorp Vault, Thales Luna and AWS CloudHSM. Treat that as a starting list, not a promise for every region or plan; verify integrations, key specs and failure behaviour in the contract.
Envelope encryption
Envelope encryption avoids sending data to the KMS. The service asks KMS for a data key, encrypts the payload, stores the ciphertext and wrapped key, then discards the plaintext key. To read, it sends the wrapped key back to KMS.
- Generate a data encryption key (DEK) through KMS.
- Encrypt the prompt, response or stored object with the DEK.
- Store the ciphertext and the KMS-wrapped DEK together.
- On read, ask KMS to unwrap the DEK, decrypt, and clear the plaintext key.
import boto3, base64
from cryptography.fernet import Fernet
kms = boto3.client("kms", region_name="me-central-1")
def encrypt(payload: bytes, key_id: str):
dek = kms.generate_data_key(KeyId=key_id, KeySpec="AES_256")
f = Fernet(base64.urlsafe_b64encode(dek["Plaintext"]))
return {
"ciphertext": f.encrypt(payload),
"wrapped_key": dek["CiphertextBlob"],
}
def decrypt(blob, key_id: str):
plaintext_key = kms.decrypt(
CiphertextBlob=blob["wrapped_key"], KeyId=key_id
)["Plaintext"]
f = Fernet(base64.urlsafe_b64encode(plaintext_key))
return f.decrypt(blob["ciphertext"])
A production implementation needs authenticated encryption, key caching, zeroisation and an audit event per unwrap. The KEK never leaves KMS in plaintext.
Rotation and multi-region keys
Rotation has two different jobs. Rotating the KEK changes the key that wraps DEKs; existing ciphertext is re-wrapped, not re-encrypted. Rotating a DEK requires re-encrypting the object.
| Key | Typical cadence | What changes | Impact |
|---|---|---|---|
| KEK / master key | Annual or per policy | New wrapping key; old DEKs re-wrapped | Low if the old key stays available for unwrap |
| DEK | Per object or per cryptoperiod | New data key; object re-encrypted | High for large corpora |
| API key | 90 days or on suspicion | New bearer token | Deploy and revoke; no data rewrite |
| Break-glass key | Quarterly test | Procedure, not routine rotation | Requires two-person approval |
Use one key per region and per environment. A key in me-central-1 should not be the only way to decrypt data in eu-west-1; a regional outage becomes a data outage. Replicate the key policy deliberately, and record which key ID protected which object. For per-provider keys, keep separate keys for separate upstream accounts so a revoked key does not take down every model.
Audit and failure modes
Log every key operation with actor, key ID, operation, resource, request ID, decision and source IP. Never log plaintext key material or the payload. Export the trail to your SIEM and keep it for the retention period your regulator or contract requires.
| Failure | Symptom | Mitigation |
|---|---|---|
| KMS outage | Unwrap calls fail; new reads stall | Cache DEKs within cryptoperiod; test break-glass |
| Key revoked | Every request fails immediately | Two-person change control; staged rotation |
| Wrong region | Key not found or latency spike | Region-scoped key map; failover test |
| Permission drift | Intermittent AccessDenied | Infrastructure as code; policy tests |
| Deleted key | Permanent data loss after waiting period | Deletion protection; 7–30 day wait; approval |
| Rotation race | Old ciphertext cannot be read | Keep old key for unwrap; version the key ID |
Test the failure mode, not the happy path. Disable the key in a staging account and measure what the application does. A BYOK design that has never lost its KMS has an untested single point of failure.
Migration and when BYOK is not worth it
- Inventory data stores, regions and retention periods.
- Choose the custody model and the KMS/HSM integration.
- Create keys, policies and break-glass procedures in staging.
- Backfill: encrypt existing objects with new DEKs; record key IDs.
- Cut over reads and writes; monitor unwrap latency and error rate.
- Keep the old keys available for the retention window, then retire them.
BYOK is not worth it when the data is public or low-sensitivity, when no contract or regulator requires customer-held keys, or when the team cannot operate a KMS, rotation and break-glass process. Provider-managed encryption with strong access controls is often better for a small team.
For the wider control set, read what BYOK means for AI and API keys, RBAC, SSO and audit logs. Enterprise deployment and contract terms are covered in the enterprise guide. Compliance note: BYOK does not by itself make a workload HIPAA-compliant, PCI-compliant or resident in a jurisdiction. A BAA, access review, retention terms and a security assessment are separate; verify the current terms in the contract with counsel review.
FAQ
What does BYOK mean for an AI API?
It usually means the customer controls the encryption key that protects data at rest, through a cloud KMS or HSM. It can also mean bringing your own model-provider API key to a gateway. They are different controls; name them separately.
Does BYOK mean the provider cannot read my data?
Not automatically. It depends on where encryption and decryption happen and whether the provider can call your KMS. Verify the key-wrap protocol, operator access and audit trail in the contract; do not infer zero access from the BYOK label.
How often should keys rotate?
Set a cryptoperiod that matches your policy and the provider's limits. Annual KEK rotation is common, with 90-day rotation for API keys and immediate rotation after exposure. Rotation should re-wrap data keys, not re-encrypt the entire corpus.
What happens if my KMS is unavailable?
New writes or reads that need the key fail unless you have cached data keys within their cryptoperiod or a documented break-glass path. Test the failure mode before production; a key-management outage is a data-availability incident.
Is BYOK required for HIPAA?
BYOK is not a substitute for a HIPAA compliance programme. A BAA, access controls, audit logs, retention terms and a security review are separate. Verify the current terms with counsel; this page is not a certification or legal opinion.
Sources
AWS KMS envelope encryption, checked 20 November 2026: docs.aws.amazon.com/kms. NIST SP 800-57 Part 1 Rev. 5, checked 20 November 2026: csrc.nist.gov. OWASP Secrets Management Cheat Sheet, checked 20 November 2026: cheatsheetseries.owasp.org.
Reviewed 20 November 2026. Key-management integrations and contract terms were checked against the Plugsky documentation on that date and are subject to change. This page is not legal, audit or certification advice. HIPAA, PCI, residency and key-custody claims require verification in the current contract and counsel review.