Switching from OpenAI to Azure OpenAI is easy and straightforward. Below are the steps you need to follow.
Get Access to Azure OpenAI
Create an Azure OpenAI Endpoints
(For a more comprehensive list of available regions for different models, you can refer to the documentation which provides information on base model regions and fine-tuning regions for various models.)
Create OpenAI Service Resources: Create resources for each region selected.
Deploy a GPT Model Using an Azure OpenAI Studio. After creating the resource, you need to deploy a model:
Configure/Update Your Python code:
For switching between OpenAI and Azure OpenAI Service endpoints, you need to make slight changes to your code. Update the authentication, model keyword argument, and other differences (Python examples below).
Authentication
Use environment variables for API keys and endpoints. For OpenAI, set openai.api_key and openai.organization. For Azure OpenAI, set openai.api_type, openai.api_key, openai.api_base, and openai.api_version.
Here is an example of how to set up authentication for OpenAI and Azure OpenAI:
# OpenAI
import openai
openai.api_key = "sk-..."
openai.organization = "..."
# Azure OpenAI
import openai
openai.api_type = "azure"
openai.api_key = "..."
openai.api_base = "https://example-endpoint.openai.azure.com"
openai.api_version = "2023-05-15" #subject to change
Keyword Argument for Model: OpenAI uses the model keyword argument, while Azure OpenAI uses deployment_id or engine interchangeably. Use the custom deployment name you chose for your model during deployment.
Here is an example of how to use the keyword argument for model:
# OpenAI
completion = openai.Completion.create(prompt="<prompt>", model="text-davinci-003")
# Azure OpenAI
completion = openai.Completion.create(prompt="<prompt>", deployment_id="text-davinci-003")
Azure OpenAI Embeddings Multiple Input Support: OpenAI currently allows a larger number of array inputs with text-embedding-ada-002. Azure OpenAI currently supports input arrays up to 16 for text-embedding-ada-002 Version 2.
Azure OpenAI Samples on GitHub
Handle Connectivity Errors: If a single connectivity issue occurs, retry the request. If errors persist, redirect traffic to a backup resource in the region you have created.
Monitor the Azure OpenAI Usage: You can monitor the Azure OpenAI resource for their availability, performance, and operation using Azure Monitor.
The dashboards are grouped into four categories: HTTP Requests, Tokens-Based Usage, PTU Utilization, and Fine-tuning
These are the sample dashboards that you can view on the Azure monitor for Azure OpenAI services.
Benefits of using Azure OpenAI Service
The Azure OpenAI Service offers several benefits concerning data, privacy, and security.
Data Privacy and Exclusivity
Data Processing and Storage
Content Control and Abuse Prevention
Customization and Fine-Tuning
Exemption from Abuse Monitoring and Human Review
Verification of Data Storage Settings
Refer here for more additional details of Data, privacy, and security for Azure OpenAI Service
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.