@@ -6,7 +6,7 @@ manager: nitinme
6
6
ms.service : azure-ai-foundry
7
7
ms.subservice : azure-ai-foundry-openai
8
8
ms.topic : conceptual
9
- ms.date : 09/05 /2025
9
+ ms.date : 10/01 /2025
10
10
author : mrbullwinkle
11
11
ms.author : mbullwin
12
12
recommendations : false
@@ -43,9 +43,11 @@ For the initial v1 Generally Available (GA) API launch we're only supporting a s
43
43
44
44
## Code changes
45
45
46
- # [ API Key ] ( #tab/key )
46
+ # [ Python ] ( #tab/python )
47
47
48
- ### Last generation API
48
+ ### Previous API
49
+
50
+ ** API Key** :
49
51
50
52
``` python
51
53
import os
@@ -65,32 +67,7 @@ response = client.responses.create(
65
67
print (response.model_dump_json(indent = 2 ))
66
68
```
67
69
68
- ### Next generation API
69
-
70
- ``` python
71
- import os
72
- from openai import OpenAI
73
-
74
- client = OpenAI(
75
- api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
76
- base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/"
77
- )
78
-
79
- response = client.responses.create(
80
- model = " gpt-4.1-nano" , # Replace with your model deployment name
81
- input = " This is a test." ,
82
- )
83
-
84
- print (response.model_dump_json(indent = 2 ))
85
- ```
86
-
87
- - ` OpenAI() ` client is used instead of ` AzureOpenAI() ` .
88
- - ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
89
- - ` api-version ` is no longer a required parameter with the v1 GA API.
90
-
91
- # [ Microsoft Entra ID] ( #tab/entra )
92
-
93
- ### Last generation API
70
+ ** Microsoft Entra ID** :
94
71
95
72
``` python
96
73
from openai import AzureOpenAI
@@ -114,7 +91,32 @@ response = client.responses.create(
114
91
print (response.model_dump_json(indent = 2 ))
115
92
```
116
93
117
- ### Next generation API
94
+ ### v1 API
95
+
96
+ ** API Key** :
97
+
98
+ ``` python
99
+ import os
100
+ from openai import OpenAI
101
+
102
+ client = OpenAI(
103
+ api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
104
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/"
105
+ )
106
+
107
+ response = client.responses.create(
108
+ model = " gpt-4.1-nano" , # Replace with your model deployment name
109
+ input = " This is a test." ,
110
+ )
111
+
112
+ print (response.model_dump_json(indent = 2 ))
113
+ ```
114
+
115
+ - ` OpenAI() ` client is used instead of ` AzureOpenAI() ` .
116
+ - ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
117
+ - ` api-version ` is no longer a required parameter with the v1 GA API.
118
+
119
+ ** Microsoft Entra ID** :
118
120
119
121
> [ !IMPORTANT]
120
122
> Handling automatic token refresh was previously handled through use of the ` AzureOpenAI() ` client. The v1 API removes this dependency, by adding automatic token refresh support to the ` OpenAI() ` client.
@@ -143,9 +145,118 @@ print(response.model_dump_json(indent=2))
143
145
- ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
144
146
- ` api_key ` parameter is set to ` token_provider ` , enabling automatic retrieval and refresh of an authentication token instead of using a static API key.
145
147
148
+ # [ C#] ( #tab/dotnet )
149
+
150
+ ### v1 API
151
+
152
+ ** API Key** :
153
+
154
+ ``` csharp
155
+ OpenAIClient client = new (
156
+ new ApiKeyCredential (" {your-api-key}" ),
157
+ new OpenAIClientOptions ()
158
+ {
159
+ Endpoint = new (" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ),
160
+ })
161
+ ```
162
+
163
+ ** Microsoft Entra ID ** :
164
+
165
+ ```csharp
166
+ #pragma warning disable OPENAI001
167
+
168
+ BearerTokenPolicy tokenPolicy = new (
169
+ new DefaultAzureCredential (),
170
+ " https://cognitiveservices.azure.com/.default" );
171
+ OpenAIClient client = new (
172
+ authenticationPolicy : tokenPolicy ,
173
+ options : new OpenAIClientOptions ()
174
+ {
175
+ Endpoint = new (" https://aoaitiptesting.openai.azure.com/openai/v1/" ),
176
+ })
177
+ ```
178
+
179
+ # [JavaScript](#tab/javascript)
180
+
181
+ ### v1 API
182
+
183
+ ** API Key ** :
184
+
185
+ ```javascript
186
+ const client = new OpenAI ({
187
+ baseURL : " https://aoaitiptesting.openai.azure.com/openai/v1/" ,
188
+ apiKey : " {your-api-key}"
189
+ });
190
+ ```
191
+
192
+ ** Microsoft Entra ID** :
193
+
194
+ ``` javascript
195
+ const tokenProvider = getBearerTokenProvider (
196
+ new DefaultAzureCredential (),
197
+ ' https://cognitiveservices.azure.com/.default' );
198
+ const client = new OpenAI ({
199
+ baseURL: " https://aoaitiptesting.openai.azure.com/openai/v1/" ,
200
+ apiKey: tokenProvider
201
+ });
202
+ ```
203
+
204
+
205
+ # [ Go] ( #tab/go )
206
+
207
+ ### v1 API
208
+
209
+ ** API Key** :
210
+
211
+ ``` go
212
+ client := openai.NewClient (
213
+ option.WithBaseURL (" https://aoaitiptesting.openai.azure.com/openai/v1/" ),
214
+ option.WithAPIKey (" {your-api-key}" )
215
+ )
216
+ ```
217
+
218
+ ** Microsoft Entra ID** :
219
+
220
+ ``` go
221
+ tokenCredential , err := azidentity.NewDefaultAzureCredential (nil )
222
+
223
+ client := openai.NewClient (
224
+ option.WithBaseURL (" https://aoaitiptesting.openai.azure.com/openai/v1/" ),
225
+ azure.WithTokenCredential (tokenCredential)
226
+ )
227
+ ```
228
+
229
+ # [ Java] ( #tab/Java )
230
+
231
+ ### v1 API
232
+
233
+ ** API Key** :
234
+
235
+ ``` java
236
+ 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()
241
+ ```
242
+
243
+ ** Microsoft Entra ID** :
244
+
245
+ ``` java
246
+ Credential tokenCredential = BearerTokenCredential . create(
247
+ AuthenticationUtil . getBearerTokenSupplier(
248
+ new DefaultAzureCredentialBuilder (). build(),
249
+ " https://cognitiveservices.azure.com/.default" ));
250
+ OpenAIClient client = OpenAIOkHttpClient . builder()
251
+ .baseUrl(" https://aoaitiptesting.openai.azure.com/openai/v1/" )
252
+ .credential(tokenCredential)
253
+ .build();
254
+ ```
255
+
256
+
146
257
# [ REST] ( #tab/rest )
147
258
148
- ### Last generation API
259
+ ### Previous API
149
260
150
261
** API Key** :
151
262
@@ -171,7 +282,7 @@ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses?api-ve
171
282
}'
172
283
```
173
284
174
- ### Next generation API
285
+ ### v1 API
175
286
176
287
** API Key** :
177
288
0 commit comments