@@ -5,7 +5,7 @@ description: Learn how to use Azure OpenAI's new stateful Responses API.
5
5
manager : nitinme
6
6
ms.service : azure-ai-openai
7
7
ms.topic : include
8
- ms.date : 05/19 /2025
8
+ ms.date : 05/25 /2025
9
9
author : mrbullwinkle
10
10
ms.author : mbullwin
11
11
ms.custom : references_regions
@@ -19,7 +19,7 @@ The Responses API is a new stateful API from Azure OpenAI. It brings together th
19
19
20
20
### API support
21
21
22
- ` 2025-03-01- preview` or later
22
+ - [ v1 preview API is required for access to the latest features ] ( ../api-version-lifecycle.md#api-evolution )
23
23
24
24
### Region Availability
25
25
@@ -60,7 +60,7 @@ Not every model is available in the regions supported by the responses API. Chec
60
60
61
61
### Reference documentation
62
62
63
- - [ Responses API reference documentation] ( /azure/ai-services/openai/reference-preview?#responses-api---create )
63
+ - [ Responses API reference documentation] ( /azure/ai-services/openai/reference-preview-latest ?#responses-api---create )
64
64
65
65
## Getting started with the responses API
66
66
@@ -82,18 +82,18 @@ token_provider = get_bearer_token_provider(
82
82
DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
83
83
)
84
84
85
- client = AzureOpenAI(
86
- azure_endpoint = os.getenv( " AZURE_OPENAI_ENDPOINT " ),
85
+ client = AzureOpenAI(
86
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ " ,
87
87
azure_ad_token_provider = token_provider,
88
- api_version = " 2025-03-01- preview"
88
+ api_version = " preview"
89
89
)
90
90
91
91
response = client.responses.create(
92
- model = " gpt-4o" , # replace with your model deployment name
93
- input = " This is a test."
94
- # truncation="auto" required when using computer-use-preview model.
95
-
92
+ model = " gpt-4.1-nano" ,
93
+ input = " This is a test"
96
94
)
95
+
96
+ print (response.model_dump_json(indent = 2 ))
97
97
```
98
98
99
99
# [ Python (API Key)] ( #tab/python-key )
@@ -102,28 +102,28 @@ response = client.responses.create(
102
102
103
103
``` python
104
104
import os
105
- from openai import AzureOpenAI
105
+ from openai import OpenAI
106
106
107
- client = AzureOpenAI(
108
- api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
109
- api_version = " 2025-03-01-preview" ,
110
- azure_endpoint = os.getenv(" AZURE_OPENAI_ENDPOINT" )
111
- )
112
-
113
- response = client.responses.create(
114
- model = " gpt-4o" , # replace with your model deployment name
115
- input = " This is a test."
116
- # truncation="auto" required when using computer-use-preview model.
107
+ client = OpenAI(
108
+ api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
109
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/" ,
110
+ default_query = {" api-version" : " preview" },
111
+ )
117
112
113
+ response = client.responses.create(
114
+ model = " gpt-4.1-nano" , # Replace with your model deployment name
115
+ input = " This is a test." ,
118
116
)
117
+
118
+ print (response.model_dump_json(indent = 2 ))
119
119
```
120
120
121
121
# [ REST API] ( #tab/rest-api )
122
122
123
123
### Microsoft Entra ID
124
124
125
125
``` bash
126
- curl -X POST " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-03-01- preview" \
126
+ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ responses? api-version=preview \
127
127
-H " Content-Type: application/json" \
128
128
-H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN " \
129
129
-d ' {
@@ -135,11 +135,11 @@ curl -X POST "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses?api-v
135
135
### API Key
136
136
137
137
``` bash
138
- curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses? api-version=2025-03-01- preview \
138
+ curl -X POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ responses? api-version=preview \
139
139
-H " Content-Type: application/json" \
140
140
-H " api-key: $AZURE_OPENAI_API_KEY " \
141
141
-d ' {
142
- "model": "gpt-4o ",
142
+ "model": "gpt-4.1-nano ",
143
143
"input": "This is a test"
144
144
}'
145
145
```
@@ -214,10 +214,10 @@ token_provider = get_bearer_token_provider(
214
214
DefaultAzureCredential(), " https://cognitiveservices.azure.com/.default"
215
215
)
216
216
217
- client = AzureOpenAI(
218
- azure_endpoint = os.getenv( " AZURE_OPENAI_ENDPOINT " ),
217
+ client = AzureOpenAI(
218
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ " ,
219
219
azure_ad_token_provider = token_provider,
220
- api_version = " 2025-03-01- preview"
220
+ api_version = " preview"
221
221
)
222
222
223
223
response = client.responses.retrieve(" resp_67cb61fa3a448190bcf2c42d96f0d1a8" )
@@ -231,13 +231,13 @@ print(response.model_dump_json(indent=2))
231
231
232
232
``` python
233
233
import os
234
- from openai import AzureOpenAI
234
+ from openai import OpenAI
235
235
236
- client = AzureOpenAI (
237
- api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
238
- api_version = " 2025-03-01-preview " ,
239
- azure_endpoint = os.getenv( " AZURE_OPENAI_ENDPOINT " )
240
- )
236
+ client = OpenAI (
237
+ api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
238
+ base_url = " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ " ,
239
+ default_query = { " api-version " : " preview " },
240
+ )
241
241
242
242
response = client.responses.retrieve(" resp_67cb61fa3a448190bcf2c42d96f0d1a8" )
243
243
```
@@ -247,15 +247,15 @@ response = client.responses.retrieve("resp_67cb61fa3a448190bcf2c42d96f0d1a8")
247
247
### Microsoft Entra ID
248
248
249
249
``` bash
250
- curl -X GET " https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses/{response_id}?api-version=2025-03-01- preview" \
250
+ curl -X GET https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ responses/{response_id}? api-version=preview \
251
251
-H " Content-Type: application/json" \
252
252
-H " Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN "
253
253
```
254
254
255
255
### API Key
256
256
257
257
``` bash
258
- curl -X GET https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses/{response_id}? api-version=2025-03-01- preview \
258
+ curl -X GET https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/ responses/{response_id}? api-version=preview \
259
259
-H " Content-Type: application/json" \
260
260
-H " api-key: $AZURE_OPENAI_API_KEY "
261
261
```
0 commit comments