You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/dall-e-python.md
+81-3Lines changed: 81 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Use this guide to get started generating images with the Azure OpenAI SDK for Py
19
19
- An Azure subscription. <ahref="https://azure.microsoft.com/free/ai-services"target="_blank">Create one for free</a>.
20
20
- <ahref="https://www.python.org/"target="_blank">Python 3.8 or later version</a>.
21
21
- An Azure OpenAI resource created in a compatible region. See [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability).
22
-
- Then, you need to deploy a `dalle3` model with your Azure resource. For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
22
+
- Then, you need to deploy a `gpt-image-1` model or `dalle3` model with your Azure resource. For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
23
23
24
24
## Setup
25
25
@@ -53,12 +53,89 @@ pip install requests
53
53
pip install pillow
54
54
```
55
55
56
-
## Generate images with DALL-E
56
+
## Generate images
57
57
58
58
Create a new python file, _quickstart.py_. Open it in your preferred editor or IDE.
59
59
60
+
#### [GPT-image-1](#tab/gpt-image-1)
61
+
60
62
Replace the contents of _quickstart.py_ with the following code.
61
63
64
+
```python
65
+
import os
66
+
import requests
67
+
import base64
68
+
fromPILimport Image
69
+
from io import BytesIO
70
+
71
+
# You will need to set these environment variables or edit the following values.
1. Enter your endpoint URL and key in the appropriate fields.
105
181
1. Change the value of `prompt` to your preferred text.
106
182
1. Change the value of `model` to the name of your deployed DALL-E 3 model.
107
183
184
+
---
185
+
108
186
> [!IMPORTANT]
109
187
> Remember to remove the key from your code when you're done, and never post your key publicly. For production, use a secure way of storing and accessing your credentials. For more information, see [Azure Key Vault](/azure/key-vault/general/overview).
0 commit comments