Skip to content

Commit 5687b57

Browse files
Copilotpamelafox
andcommitted
Migrate AzureOpenAI constructor to OpenAI client
Co-authored-by: pamelafox <297042+pamelafox@users.noreply.github.com>
1 parent 485ee92 commit 5687b57

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎example.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
credential = azure.identity.DefaultAzureCredential()
1919
token_provider = azure.identity.get_bearer_token_provider(credential, "https://cognitiveservices.azure.com/.default")
2020

21-
client = openai.AzureOpenAI(
22-
api_version="2024-03-01-preview",
23-
azure_endpoint=f"https://{os.getenv('AZURE_OPENAI_SERVICE')}.openai.azure.com",
24-
azure_ad_token_provider=token_provider,
21+
client = openai.OpenAI(
22+
base_url=f"https://{os.getenv('AZURE_OPENAI_SERVICE')}.openai.azure.com",
23+
api_key=token_provider,
2524
)
2625

2726
response = client.chat.completions.create(

‎requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
azure-identity
2-
openai
2+
openai>=1.108.1
33
python-dotenv

0 commit comments

Comments
 (0)