Register a cloud-managed public key for use with OpenAI
Register an RSA-3072 asymmetric key pair from your cloud provider for use with OpenAI.
Your private key stays in AWS KMS, Azure Key Vault, or Google Cloud KMS. OpenAI stores a copy of the corresponding public key at registration.
Registering a key doesn’t configure product features or storage. This guide
covers keys for PSP
decryption.
Before you start
Have your organization ID. Use the same organization for cloud trust, registration, and API access.
Create an organization Admin API key with external-key read/write access. Load it securely as OPENAI_ADMIN_KEY; project inference keys won’t work.
Have permission to create an enabled RSA-3072 key and grant OpenAI the scoped public-key read access described in this guide.
Restrict private-key use to authorized users and retain old key versions while records depend on them.
Set up a cloud key
Follow the steps for your provider before registering the key. Each setup uses RSA-3072 and grants OpenAI only public-key and metadata reads.
1. Create an RSA key
Open KMS > Customer managed keys > Create key and choose your region. Use these settings:
Key type: Asymmetric
Key usage: Encrypt and decrypt
Key spec:RSA_3072
Finish creating the key with your own key administrators. Keep it enabled and copy its full ARN, ending in key/<CUSTOMER_KMS_KEY_ID>. Don’t use an alias ARN.
2. Create a public-key read policy
Open IAM > Policies > Create policy > JSON. Replace <CUSTOMER_KMS_KEY_ARN> and save this policy as OpenAI-PublicKeyRead.
Attach OpenAI-PublicKeyRead and create the role. Copy its ARN. Use the same organization ID as external_id when registering the key.
4. Check the KMS key policy
Confirm that the key policy authorizes the role. If it doesn’t delegate authorization to IAM, add this statement. Replace <CUSTOMER_ROLE_ARN> and preserve existing administrator access.
In this KMS key policy, "Resource": "*" applies only to the key the policy is attached to. The IAM policy uses the exact key ARN.
Ask a tenant administrator to add EKM - OpenAI Azure to your tenant. Its application ID is 20a14814-5ab7-4612-a671-1382b412bf93.
Install Azure CLI, then sign in and check for the application:
123az login --tenant '<CUSTOMER_TENANT_ID>'az ad sp show --id '20a14814-5ab7-4612-a671-1382b412bf93' \ --query '{name:displayName,objectId:id}' -o table
If the application is missing, add it:
az ad sp create --id '20a14814-5ab7-4612-a671-1382b412bf93' \ --query '{name:displayName,objectId:id}' -o table
Save the tenant-local object ID for the role assignment.
2. Create the key
Open Key vaults > Create. Select your subscription, resource group, vault name, and region. Under Access configuration, choose Azure role-based access control.
Your administrator needs a role that permits key creation, such as Key Vault Crypto Officer on this vault. Don’t grant that role to OpenAI.
In the vault, open Objects > Keys > Generate/Import and use:
Name:<OPENAI_ORG_ID>--asymmetric-key, using your OpenAI organization ID
Key type: RSA
RSA key size: 3072
Enabled: Yes
If you set activation or expiration dates, make sure the key is currently valid. Include Decrypt in the key’s permitted operations. OpenAI receives key-read access only.
RSA-HSM keys in a Key Vault are also supported. Standalone Managed HSM endpoints aren’t supported.
3. Grant key-read access
Create a custom role with the key-read DataAction. Save this as public-key-reader.json and replace the subscription and resource-group values.
123456789101112{ "Name": "OpenAI Public Key Reader", "IsCustom": true, "Description": "Read key metadata and public keys.", "Actions": [], "NotActions": [], "DataActions": ["Microsoft.KeyVault/vaults/keys/read"], "NotDataActions": [], "AssignableScopes": [ "/subscriptions/<CUSTOMER_SUBSCRIPTION_ID>/resourceGroups/<CUSTOMER_RESOURCE_GROUP>" ]}
Set VAULT_RESOURCE_ID to the vault’s Azure resource ID from Properties, not its HTTPS URI. Set OPENAI_SP_ID to the application’s tenant-local object ID, then assign the role on the key:
123456789101112az role definition create --role-definition @public-key-reader.jsonOPENAI_SP_ID='<CUSTOMER_OPENAI_SP_OBJECT_ID>'VAULT_RESOURCE_ID='<CUSTOMER_VAULT_RESOURCE_ID>'KEY_NAME='<OPENAI_ORG_ID>--asymmetric-key'KEY_SCOPE="$VAULT_RESOURCE_ID/keys/$KEY_NAME"az role assignment create \ --assignee-object-id "$OPENAI_SP_ID" \ --assignee-principal-type ServicePrincipal \ --role 'OpenAI Public Key Reader' \ --scope "$KEY_SCOPE"
For a vault using legacy access policies, grant key Get instead. Keep its existing permission model.
4. Record the exact version
Record your tenant ID, vault URI, and key name. Open the enabled key version and copy the 32-character hexadecimal version from the end of its Key Identifier.
1. Prepare the project and key
Enable Cloud KMS in the key project and IAM and Security Token Service in the federation project. If these projects differ, enable Cloud KMS in both.
Record your federation project’s 12-digit project number. The KMS project may be different.
Open Security > Key Management. Create a key ring, then create a key with:
Protection level: Software
Purpose: Asymmetric decrypt
Algorithm: 3072 bit RSA - OAEP Padding - SHA256 Digest
Copy the KMS project ID, location, key ring, key name, and enabled version. Use a specific version such as "1", not "latest" or "0". Asymmetric keys don’t have a primary version.
2. Configure workload identity federation
Open IAM & Admin > Workload Identity Federation. Create a global pool, such as openai-keys, and an OIDC provider, such as openai-google, with these settings:
Provider setting
Value
Issuer URL
https://accounts.google.com
Allowed audience
Your exact OpenAI organization ID
Attribute mapping
google.subject = assertion.sub
Attribute condition
assertion.sub == '105900137572174660365'
Use your OpenAI organization ID as the audience. Keep the issuer and OpenAI subject unchanged.
3. Create and assign the key-reader role
In IAM & Admin > Roles, create a custom role in the KMS project with:
Both permissions are required; public-key-viewer alone is insufficient. No decrypt, sign, or service-account impersonation grant is needed.
On the key’s Permissions tab, choose Grant access. Assign the role to this principal, replacing <CUSTOMER_GCP_PROJECT_NUMBER> and <CUSTOMER_GCP_POOL_ID>:
Use your pool’s project number and scope the grant to this key. Key-level IAM covers its versions. Save the pool and provider IDs, organization audience, and KMS identifiers for registration.
Register your key
The examples use curl and a Bash-compatible shell. Load OPENAI_ADMIN_KEY securely, then set your organization ID:
123456API_BASE="https://api.openai.com/v1"ORG_ID="<OPENAI_ORG_ID>": "${OPENAI_ADMIN_KEY:?Load your organization admin key securely}"KEYS_URL="$API_BASE/organization/external_keys"
Prepare the registration request
The purpose enum accepts ekm (the default) or psp_decryption. Use psp_decryption for the asymmetric keys in this guide; ekm is for Enterprise Key Management (EKM).
Save your provider’s request as registration.json. Replace the example values; JSON doesn’t expand shell variables.
GET returns stored details. POST /validate rechecks current access and key validity against the saved public key. It doesn’t decrypt records or refresh the snapshot.
Registrations are fixed snapshots; cloud rotation doesn’t update them. Keep old private keys for records that depend on them. Changing the selection doesn’t migrate existing records.
Delete a key
Clear or replace the selection on every active project before deleting the registration: