@@ -45,54 +45,10 @@ For the initial v1 Generally Available (GA) API launch we're only supporting a s
45
45
46
46
# [ Python] ( #tab/python )
47
47
48
- ### Previous API
49
-
50
- ** API Key** :
51
-
52
- ``` python
53
- import os
54
- from openai import AzureOpenAI
55
-
56
- client = AzureOpenAI(
57
- api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
58
- api_version = " 2025-04-01-preview" ,
59
- azure_endpoint = " https://YOUR-RESOURCE-NAME.openai.azure.com" )
60
- )
61
-
62
- response = client.responses.create(
63
- model = " gpt-4.1-nano" , # Replace with your model deployment name
64
- input = " This is a test."
65
- )
66
-
67
- print (response.model_dump_json(indent = 2 ))
68
- ```
69
-
70
- ** Microsoft Entra ID** :
71
-
72
- ``` python
73
- from openai import AzureOpenAI
74
- from azure.identity import DefaultAzureCredential, get_bearer_token_provider
75
-
76
- token_provider = get_bearer_token_provider(
77
- DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
78
- )
79
-
80
- client = AzureOpenAI(
81
- azure_endpoint = " https://YOUR-RESOURCE-NAME.openai.azure.com/" ,
82
- azure_ad_token_provider = token_provider,
83
- api_version = " 2025-04-01-preview"
84
- )
85
-
86
- response = client.responses.create(
87
- model = " gpt-4.1-nano" , # Replace with your model deployment name
88
- input = " This is a test."
89
- )
90
-
91
- print (response.model_dump_json(indent = 2 ))
92
- ```
93
-
94
48
### v1 API
95
49
50
+ [ Python v1 examples] ( ./supported-languages.md )
51
+
96
52
** API Key** :
97
53
98
54
``` python
@@ -116,6 +72,12 @@ print(response.model_dump_json(indent=2))
116
72
- ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
117
73
- ` api-version ` is no longer a required parameter with the v1 GA API.
118
74
75
+ ** API Key** with environment variables set for ` OPENAI_BASE_URL ` and ` OPENAI_API_KEY ` :
76
+
77
+ ``` python
78
+ client = OpenAI()
79
+ ```
80
+
119
81
** Microsoft Entra ID** :
120
82
121
83
> [ !IMPORTANT]
@@ -149,6 +111,8 @@ print(response.model_dump_json(indent=2))
149
111
150
112
### v1 API
151
113
114
+ [ C# v1 examples] ( ./supported-languages.md )
115
+
152
116
** API Key** :
153
117
154
118
``` csharp
@@ -172,56 +136,72 @@ OpenAIClient client = new(
172
136
authenticationPolicy : tokenPolicy ,
173
137
options : new OpenAIClientOptions ()
174
138
{
175
- Endpoint = new (" https://aoaitiptesting .openai.azure.com/openai/v1/" ),
139
+ Endpoint = new (" https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" ),
176
140
})
177
141
```
178
142
179
143
# [JavaScript](#tab/javascript)
180
144
181
145
### v1 API
182
146
147
+ [JavaScript v1 examples ](./ supported - languages .md )
148
+
183
149
** API Key ** :
184
150
185
151
```javascript
186
152
const client = new OpenAI ({
187
- baseURL : " https://aoaitiptesting .openai.azure.com/openai/v1/" ,
153
+ baseURL : " https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" ,
188
154
apiKey : " {your-api-key}"
189
155
});
190
156
```
191
157
158
+ ** API Key** with environment variables set for ` OPENAI_BASE_URL ` and ` OPENAI_API_KEY ` :
159
+
160
+ ``` javascript
161
+ const client = new OpenAI ();
162
+ ```
163
+
192
164
** Microsoft Entra ID** :
193
165
194
166
``` javascript
195
167
const tokenProvider = getBearerTokenProvider (
196
168
new DefaultAzureCredential (),
197
169
' https://cognitiveservices.azure.com/.default' );
198
170
const client = new OpenAI ({
199
- baseURL: " https://aoaitiptesting .openai.azure.com/openai/v1/" ,
171
+ baseURL: " https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" ,
200
172
apiKey: tokenProvider
201
173
});
202
174
```
203
175
204
-
205
176
# [ Go] ( #tab/go )
206
177
207
178
### v1 API
208
179
180
+ [ Go v1 examples] ( ./supported-languages.md )
181
+
209
182
** API Key** :
210
183
211
184
``` go
212
185
client := openai.NewClient (
213
- option.WithBaseURL (" https://aoaitiptesting .openai.azure.com/openai/v1/" ),
186
+ option.WithBaseURL (" https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" ),
214
187
option.WithAPIKey (" {your-api-key}" )
215
188
)
216
189
```
217
190
191
+ ** API Key** with environment variables set for ` OPENAI_BASE_URL ` and ` OPENAI_API_KEY ` :
192
+
193
+ ``` go
194
+ client := openai.NewClient ()
195
+ ```
196
+
197
+
218
198
** Microsoft Entra ID** :
219
199
220
200
``` go
221
201
tokenCredential , err := azidentity.NewDefaultAzureCredential (nil )
222
202
223
203
client := openai.NewClient (
224
- option.WithBaseURL (" https://aoaitiptesting .openai.azure.com/openai/v1/" ),
204
+ option.WithBaseURL (" https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" ),
225
205
azure.WithTokenCredential (tokenCredential)
226
206
)
227
207
```
@@ -232,12 +212,20 @@ client := openai.NewClient(
232
212
233
213
** API Key** :
234
214
215
+ ``` java
216
+
217
+ OpenAIClient client = OpenAIOkHttpClient . builder()
218
+ .baseUrl(" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" )
219
+ .credential(AzureApiKeyCredential . create(" {your-api-key}" ))
220
+ .build();
221
+ ```
222
+
223
+ ** API Key** with environment variables set for ` OPENAI_BASE_URL ` and ` OPENAI_API_KEY ` :
224
+
235
225
``` java
236
226
OpenAIClient client = OpenAIOkHttpClient . builder()
237
- .baseUrl(" https://aoaitiptesting.services.ai.azure.com/openai/v1/" )
238
- .azureServiceVersion(AzureOpenAIServiceVersion . fromString(" preview" ))
239
- .credential(AzureApiKeyCredential . create(" {your-azure-api-key}" ))
240
- .build()
227
+ .fromEnv()
228
+ .build();
241
229
```
242
230
243
231
** Microsoft Entra ID** :
@@ -248,46 +236,19 @@ Credential tokenCredential = BearerTokenCredential.create(
248
236
new DefaultAzureCredentialBuilder (). build(),
249
237
" https://cognitiveservices.azure.com/.default" ));
250
238
OpenAIClient client = OpenAIOkHttpClient . builder()
251
- .baseUrl(" https://aoaitiptesting .openai.azure.com/openai/v1/" )
239
+ .baseUrl(" https://YOUR-RESOURCE-NAME .openai.azure.com/openai/v1/" )
252
240
.credential(tokenCredential)
253
241
.build();
254
242
```
255
243
256
-
257
244
# [ REST] ( #tab/rest )
258
245
259
- ### Previous API
260
-
261
- ** API Key** :
262
-
263
- ``` bash
264
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses? api-version=2025-04-01-preview \
265
- -H " Content-Type: application/json" \
266
- -H " api-key: $AZURE_OPENAI_API_KEY " \
267
- -d ' {
268
- "model": "gpt-4.1-nano",
269
- "input": "This is a test"
270
- }'
271
- ```
272
-
273
- ** Microsoft Entra ID** :
274
-
275
- ``` bash
276
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses? api-version=2025-04-01-preview \
277
- -H " Content-Type: application/json" \
278
- -H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN " \
279
- -d ' {
280
- "model": "gpt-4.1-nano",
281
- "input": "This is a test"
282
- }'
283
- ```
284
-
285
246
### v1 API
286
247
287
248
** API Key** :
288
249
289
250
``` bash
290
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses? api-version=preview \
251
+ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses \
291
252
-H " Content-Type: application/json" \
292
253
-H " api-key: $AZURE_OPENAI_API_KEY " \
293
254
-d ' {
@@ -299,7 +260,7 @@ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses?api
299
260
** Microsoft Entra ID** :
300
261
301
262
``` bash
302
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses? api-version=preview \
263
+ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses \
303
264
-H " Content-Type: application/json" \
304
265
-H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN " \
305
266
-d ' {
0 commit comments