Skip to content

Commit 6a73c51

Browse files
Merge pull request #7050 from mrbullwinkle/mrb_09_12_2025_update
[Azure OpenAI] [fix]
2 parents 40ca6ff + 1794e5a commit 6a73c51

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

articles/ai-foundry/openai/how-to/dall-e.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ The response from a successful image generation API call looks like the followin
153153
You can stream image generation requests to `gpt-image-1` by setting the `stream` parameter to `true`, and setting the `partial_images` parameter to a value between 0 and 3.
154154

155155
```python
156+
import base64
156157
from openai import OpenAI
157158
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
158159

@@ -163,7 +164,7 @@ token_provider = get_bearer_token_provider(
163164
client = OpenAI(
164165
base_url = "https://RESOURCE-NAME-HERE/openai/v1/",
165166
api_key=token_provider,
166-
default_headers={"x-ms-oai-image-generation-deployment":"gpt-image-1", "api_version":"preview"}
167+
default_headers={"api_version":"preview"}
167168
)
168169

169170
stream = client.images.generate(

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,18 +1271,17 @@ Use the Responses API if you want to build conversational image experiences with
12711271

12721272

12731273
```python
1274-
from openai import AzureOpenAI
1274+
from openai import OpenAI
12751275
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
12761276

12771277
token_provider = get_bearer_token_provider(
12781278
DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
12791279
)
12801280

1281-
client = AzureOpenAI(
1281+
client = OpenAI(
12821282
base_url = "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
1283-
azure_ad_token_provider=token_provider,
1284-
api_version="preview",
1285-
default_headers={"x-ms-oai-image-generation-deployment":"YOUR-GPT-IMAGE1-DEPLOYMENT-NAME"}
1283+
api_key=token_provider,
1284+
default_headers={"x-ms-oai-image-generation-deployment":"gpt-image-1", "api_version":"preview"}
12861285
)
12871286

12881287
response = client.responses.create(

0 commit comments

Comments
 (0)