@@ -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,29 +43,13 @@ 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
+ ### v1 API
49
49
50
- ``` python
51
- import os
52
- from openai import AzureOpenAI
53
-
54
- client = AzureOpenAI(
55
- api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
56
- api_version = " 2025-04-01-preview" ,
57
- azure_endpoint = " https://YOUR-RESOURCE-NAME.openai.azure.com" )
58
- )
59
-
60
- response = client.responses.create(
61
- model = " gpt-4.1-nano" , # Replace with your model deployment name
62
- input = " This is a test."
63
- )
50
+ [ Python v1 examples] ( ./supported-languages.md )
64
51
65
- print (response.model_dump_json(indent = 2 ))
66
- ```
67
-
68
- ### Next generation API
52
+ ** API Key** :
69
53
70
54
``` python
71
55
import os
@@ -88,33 +72,13 @@ print(response.model_dump_json(indent=2))
88
72
- ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
89
73
- ` api-version ` is no longer a required parameter with the v1 GA API.
90
74
91
- # [ Microsoft Entra ID] ( #tab/entra )
92
-
93
- ### Last generation API
75
+ ** API Key** with environment variables set for ` OPENAI_BASE_URL ` and ` OPENAI_API_KEY ` :
94
76
95
77
``` python
96
- from openai import AzureOpenAI
97
- from azure.identity import DefaultAzureCredential, get_bearer_token_provider
98
-
99
- token_provider = get_bearer_token_provider(
100
- DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
101
- )
102
-
103
- client = AzureOpenAI(
104
- azure_endpoint = " https://YOUR-RESOURCE-NAME.openai.azure.com/" ,
105
- azure_ad_token_provider = token_provider,
106
- api_version = " 2025-04-01-preview"
107
- )
108
-
109
- response = client.responses.create(
110
- model = " gpt-4.1-nano" , # Replace with your model deployment name
111
- input = " This is a test."
112
- )
113
-
114
- print (response.model_dump_json(indent = 2 ))
78
+ client = OpenAI()
115
79
```
116
80
117
- ### Next generation API
81
+ ** Microsoft Entra ID ** :
118
82
119
83
> [ !IMPORTANT]
120
84
> 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,40 +107,148 @@ print(response.model_dump_json(indent=2))
143
107
- ` base_url ` passes the Azure OpenAI endpoint and ` /openai/v1 ` is appended to the endpoint address.
144
108
- ` 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
109
146
- # [ REST] ( #tab/rest )
110
+ # [ C#] ( #tab/dotnet )
111
+
112
+ ### v1 API
147
113
148
- ### Last generation API
114
+ [ C# v1 examples ] ( ./supported-languages.md )
149
115
150
116
** API Key** :
151
117
152
- ``` bash
153
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses? api-version=2025-04-01-preview \
154
- -H " Content-Type: application/json" \
155
- -H " api-key: $AZURE_OPENAI_API_KEY " \
156
- -d ' {
157
- "model": "gpt-4.1-nano",
158
- "input": "This is a test"
159
- }'
118
+ ``` csharp
119
+ OpenAIClient client = new (
120
+ new ApiKeyCredential (" {your-api-key}" ),
121
+ new OpenAIClientOptions ()
122
+ {
123
+ Endpoint = new (" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ),
124
+ })
160
125
```
161
126
162
127
** Microsoft Entra ID ** :
163
128
164
- ``` bash
165
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses? api-version=2025-04-01-preview \
166
- -H " Content-Type: application/json" \
167
- -H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN " \
168
- -d ' {
169
- "model": "gpt-4.1-nano",
170
- "input": "This is a test"
171
- }'
129
+ ```csharp
130
+ #pragma warning disable OPENAI001
131
+
132
+ BearerTokenPolicy tokenPolicy = new (
133
+ new DefaultAzureCredential (),
134
+ " https://cognitiveservices.azure.com/.default" );
135
+ OpenAIClient client = new (
136
+ authenticationPolicy : tokenPolicy ,
137
+ options : new OpenAIClientOptions ()
138
+ {
139
+ Endpoint = new (" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ),
140
+ })
172
141
```
173
142
174
- ### Next generation API
143
+ # [JavaScript](#tab/javascript)
144
+
145
+ ### v1 API
146
+
147
+ [JavaScript v1 examples ](./ supported - languages .md )
148
+
149
+ ** API Key ** :
150
+
151
+ ```javascript
152
+ const client = new OpenAI ({
153
+ baseURL : " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ,
154
+ apiKey : " {your-api-key}"
155
+ });
156
+ ```
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
+
164
+ ** Microsoft Entra ID** :
165
+
166
+ ``` javascript
167
+ const tokenProvider = getBearerTokenProvider (
168
+ new DefaultAzureCredential (),
169
+ ' https://cognitiveservices.azure.com/.default' );
170
+ const client = new OpenAI ({
171
+ baseURL: " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ,
172
+ apiKey: tokenProvider
173
+ });
174
+ ```
175
+
176
+ # [ Go] ( #tab/go )
177
+
178
+ ### v1 API
179
+
180
+ [ Go v1 examples] ( ./supported-languages.md )
181
+
182
+ ** API Key** :
183
+
184
+ ``` go
185
+ client := openai.NewClient (
186
+ option.WithBaseURL (" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ),
187
+ option.WithAPIKey (" {your-api-key}" )
188
+ )
189
+ ```
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
+
198
+ ** Microsoft Entra ID** :
199
+
200
+ ``` go
201
+ tokenCredential , err := azidentity.NewDefaultAzureCredential (nil )
202
+
203
+ client := openai.NewClient (
204
+ option.WithBaseURL (" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ),
205
+ azure.WithTokenCredential (tokenCredential)
206
+ )
207
+ ```
208
+
209
+ # [ Java] ( #tab/Java )
210
+
211
+ ### v1 API
212
+
213
+ ** API Key** :
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
+
225
+ ``` java
226
+ OpenAIClient client = OpenAIOkHttpClient . builder()
227
+ .fromEnv()
228
+ .build();
229
+ ```
230
+
231
+ ** Microsoft Entra ID** :
232
+
233
+ ``` java
234
+ Credential tokenCredential = BearerTokenCredential . create(
235
+ AuthenticationUtil . getBearerTokenSupplier(
236
+ new DefaultAzureCredentialBuilder (). build(),
237
+ " https://cognitiveservices.azure.com/.default" ));
238
+ OpenAIClient client = OpenAIOkHttpClient . builder()
239
+ .baseUrl(" https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" )
240
+ .credential(tokenCredential)
241
+ .build();
242
+ ```
243
+
244
+ # [ REST] ( #tab/rest )
245
+
246
+ ### v1 API
175
247
176
248
** API Key** :
177
249
178
250
``` bash
179
- 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 \
180
252
-H " Content-Type: application/json" \
181
253
-H " api-key: $AZURE_OPENAI_API_KEY " \
182
254
-d ' {
@@ -188,7 +260,7 @@ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses?api
188
260
** Microsoft Entra ID** :
189
261
190
262
``` bash
191
- 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 \
192
264
-H " Content-Type: application/json" \
193
265
-H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN " \
194
266
-d ' {
0 commit comments