Skip to content

Commit ab9febd

Browse files
committed
update
1 parent 2ef708e commit ab9febd

File tree

1 file changed

+47
-86
lines changed

1 file changed

+47
-86
lines changed

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

Lines changed: 47 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -45,54 +45,10 @@ For the initial v1 Generally Available (GA) API launch we're only supporting a s
4545

4646
# [Python](#tab/python)
4747

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-
9448
### v1 API
9549

50+
[Python v1 examples](./supported-languages.md)
51+
9652
**API Key**:
9753

9854
```python
@@ -116,6 +72,12 @@ print(response.model_dump_json(indent=2))
11672
- `base_url` passes the Azure OpenAI endpoint and `/openai/v1` is appended to the endpoint address.
11773
- `api-version` is no longer a required parameter with the v1 GA API.
11874

75+
**API Key** with environment variables set for `OPENAI_BASE_URL` and `OPENAI_API_KEY`:
76+
77+
```python
78+
client = OpenAI()
79+
```
80+
11981
**Microsoft Entra ID**:
12082

12183
> [!IMPORTANT]
@@ -149,6 +111,8 @@ print(response.model_dump_json(indent=2))
149111

150112
### v1 API
151113

114+
[C# v1 examples](./supported-languages.md)
115+
152116
**API Key**:
153117

154118
```csharp
@@ -172,56 +136,72 @@ OpenAIClient client = new(
172136
authenticationPolicy: tokenPolicy,
173137
options: new OpenAIClientOptions()
174138
{
175-
Endpoint = new("https://aoaitiptesting.openai.azure.com/openai/v1/"),
139+
Endpoint = new("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/"),
176140
})
177141
```
178142

179143
# [JavaScript](#tab/javascript)
180144

181145
### v1 API
182146

147+
[JavaScript v1 examples](./supported-languages.md)
148+
183149
**API Key**:
184150

185151
```javascript
186152
const client = new OpenAI({
187-
baseURL: "https://aoaitiptesting.openai.azure.com/openai/v1/",
153+
baseURL: "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
188154
apiKey: "{your-api-key}"
189155
});
190156
```
191157

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+
192164
**Microsoft Entra ID**:
193165

194166
```javascript
195167
const tokenProvider = getBearerTokenProvider(
196168
new DefaultAzureCredential(),
197169
'https://cognitiveservices.azure.com/.default');
198170
const client = new OpenAI({
199-
baseURL: "https://aoaitiptesting.openai.azure.com/openai/v1/",
171+
baseURL: "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/",
200172
apiKey: tokenProvider
201173
});
202174
```
203175

204-
205176
# [Go](#tab/go)
206177

207178
### v1 API
208179

180+
[Go v1 examples](./supported-languages.md)
181+
209182
**API Key**:
210183

211184
```go
212185
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/"),
214187
option.WithAPIKey("{your-api-key}")
215188
)
216189
```
217190

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+
218198
**Microsoft Entra ID**:
219199

220200
```go
221201
tokenCredential, err := azidentity.NewDefaultAzureCredential(nil)
222202

223203
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/"),
225205
azure.WithTokenCredential(tokenCredential)
226206
)
227207
```
@@ -232,12 +212,20 @@ client := openai.NewClient(
232212

233213
**API Key**:
234214

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+
235225
```java
236226
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();
241229
```
242230

243231
**Microsoft Entra ID**:
@@ -248,46 +236,19 @@ Credential tokenCredential = BearerTokenCredential.create(
248236
new DefaultAzureCredentialBuilder().build(),
249237
"https://cognitiveservices.azure.com/.default"));
250238
OpenAIClient client = OpenAIOkHttpClient.builder()
251-
.baseUrl("https://aoaitiptesting.openai.azure.com/openai/v1/")
239+
.baseUrl("https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/")
252240
.credential(tokenCredential)
253241
.build();
254242
```
255243

256-
257244
# [REST](#tab/rest)
258245

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-
285246
### v1 API
286247

287248
**API Key**:
288249

289250
```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 \
291252
-H "Content-Type: application/json" \
292253
-H "api-key: $AZURE_OPENAI_API_KEY" \
293254
-d '{
@@ -299,7 +260,7 @@ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses?api
299260
**Microsoft Entra ID**:
300261

301262
```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 \
303264
-H "Content-Type: application/json" \
304265
-H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
305266
-d '{

0 commit comments

Comments
 (0)