Skip to content

Commit 2ef708e

Browse files
committed
update
1 parent a5acf63 commit 2ef708e

File tree

1 file changed

+143
-32
lines changed

1 file changed

+143
-32
lines changed

articles/ai-foundry/openai/api-version-lifecycle.md

Lines changed: 143 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ manager: nitinme
66
ms.service: azure-ai-foundry
77
ms.subservice: azure-ai-foundry-openai
88
ms.topic: conceptual
9-
ms.date: 09/05/2025
9+
ms.date: 10/01/2025
1010
author: mrbullwinkle
1111
ms.author: mbullwin
1212
recommendations: false
@@ -43,9 +43,11 @@ For the initial v1 Generally Available (GA) API launch we're only supporting a s
4343

4444
## Code changes
4545

46-
# [API Key](#tab/key)
46+
# [Python](#tab/python)
4747

48-
### Last generation API
48+
### Previous API
49+
50+
**API Key**:
4951

5052
```python
5153
import os
@@ -65,32 +67,7 @@ response = client.responses.create(
6567
print(response.model_dump_json(indent=2))
6668
```
6769

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**:
9471

9572
```python
9673
from openai import AzureOpenAI
@@ -114,7 +91,32 @@ response = client.responses.create(
11491
print(response.model_dump_json(indent=2))
11592
```
11693

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**:
118120

119121
> [!IMPORTANT]
120122
> 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))
143145
- `base_url` passes the Azure OpenAI endpoint and `/openai/v1` is appended to the endpoint address.
144146
- `api_key` parameter is set to `token_provider`, enabling automatic retrieval and refresh of an authentication token instead of using a static API key.
145147

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+
146257
# [REST](#tab/rest)
147258

148-
### Last generation API
259+
### Previous API
149260

150261
**API Key**:
151262

@@ -171,7 +282,7 @@ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses?api-ve
171282
}'
172283
```
173284

174-
### Next generation API
285+
### v1 API
175286

176287
**API Key**:
177288

0 commit comments

Comments
 (0)