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/active-directory/fundamentals/how-to-approve-support-access-requests.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,11 @@ When you have a pending support access request, you can view and approve that re
46
46
47
47
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com/) and navigate to **Diagnose and solve problems**.
48
48
49
-
1. Select the link from the banner message at the top of the page...
49
+
1. Select the link from the banner message at the top of the page.
50
50
51
51

52
52
53
-
... or scroll to the bottom of the page and select **Manage pending requests** from the **Microsoft Support Access Requests** section.
53
+
Or scroll to the bottom of the page and select **Manage pending requests** from the **Microsoft Support Access Requests** section.
54
54
55
55
:::image type="content" source="media/how-to-approve-support-access-requests/diagnose-solve-problems-access-requests.png" alt-text="Screenshot of the Diagnose and solve problems page with the Manage pending requests link highlighted." lightbox="media/how-to-approve-support-access-requests/diagnose-solve-problems-access-requests-expanded.png":::
Copy file name to clipboardExpand all lines: articles/ai-services/document-intelligence/how-to-guides/includes/v3-0/javascript-sdk.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ ms.custom: devx-track-csharp
28
28
29
29
* The latest version of [Visual Studio Code](https://code.visualstudio.com/) or your preferred IDE. For more information, *see*[Node.js in Visual Studio Code](https://code.visualstudio.com/docs/nodejs/nodejs-tutorial)
30
30
31
-
* The latest LTS version of [Node.js](https://nodejs.org/about/releases/)
31
+
* The latest LTS version of [Node.js](https://nodejs.org/)
32
32
33
33
* An Azure AI services or Document Intelligence resource. Once you have your Azure subscription, create a [single-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesFormRecognizer) or [multi-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesAllInOne) Document Intelligence resource, in the Azure portal, to get your key and endpoint. You can use the free pricing tier (`F0`) to try the service, and upgrade later to a paid tier for production.
Copy file name to clipboardExpand all lines: articles/ai-services/document-intelligence/quickstarts/includes/get-started/javascript.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ In this quickstart, you use the following APIs to extract structured data from f
25
25
26
26
* The latest version of [Visual Studio Code](https://code.visualstudio.com/) or your preferred IDE.
27
27
28
-
* The latest LTS version of [Node.js](https://nodejs.org/about/releases/)
28
+
* The latest LTS version of [Node.js](https://nodejs.org/)
29
29
30
30
* An Azure AI services or Document Intelligence resource. Once you have your Azure subscription, create a [single-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesFormRecognizer) or [multi-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesAllInOne) Document Intelligence resource in the Azure portal to get your key and endpoint. You can use the free pricing tier (`F0`) to try the service, and upgrade later to a paid tier for production.
Copy file name to clipboardExpand all lines: articles/ai-services/document-intelligence/quickstarts/includes/v3-javascript-sdk.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ In this quickstart you'll, use the following features to analyze and extract dat
28
28
29
29
* The latest version of [Visual Studio Code](https://code.visualstudio.com/) or your preferred IDE. For more information, *see*[Node.js in Visual Studio Code](https://code.visualstudio.com/docs/nodejs/nodejs-tutorial)
30
30
31
-
* The latest LTS version of [Node.js](https://nodejs.org/about/releases/)
31
+
* The latest LTS version of [Node.js](https://nodejs.org/)
32
32
33
33
* An Azure AI services or Document Intelligence resource. Once you have your Azure subscription, create a [single-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesFormRecognizer) or [multi-service](https://portal.azure.com/#create/Microsoft.CognitiveServicesAllInOne) Document Intelligence resource, in the Azure portal, to get your key and endpoint. You can use the free pricing tier (`F0`) to try the service, and upgrade later to a paid tier for production.
title: 'Quickstart: Use the OpenAI Service image generation REST APIs'
2
+
title: 'Quickstart: Generate images with the Python SDK for Azure OpenAI Service'
3
3
titleSuffix: Azure OpenAI Service
4
-
description: Walkthrough on how to get started with Azure OpenAI image generation using the REST API.
4
+
description: Learn how to generate images with Azure OpenAI Service by using the Python SDK and the endpoint and access keys for your Azure OpenAI resource.
5
5
services: cognitive-services
6
6
manager: nitinme
7
7
ms.service: cognitive-services
8
8
ms.subservice: openai
9
9
ms.topic: include
10
-
ms.date: 06/04/2023
10
+
ms.date: 08/08/2023
11
11
keywords:
12
12
---
13
13
14
-
Use this guide to get started calling the image generation APIs using the Python SDK.
14
+
Use this guide to get started calling the Azure OpenAI Service image generation APIs by using the Python SDK.
15
15
16
16
> [!NOTE]
17
-
> The image generation API creates an image from a text prompt. It does not edit existing images or create variations.
17
+
> The image generation API creates an image from a text prompt. It doesn't edit existing images or create variations.
18
18
19
19
## Prerequisites
20
20
21
-
- An Azure subscription - <ahref="https://azure.microsoft.com/free/cognitive-services"target="_blank">Create one for free</a>
22
-
- Access granted to DALL-E in the desired Azure subscription
23
-
Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at <ahref="https://aka.ms/oai/access"target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue.
24
-
- <ahref="https://www.python.org/"target="_blank">Python 3.7.1 or later version</a>
25
-
- The following Python libraries: os, requests, json
26
-
- An Azure OpenAI resource created in the East US region. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
21
+
- An Azure subscription. <ahref="https://azure.microsoft.com/free/ai-services"target="_blank">Create one for free</a>.
22
+
- Access granted to DALL-E in the desired Azure subscription.
23
+
- <ahref="https://www.python.org/"target="_blank">Python 3.7.1 or later version</a>.
24
+
- The following Python libraries: `os`, `requests`, `json`.
25
+
- An Azure OpenAI resource created in the East US region. For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
26
+
27
+
> [!NOTE]
28
+
> Currently, you must submit an application to access Azure OpenAI Service. To apply for access, complete [this form](https://aka.ms/oai/access). If you need assistance, open an issue on this repo to contact Microsoft.
27
29
28
30
## Retrieve key and endpoint
29
31
30
-
To successfully make a call against Azure OpenAI, you'll need the following:
32
+
To successfully call the Azure OpenAI APIs, you need the following information about your Azure OpenAI resource:
33
+
34
+
| Variable | Name | Value |
35
+
|---|---|---|
36
+
|**Endpoint**|`api_base`| The endpoint value is located under **Keys and Endpoint** for your resource in the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** > **Playground** > **Code View**. An example endpoint is: `https://docs-test-001.openai.azure.com/`. |
37
+
|**Key**|`api_key`| The key value is also located under **Keys and Endpoint** for your resource in the Azure portal. Azure generates two keys for your resource. You can use either value. |
31
38
32
-
|Variable name | Value |
33
-
|--------------------------|-------------|
34
-
|`ENDPOINT`| This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in **Azure OpenAI Studio** > **Playground** > **Code View**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
35
-
|`API-KEY`| This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`.|
39
+
Go to your resource in the Azure portal. On the navigation pane, select **Keys and Endpoint** under **Resource Management**. Copy the **Endpoint** value and an access key value. You can use either the **KEY 1** or **KEY 2** value. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
36
40
37
-
Go to your resource in the Azure portal. The **Endpoint and Keys** can be found in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
41
+
:::image type="content" source="../media/quickstarts/endpoint.png" alt-text="Screenshot that shows the Keys and Endpoint page for an Azure OpenAI resource in the Azure portal." lightbox="../media/quickstarts/endpoint.png":::
38
42
39
43
## Install the Python SDK
40
44
41
-
Open the command prompt and navigate to your project folder. Install the OpenAI Python SDK using the following command:
45
+
Open a command prompt and browse to your project folder. Install the OpenAI Python SDK by using the following command:
42
46
43
47
```bash
44
48
pip install openai
45
49
```
50
+
46
51
Install the following libraries as well:
47
52
48
53
```bash
@@ -52,75 +57,76 @@ pip install pillow
52
57
53
58
## Create a new Python application
54
59
55
-
Create a new Python file called quickstart.py. Then open it in your preferred editor or IDE.
60
+
Create a new Python file named _quickstart.py_. Open the new file in your preferred editor or IDE.
56
61
57
-
1. Replace the contents of quickstart.py with the following code. Enter your endpoint URL and key in the appropriate fields.
62
+
1. Replace the contents of _quickstart.py_ with the following code. Enter your endpoint URL and key in the appropriate fields. Change the value of `prompt` to your preferred text.
58
63
59
64
```python
60
65
import openai
61
66
import os
62
67
import requests
63
68
fromPILimport Image
64
69
65
-
openai.api_base ='<your_openai_endpoint>'# Add your endpoint here
66
-
openai.api_key ='<your_openai_key>'# Add your api key here
70
+
openai.api_base ='<your_endpoint>'# Enter your endpoint here
71
+
openai.api_key ='<your_key>'# Enter your API key here
67
72
68
-
#At the moment Dall-E is only supported by the 2023-06-01-preview API version
73
+
#Assign the API version (DALL-E is currently supported for the 2023-06-01-preview API version only)
69
74
openai.api_version ='2023-06-01-preview'
70
-
71
75
openai.api_type ='azure'
72
76
73
-
# Create an image using the image generation API
77
+
# Create an image by using the image generation API
74
78
generation_response = openai.Image.create(
75
-
prompt='A painting of a dog',
79
+
prompt='A painting of a dog',# Enter your prompt text here
76
80
size='1024x1024',
77
81
n=2
78
82
)
79
83
80
-
# Set the directory where we'll store the image
84
+
# Set the directory for the stored image
81
85
image_dir = os.path.join(os.curdir, 'images')
86
+
82
87
# If the directory doesn't exist, create it
83
88
ifnot os.path.isdir(image_dir):
84
89
os.mkdir(image_dir)
85
90
86
-
#With the directory in place, we can initialize the image path (note that filetype should be png)
91
+
#Initialize the image path (note the filetype should be png)
image_url = generation_response["data"][0]["url"] # extract image URL from response
91
96
generated_image = requests.get(image_url).content # download the image
92
97
withopen(image_path, "wb") as image_file:
93
98
image_file.write(generated_image)
94
99
95
100
# Display the image in the default image viewer
96
-
display(Image.open(image_path))
101
+
image = Image.open(image_path)
102
+
image.show()
97
103
```
98
104
99
105
> [!IMPORTANT]
100
-
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials. For example, [Azure Key Vault](../../../key-vault/general/overview.md).
106
+
> 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](../../../key-vault/general/overview.md).
101
107
102
108
1. Run the application with the `python` command:
103
109
104
110
```console
105
111
python quickstart.py
106
112
```
107
113
108
-
The script will loop until the generated image is ready.
114
+
The script loops until the generated image is ready.
109
115
110
116
## Output
111
117
112
-
The output image will be downloaded to _generated_image.png_ at your specified location. The script will also display the image in your default image viewer.
118
+
Azure OpenAI stores the output image in the _generated_image.png_ fileinyour specified directory. The script also displays the image in your default image viewer.
113
119
114
-
The image generation APIs come with a content moderation filter. If the service recognizes your prompt as harmful content, it won't return a generated image. For more information, see the [content filter](../concepts/content-filter.md) article.
120
+
The image generation APIs come with a content moderation filter. If the service recognizes your prompt as harmful content, it doesn't generate an image. For more information, see [Content filtering](../concepts/content-filter.md).
115
121
116
122
## Clean up resources
117
123
118
-
If you want to clean up and remove an OpenAI resource, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
124
+
If you want to clean up and remove an Azure OpenAI resource, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
0 commit comments