Skip to content

Commit 67592b8

Browse files
Merge pull request #4224 from mrbullwinkle/mrb_04_18_2025_stream
[Azure OpenAI] Updates
2 parents 4808b8c + 5dc450b commit 67592b8

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to use Azure OpenAI's advanced o3-mini, o1, & o1-mini rea
55
manager: nitinme
66
ms.service: azure-ai-openai
77
ms.topic: include
8-
ms.date: 04/16/2025
8+
ms.date: 04/18/2025
99
author: mrbullwinkle
1010
ms.author: mbullwin
1111
---
@@ -91,7 +91,7 @@ token_provider = get_bearer_token_provider(
9191
client = AzureOpenAI(
9292
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
9393
azure_ad_token_provider=token_provider,
94-
api_version="2024-12-01-preview"
94+
api_version="2025-03-01-preview"
9595
)
9696

9797
response = client.chat.completions.create(
@@ -121,7 +121,7 @@ from openai import AzureOpenAI
121121
client = AzureOpenAI(
122122
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
123123
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
124-
api_version="2024-12-01-preview"
124+
api_version="2025-03-01-preview"
125125
)
126126

127127
response = client.chat.completions.create(
@@ -298,7 +298,7 @@ token_provider = get_bearer_token_provider(
298298
client = AzureOpenAI(
299299
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
300300
azure_ad_token_provider=token_provider,
301-
api_version="2024-12-01-preview"
301+
api_version="2025-03-01-preview"
302302
)
303303

304304
response = client.chat.completions.create(
@@ -330,7 +330,7 @@ from openai import AzureOpenAI
330330
client = AzureOpenAI(
331331
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
332332
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
333-
api_version="2024-12-01-preview"
333+
api_version="2025-03-01-preview"
334334
)
335335

336336
response = client.chat.completions.create(
@@ -407,7 +407,7 @@ token_provider = get_bearer_token_provider(
407407
client = AzureOpenAI(
408408
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
409409
azure_ad_token_provider=token_provider,
410-
api_version="2025-04-01-preview"
410+
api_version="2025-04-01-preview" # You must use this version or greater to access reasoning summary
411411
)
412412

413413
response = client.responses.create(

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,35 @@ second_response = client.responses.create(
462462
print(second_response.model_dump_json(indent=2))
463463
```
464464

465+
## Streaming
466+
467+
```python
468+
from openai import AzureOpenAI
469+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
470+
471+
token_provider = get_bearer_token_provider(
472+
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
473+
)
474+
475+
client = AzureOpenAI(
476+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
477+
azure_ad_token_provider = token_provider,
478+
api_version = "2025-04-01-preview"
479+
)
480+
481+
response = client.responses.create(
482+
input = "This is a test",
483+
model = "o4-mini", # replace with model deployment name
484+
stream = True
485+
)
486+
487+
for event in response:
488+
if event.type == 'response.output_text.delta':
489+
print(event.delta, end='')
490+
491+
```
492+
493+
465494
## Function calling
466495

467496
The responses API supports function calling.
@@ -660,6 +689,10 @@ response = client.responses.create(
660689
print(response)
661690
```
662691

692+
## Reasoning models
693+
694+
For examples of how to use reasoning models with the responses API see the [reasoning models guide](./reasoning.md#reasoning-summary).
695+
663696
## Computer use
664697

665698
In this section, we provide a simple example script that integrates Azure OpenAI's `computer-use-preview` model with [Playwright](https://playwright.dev/) to automate basic browser interactions. Combining the model with [Playwright](https://playwright.dev/) allows the model to see the browser screen, make decisions, and perform actions like clicking, typing, and navigating websites. You should exercise caution when running this example code. This code is designed to be run locally but should only be executed in a test environment. Use a human to confirm decisions and don't give the model access to sensitive data.

0 commit comments

Comments
 (0)