Skip to content

Commit cd5960b

Browse files
Merge pull request #6779 from mrbullwinkle/mrb_08_26_2025_v1_010
[Release Branch] [Azure OpenAI] v1 updates
2 parents dd9ae3c + dda8736 commit cd5960b

File tree

2 files changed

+57
-54
lines changed

2 files changed

+57
-54
lines changed

articles/ai-foundry/openai/how-to/reasoning.md

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -186,33 +186,39 @@ print(response.model_dump_json(indent=2))
186186
# [C#](#tab/csharp)
187187

188188
```c#
189-
using Azure.AI.OpenAI;
190-
using Azure.AI.OpenAI.Chat;
191189
using Azure.Identity;
190+
using OpenAI;
192191
using OpenAI.Chat;
192+
using System.ClientModel.Primitives;
193193

194-
AzureOpenAIClient openAIClient = new(
195-
new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/"),
196-
new DefaultAzureCredential());
197-
ChatClient chatClient = openAIClient.GetChatClient("o3-mini"); //model deployment name
194+
#pragma warning disable OPENAI001 //currently required for token based authentication
195+
196+
BearerTokenPolicy tokenPolicy = new(
197+
new DefaultAzureCredential(),
198+
"https://cognitiveservices.azure.com/.default");
199+
200+
ChatClient client = new(
201+
model: "o4-mini",
202+
authenticationPolicy: tokenPolicy,
203+
options: new OpenAIClientOptions()
204+
{
205+
206+
Endpoint = new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1")
207+
}
208+
);
198209

199210
ChatCompletionOptions options = new ChatCompletionOptions
200211
{
201212
MaxOutputTokenCount = 100000
202213
};
203214

204-
#pragma warning disable AOAI001 //currently required to use MaxOutputTokenCount
215+
ChatCompletion completion = client.CompleteChat(
216+
new DeveloperChatMessage("You are a helpful assistant"),
217+
new UserChatMessage("Tell me about the bitter lesson")
218+
);
205219

206-
options.SetNewMaxCompletionTokensPropertyEnabled(true);
220+
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
207221

208-
ChatCompletion completion = chatClient.CompleteChat(
209-
[
210-
211-
new UserChatMessage("Testing 1,2,3")
212-
],
213-
options); // Pass the options to the CompleteChat method
214-
215-
Console.WriteLine($"{completion.Role}: {completion.Content[0].Text}");
216222
```
217223

218224
---
@@ -395,34 +401,41 @@ print(response.model_dump_json(indent=2))
395401
# [C#](#tab/csharp)
396402

397403
```csharp
398-
using Azure.AI.OpenAI;
399-
using Azure.AI.OpenAI.Chat;
404+
400405
using Azure.Identity;
406+
using OpenAI;
401407
using OpenAI.Chat;
408+
using System.ClientModel.Primitives;
402409

403-
AzureOpenAIClient openAIClient = new(
404-
new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/"),
405-
new DefaultAzureCredential());
406-
ChatClient chatClient = openAIClient.GetChatClient("o3-mini"); //model deployment name
410+
#pragma warning disable OPENAI001 //currently required for token based authentication
411+
412+
BearerTokenPolicy tokenPolicy = new(
413+
new DefaultAzureCredential(),
414+
"https://cognitiveservices.azure.com/.default");
415+
416+
ChatClient client = new(
417+
model: "o4-mini",
418+
authenticationPolicy: tokenPolicy,
419+
options: new OpenAIClientOptions()
420+
{
421+
422+
Endpoint = new Uri("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1")
423+
}
424+
);
407425

408426
ChatCompletionOptions options = new ChatCompletionOptions
409427
{
410428
ReasoningEffortLevel = ChatReasoningEffortLevel.Low,
411429
MaxOutputTokenCount = 100000
412430
};
413431

414-
#pragma warning disable AOAI001 //currently required to use MaxOutputTokenCount
415-
416-
options.SetNewMaxCompletionTokensPropertyEnabled(true);
432+
ChatCompletion completion = client.CompleteChat(
433+
new DeveloperChatMessage("You are a helpful assistant"),
434+
new UserChatMessage("Tell me about the bitter lesson")
435+
);
417436

418-
ChatCompletion completion = chatClient.CompleteChat(
419-
[
420-
new DeveloperChatMessage("You are a helpful assistant."),
421-
new UserChatMessage("Testing 1,2,3")
422-
],
423-
options); // Pass the options to the CompleteChat method
437+
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
424438

425-
Console.WriteLine($"{completion.Role}: {completion.Content[0].Text}");
426439
```
427440

428441
---
@@ -443,17 +456,12 @@ pip install openai --upgrade
443456
```
444457

445458
```python
446-
from openai import AzureOpenAI
447-
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
448-
449-
token_provider = get_bearer_token_provider(
450-
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
451-
)
459+
import os
460+
from openai import OpenAI
452461

453-
client = AzureOpenAI(
454-
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
455-
azure_ad_token_provider=token_provider,
456-
api_version="preview"
462+
client = OpenAI(
463+
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
464+
api_key=os.getenv("AZURE_OPENAI_API_KEY")
457465
)
458466

459467
response = client.responses.create(
@@ -474,7 +482,7 @@ print(response.model_dump_json(indent=2))
474482
# [REST](#tab/REST)
475483

476484
```bash
477-
curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses?api-version=preview" \
485+
curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses" \
478486
-H "Content-Type: application/json" \
479487
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
480488
-d '{
@@ -589,17 +597,12 @@ GPT-5 series reasoning models have the ability to call a new `custom_tool` calle
589597
```
590598

591599
```python
592-
from openai import AzureOpenAI
593-
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
594-
595-
token_provider = get_bearer_token_provider(
596-
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
597-
)
600+
import os
601+
from openai import OpenAI
598602

599-
client = AzureOpenAI(
600-
base_url = "https://YOUR-RESOURCE-NAME-HERE.openai.azure.com/openai/v1/",
601-
azure_ad_token_provider=token_provider,
602-
api_version="preview"
603+
client = OpenAI(
604+
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
605+
api_key=os.getenv("AZURE_OPENAI_API_KEY")
603606
)
604607

605608
response = client.responses.create(

articles/ai-foundry/openai/how-to/responses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ curl https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses \
12631263
  }'
12641264
```
12651265

1266-
## Image generation
1266+
## Image generation (preview)
12671267

12681268
The Responses API enables image generation as part of conversations and multi-step workflows. It supports image inputs and outputs within context and includes built-in tools for generating and editing images.
12691269

0 commit comments

Comments
 (0)