Keys / Azure OpenAI
AZURE_OPENAI_API_KEY
One of the two keys of your Azure OpenAI resource. Your app sends it to call models deployed on that resource.
- Expires
- the docs don't say
- API
- list and regenerate, with the Azure management API
Get it
Create one on portal.azure.com. The steps aren't recorded yet.
Set it
AZURE_OPENAI_API_KEY=...
The OpenAI Python and Node.js SDKs read it in their AzureOpenAI clients when you don't pass a key. In Python, AZURE_OPENAI_AD_TOKEN wins if both are set. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- Move every app to key 1, so key 2 is unused. Regenerating a key stops the old value at once.
- On the resource's Keys and Endpoint page in the Azure portal, click Regenerate Key 2, then deploy the new key 2.
- Check that every app uses key 2, then regenerate key 1 the same way.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.
Sources, checked 2026-11-16
- Azure OpenAI: Quickstart
- Azure AI services: Rotate API keys
- Azure AI services: Authentication
- Cognitive Services REST API: Regenerate key
- Cognitive Services REST API: List keys
- openai-python: reads AZURE_OPENAI_API_KEY
- openai-node: reads AZURE_OPENAI_API_KEY
- GitHub secret scanning: supported patterns