Skip to content

Commit 9e77d30

Browse files
committed
pivots
1 parent 3a31494 commit 9e77d30

File tree

7 files changed

+493
-344
lines changed

7 files changed

+493
-344
lines changed

articles/ai-services/openai/dall-e-quickstart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ zone_pivot_groups: openai-quickstart-dall-e
5454

5555
::: zone-end
5656

57+
::: zone pivot="programming-language-typescript"
58+
59+
[!INCLUDE [TypeScript SDK quickstart](includes/dall-e-typescript.md)]
60+
61+
::: zone-end
62+
5763
::: zone pivot="programming-language-go"
5864

5965
[!INCLUDE [Go SDK quickstart](includes/dall-e-go.md)]

articles/ai-services/openai/gpt-v-quickstart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Get started using GPT-4 Turbo with images with the Azure OpenAI Service.
4545

4646
::: zone-end
4747

48+
::: zone pivot="programming-language-typescript"
49+
50+
[!INCLUDE [TypeScript quickstart](includes/gpt-v-typescript.md)]
51+
52+
::: zone-end
53+
4854
::: zone pivot="programming-language-dotnet"
4955

5056
[!INCLUDE [.NET quickstart](includes/gpt-v-dotnet.md)]

articles/ai-services/openai/includes/dall-e-javascript.md

Lines changed: 2 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,13 @@ Use this guide to get started generating images with the Azure OpenAI SDK for Ja
1717

1818
## Prerequisites
1919

20-
#### [TypeScript](#tab/typescript)
2120

2221
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
2322
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
24-
- [TypeScript](https://www.typescriptlang.org/download/)
2523
- [Azure CLI](/cli/azure/install-azure-cli) used for passwordless authentication in a local development environment, create the necessary context by signing in with the Azure CLI.
2624
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
2725

2826

29-
#### [JavaScript](#tab/javascript)
30-
31-
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services?azure-portal=true)
32-
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
33-
- [Azure CLI](/cli/azure/install-azure-cli) used for passwordless authentication in a local development environment, create the necessary context by signing in with the Azure CLI.
34-
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
35-
36-
---
37-
3827
## Setup
3928

4029
[!INCLUDE [get-key-endpoint](get-key-endpoint.md)]
@@ -64,72 +53,9 @@ Your app's _package.json_ file will be updated with the dependencies.
6453

6554
Create a new file named _ImageGeneration.js_ and open it in your preferred code editor. Copy the following code into the _ImageGeneration.js_ file:
6655

67-
#### [TypeScript (Microsoft Entra ID)](#tab/typescript-keyless)
68-
69-
```typescript
70-
import { AzureOpenAI } from "openai";
71-
import {
72-
DefaultAzureCredential,
73-
getBearerTokenProvider
74-
} from "@azure/identity";
75-
76-
// You will need to set these environment variables or edit the following values
77-
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
78-
79-
// Required Azure OpenAI deployment name and API version
80-
const apiVersion = "2024-07-01";
81-
const deploymentName = "dall-e-3";
82-
83-
// keyless authentication
84-
const credential = new DefaultAzureCredential();
85-
const scope = "https://cognitiveservices.azure.com/.default";
86-
const azureADTokenProvider = getBearerTokenProvider(credential, scope);
87-
88-
function getClient(): AzureOpenAI {
89-
return new AzureOpenAI({
90-
endpoint,
91-
azureADTokenProvider,
92-
apiVersion,
93-
deployment: deploymentName,
94-
});
95-
}
96-
async function main() {
97-
console.log("== Image Generation ==");
98-
99-
const client = getClient();
100-
101-
const results = await client.images.generate({
102-
prompt,
103-
size: "1024x1024",
104-
n: numberOfImagesToGenerate,
105-
model: "",
106-
style: "vivid", // or "natural"
107-
});
108-
109-
for (const image of results.data) {
110-
console.log(`Image generation result URL: ${image.url}`);
111-
}
112-
}
113-
114-
main().catch((err) => {
115-
console.error("The sample encountered an error:", err);
116-
});
117-
```
11856

119-
1. Build the application with the following command:
12057

121-
```console
122-
tsc
123-
```
124-
125-
1. Run the application with the following command:
126-
127-
```console
128-
node ImageGeneration.js
129-
```
130-
131-
132-
#### [JavaScript (Microsoft Entra ID)](#tab/javascript-keyless)
58+
#### [Microsoft Entra ID](#tab/javascript-keyless)
13359

13460
```javascript
13561
const { AzureOpenAI } = require("openai");
@@ -192,68 +118,8 @@ node ImageGeneration.js
192118
```
193119

194120

195-
#### [TypeScript (API key)](#tab/typescript-key)
196-
197-
```typescript
198-
import { AzureOpenAI } from "openai";
199-
200-
// You will need to set these environment variables or edit the following values
201-
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
202-
const apiKey = process.env["AZURE_OPENAI_API_KEY"];
203-
204-
// Required Azure OpenAI deployment name and API version
205-
const apiVersion = "2024-07-01";
206-
const deploymentName = "dall-e-3";
207-
208-
// The prompt to generate images from
209-
const prompt = "a monkey eating a banana";
210-
const numberOfImagesToGenerate = 1;
211-
212-
function getClient(): AzureOpenAI {
213-
return new AzureOpenAI({
214-
endpoint,
215-
apiKey,
216-
apiVersion,
217-
deployment: deploymentName,
218-
});
219-
}
220-
async function main() {
221-
console.log("== Image Generation ==");
222-
223-
const client = getClient();
224-
225-
const results = await client.images.generate({
226-
prompt,
227-
size: "1024x1024",
228-
n: numberOfImagesToGenerate,
229-
model: "",
230-
style: "vivid", // or "natural"
231-
});
232-
233-
for (const image of results.data) {
234-
console.log(`Image generation result URL: ${image.url}`);
235-
}
236-
}
237-
238-
main().catch((err) => {
239-
console.error("The sample encountered an error:", err);
240-
});
241-
```
242-
243-
1. Build the application with the following command:
244-
245-
```console
246-
tsc
247-
```
248-
249-
1. Run the application with the following command:
250-
251-
```console
252-
node ImageGeneration.js
253-
```
254-
255121

256-
#### [JavaScript (API key)](#tab/javascript-key)
122+
#### [API key](#tab/javascript-key)
257123

258124
```javascript
259125
const { AzureOpenAI } = require("openai");

0 commit comments

Comments
 (0)