# The API version you want to use: set this to `2023-12-01-preview` for the released version.export OPENAI_API_VERSION=2023-12-01-preview# The base URL for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource.export AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com# The API key for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource.export AZURE_OPENAI_API_KEY=<your Azure OpenAI API key>
import osfrom azure.identity import DefaultAzureCredential# Get the Azure Credentialcredential = DefaultAzureCredential()# Set the API type to `azure_ad`os.environ["OPENAI_API_TYPE"] = "azure_ad"# Set the API_KEY to the token from the Azure credentialos.environ["OPENAI_API_KEY"] = credential.get_token("https://cognitiveservices.azure.com/.default").token