@@ -37,9 +37,9 @@ You can find the template and code used here on [GitHub](https://github.com/Azur
37
37
38
38
## Usage support
39
39
40
- | Azure AI foundry support | Python SDK | C# SDK | Basic agent setup | Standard agent setup |
41
- | ---------| ---------| ---------| ---------| ---------|
42
- | | ✔️ | | | ✔️ |
40
+ | Azure AI foundry support | Python SDK | C# SDK | REST API | Basic agent setup | Standard agent setup |
41
+ | ---------| ---------| ---------| ---------| ---------| --------- |
42
+ | | ✔️ | | ✔️ | | ✔️ |
43
43
44
44
### Create Azure resources for local and cloud dev-test
45
45
@@ -177,6 +177,7 @@ def process_queue_message(msg: func.QueueMessage) -> None:
177
177
178
178
In the sample below we create a client and an agent that has the tools definition for the Azure Function
179
179
180
+ # [ Python] ( #tab/python )
180
181
``` python
181
182
# Initialize the client and create agent for the tools Azure Functions that the agent can use
182
183
@@ -230,16 +231,74 @@ agent = project_client.agents.create_agent(
230
231
)
231
232
```
232
233
234
+ # [ REST API] ( #tab/rest )
235
+ Follow the [ REST API Quickstart] ( ../../quickstart.md?pivots=rest-api ) to set the right values for the environment variables ` AZURE_AI_AGENTS_TOKEN ` and ` AZURE_AI_AGENTS_ENDPOINT ` . The create the agent using:
236
+ ``` console
237
+ curl $AZURE_AI_AGENTS_ENDPOINT/assistants?api-version=2024-12-01-preview \
238
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
239
+ -H "Content-Type: application/json" \
240
+ -d '{
241
+ "instructions": "You are a helpful support agent. Answer the user's questions to the best of your ability.",
242
+ "name": "azure-function-agent-get-weather",
243
+ "model": "gpt-4o-mini",
244
+ "tools": [
245
+ {
246
+ "type": "azure_function",
247
+ "azure_function": {
248
+ "function": {
249
+ "name": "GetWeather",
250
+ "description": "Get the weather in a location.",
251
+ "parameters": {
252
+ "type": "object",
253
+ "properties": {
254
+ "location": {"type": "string", "description": "The location to look up."}
255
+ },
256
+ "required": ["location"]
257
+ }
258
+ },
259
+ "input_binding": {
260
+ "type": "storage_queue",
261
+ "storage_queue": {
262
+ "queue_service_endpoint": "https://storageaccount.queue.core.windows.net",
263
+ "queue_name": "input"
264
+ }
265
+ },
266
+ "output_binding": {
267
+ "type": "storage_queue",
268
+ "storage_queue": {
269
+ "queue_service_endpoint": "https://storageaccount.queue.core.windows.net",
270
+ "queue_name": "output"
271
+ }
272
+ }
273
+ }
274
+ }
275
+ ]
276
+ }'
277
+ ```
278
+
279
+ ---
280
+
233
281
## Create a thread for the agent
234
282
283
+ # [ Python] ( #tab/python )
235
284
``` python
236
285
# Create a thread
237
286
thread = project_client.agents.create_thread()
238
287
print (f " Created thread, thread ID: { thread.id} " )
239
288
```
240
289
290
+ # [ REST API] ( #tab/rest )
291
+ ``` console
292
+ curl $AZURE_AI_AGENTS_ENDPOINT/threads?api-version=2024-12-01-preview \
293
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
294
+ -H "Content-Type: application/json" \
295
+ -d ''
296
+ ```
297
+ ---
298
+
241
299
## Create a run and check the output
242
300
301
+ # [ Python] ( #tab/python )
243
302
``` python
244
303
# Send the prompt to the agent
245
304
message = project_client.agents.create_message(
@@ -261,9 +320,35 @@ while run.status in ["queued", "in_progress", "requires_action"]:
261
320
262
321
print (f " Run finished with status: { run.status} " )
263
322
```
323
+ # [ REST API] ( #tab/rest )
324
+ ``` console
325
+ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
326
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
327
+ -H "Content-Type: application/json" \
328
+ -d '{
329
+ "role": "user",
330
+ "content": "What is the weather in Seattle, WA?"
331
+ }'
332
+ ```
333
+
334
+ ``` console
335
+ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs?api-version=2024-12-01-preview \
336
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
337
+ -H "Content-Type: application/json" \
338
+ -d '{
339
+ "assistant_id": "asst_abc123",
340
+ }'
341
+ ```
264
342
265
- ### Get the result of the run
343
+ ``` console
344
+ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2024-12-01-preview \
345
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
346
+ ```
347
+
348
+ ---
349
+ ## Get the result of the run
266
350
351
+ # [ Python] ( #tab/python )
267
352
``` python
268
353
# Get messages from the assistant thread
269
354
messages = project_client.agents.get_messages(thread_id = thread.id)
@@ -279,4 +364,10 @@ project_client.agents.delete_agent(agent.id)
279
364
print (" Deleted agent" )
280
365
```
281
366
367
+ # [ REST API] ( #tab/rest )
368
+ ``` console
369
+ curl $AZURE_AI_AGENTS_ENDPOINT/threads/thread_abc123/messages?api-version=2024-12-01-preview \
370
+ -H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
371
+ ```
372
+
282
373
::: zone-end
0 commit comments