When adding Azure Active Directory authentication (Security), make token acquisition and dependency responsibility explicit and align it with your SDK’s lifecycle.
azure.identity) and pass it into the request.api_type = "azure_ad" and provide the acquired credential token as api_key (used for request headers).Example (documented flow):
from azure.identity import DefaultAzureCredential
import openai
default_credential = DefaultAzureCredential()
# Acquire token for Azure Cognitive Services
token = default_credential.get_token("https://cognitiveservices.azure.com")
openai.api_type = "azure_ad"
openai.api_key = token.token
This keeps the authentication flow predictable (caller-owned, token-only passthrough) and reduces the risk of surprising security behavior or broken SDK integration.
Enter the URL of a public GitHub repository