gpt-3.5-turbo-instruct
, you are probably looking for this page instead.openai
Python package makes it easy to use both OpenAI and Azure OpenAI. You can call Azure OpenAI the same way you call OpenAI with the exceptions noted below.
openai
package to use Azure OpenAI using environment variables. The following is for bash
:
az login
to log in.
Add a role an Azure role assignment Cognitive Services OpenAI User
scoped to your Azure OpenAI resource. This will allow you to get a token from AAD to use with Azure OpenAI. You can grant this role assignment to a user, group, service principal, or managed identity. For more information about Azure OpenAI RBAC roles see here.
To use AAD in Python with LangChain, install the azure-identity
package. Then, set OPENAI_API_TYPE
to azure_ad
. Next, use the DefaultAzureCredential
class to get a token from AAD by calling get_token
as shown below. Finally, set the OPENAI_API_KEY
environment variable to the token value.
DefaultAzureCredential
class is an easy way to get started with AAD authentication. You can also customize the credential chain if necessary. In the example shown below, we first try Managed Identity, then fall back to the Azure CLI. This is useful if you are running your code in Azure, but want to develop locally.
AzureChatOpenAI
class. For docs on Azure chat see Azure Chat OpenAI documentation.
Let’s say your deployment name is gpt-35-turbo-instruct-prod
. In the openai
Python API, you can specify this deployment with the engine
parameter. For example: