@@ -33,33 +33,30 @@ az login
33
33
34
34
Next, you will need to fetch the Entra ID token to provide as authorization to the API calls. Fetch the token using the CLI command:
35
35
``` azurecli
36
- az account get-access-token --resource 'https://ml .azure.com/ ' | jq -r .accessToken | tr -d '"'
36
+ az account get-access-token --resource 'https://ai .azure.com' | jq -r .accessToken | tr -d '"'
37
37
```
38
38
Set the access token as an environment variable named ` AZURE_AI_AGENTS_TOKEN ` .
39
39
40
- To successfully make REST API calls to Azure AI Agents Service, you will need to use the endpoint as below:
40
+ To successfully make REST API calls to Azure AI Foundry Agent Service, you will need to use the endpoint as below:
41
41
42
- ` https://<HostName>/agents/v1.0/subscriptions/<AzureSubscriptionId>/resourceGroups/<ResourceGroup>/providers/Microsoft.MachineLearningServices/workspaces/<ProjectName> `
43
-
44
- ` HostName ` can be found by navigating to your ` discovery_url ` and removing the leading ` https:// ` and trailing ` /discovery ` . To find your ` discovery_url ` , run this CLI command:
45
-
46
- ``` azurecli
47
- az ml workspace show -n {project_name} --subscription {subscription_name} --resource-group {resource_group_name} --query discovery_url
48
- ```
42
+ ` https://<your_ai_service_name>.services.ai.azure.com/api/projects/<your_project_name> `
49
43
50
44
For example, your endpoint may look something like:
51
45
52
- ` https://eastus.api.azureml.ms/agents/v1.0/subscriptions/12345678-abcd-1234-abcd-123456789000/resourceGroups/my-resource-group/providers/Microsoft.MachineLearningServices/workspaces/my-project-name `
46
+ ` https://exampleaiservice.services.ai.azure.com/api/projects/project `
47
+
48
+ Set this endpoint as an environment variable named ` AZURE_AI_FOUNDRY_PROJECT_ENDPOINT ` .
53
49
54
- Set this endpoint as an environment variable named ` AZURE_AI_AGENTS_ENDPOINT ` .
50
+ For ` API_VERSION ` , the GA API version is ` 2025-05-01 ` and the latest Preview API version is ` 2025-05-15-preview ` .
55
51
56
52
### Create an agent
57
53
58
54
> [ !NOTE]
59
55
> With Azure AI Agents Service the ` model ` parameter requires model deployment name. If your model deployment name is different than the underlying model name then you would adjust your code to ` "model": "{your-custom-model-deployment-name}" ` .
60
56
61
57
``` console
62
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
58
+ curl --request POST \
59
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
63
60
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
64
61
-H "Content-Type: application/json" \
65
62
-d '{
@@ -73,7 +70,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=2025-05-01 \
73
70
### Create a thread
74
71
75
72
``` console
76
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
73
+ curl --request POST \
74
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
77
75
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
78
76
-H "Content-Type: application/json" \
79
77
-d ''
@@ -82,7 +80,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads?api-version=2025-05-01 \
82
80
### Add a user question to the thread
83
81
84
82
``` console
85
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
83
+ curl --request POST \
84
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
86
85
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
87
86
-H "Content-Type: application/json" \
88
87
-d '{
@@ -94,7 +93,8 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-versi
94
93
### Run the thread
95
94
96
95
``` console
97
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2025-05-01 \
96
+ curl --request POST \
97
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2025-05-01 \
98
98
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN" \
99
99
-H "Content-Type: application/json" \
100
100
-d '{
@@ -105,13 +105,15 @@ curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=2
105
105
### Retrieve the status of the run
106
106
107
107
``` console
108
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2025-05-01 \
108
+ curl --request GET \
109
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123?api-version=2025-05-01 \
109
110
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
110
111
```
111
112
112
113
### Retrieve the agent response
113
114
114
115
``` console
115
- curl $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
116
+ curl --request GET \
117
+ --url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/messages?api-version=2025-05-01 \
116
118
-H "Authorization: Bearer $AZURE_AI_AGENTS_TOKEN"
117
119
```
0 commit comments