@azure/ai-projects 2.0.0-beta.1 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +589 -14
  2. package/dist/browser/aiProjectClient.d.ts +4 -0
  3. package/dist/browser/aiProjectClient.d.ts.map +1 -1
  4. package/dist/browser/aiProjectClient.js +6 -1
  5. package/dist/browser/aiProjectClient.js.map +1 -1
  6. package/dist/browser/api/aiProjectContext.js +1 -1
  7. package/dist/browser/api/aiProjectContext.js.map +1 -1
  8. package/dist/browser/api/memoryStores/index.d.ts +1 -0
  9. package/dist/browser/api/memoryStores/index.d.ts.map +1 -1
  10. package/dist/browser/api/memoryStores/index.js.map +1 -1
  11. package/dist/browser/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  12. package/dist/browser/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  13. package/dist/browser/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +160 -0
  14. package/dist/browser/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  15. package/dist/browser/api/memoryStores/operations.d.ts +3 -4
  16. package/dist/browser/api/memoryStores/operations.d.ts.map +1 -1
  17. package/dist/browser/api/memoryStores/operations.js +3 -16
  18. package/dist/browser/api/memoryStores/operations.js.map +1 -1
  19. package/dist/browser/api/telemetry/index.d.ts +2 -0
  20. package/dist/browser/api/telemetry/index.d.ts.map +1 -0
  21. package/dist/browser/api/telemetry/index.js +4 -0
  22. package/dist/browser/api/telemetry/index.js.map +1 -0
  23. package/dist/browser/api/telemetry/operations.d.ts +22 -0
  24. package/dist/browser/api/telemetry/operations.d.ts.map +1 -0
  25. package/dist/browser/api/telemetry/operations.js +55 -0
  26. package/dist/browser/api/telemetry/operations.js.map +1 -0
  27. package/dist/browser/classic/index.d.ts +1 -0
  28. package/dist/browser/classic/index.d.ts.map +1 -1
  29. package/dist/browser/classic/index.js.map +1 -1
  30. package/dist/browser/classic/memoryStores/index.d.ts +3 -3
  31. package/dist/browser/classic/memoryStores/index.d.ts.map +1 -1
  32. package/dist/browser/classic/memoryStores/index.js.map +1 -1
  33. package/dist/browser/classic/telemetry/index.d.ts +8 -0
  34. package/dist/browser/classic/telemetry/index.d.ts.map +1 -0
  35. package/dist/browser/classic/telemetry/index.js +13 -0
  36. package/dist/browser/classic/telemetry/index.js.map +1 -0
  37. package/dist/browser/constants.d.ts +1 -1
  38. package/dist/browser/constants.js +1 -1
  39. package/dist/browser/constants.js.map +1 -1
  40. package/dist/browser/index.d.ts +2 -1
  41. package/dist/browser/index.d.ts.map +1 -1
  42. package/dist/browser/index.js.map +1 -1
  43. package/dist/browser/models/models.d.ts.map +1 -1
  44. package/dist/browser/models/models.js.map +1 -1
  45. package/dist/browser/restorePollerHelpers.d.ts.map +1 -1
  46. package/dist/browser/restorePollerHelpers.js +12 -4
  47. package/dist/browser/restorePollerHelpers.js.map +1 -1
  48. package/dist/commonjs/aiProjectClient.d.ts +4 -0
  49. package/dist/commonjs/aiProjectClient.d.ts.map +1 -1
  50. package/dist/commonjs/aiProjectClient.js +10 -5
  51. package/dist/commonjs/aiProjectClient.js.map +1 -1
  52. package/dist/commonjs/api/aiProjectContext.js +1 -1
  53. package/dist/commonjs/api/aiProjectContext.js.map +1 -1
  54. package/dist/commonjs/api/memoryStores/index.d.ts +1 -0
  55. package/dist/commonjs/api/memoryStores/index.d.ts.map +1 -1
  56. package/dist/commonjs/api/memoryStores/index.js.map +1 -1
  57. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  58. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  59. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +163 -0
  60. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  61. package/dist/commonjs/api/memoryStores/operations.d.ts +3 -4
  62. package/dist/commonjs/api/memoryStores/operations.d.ts.map +1 -1
  63. package/dist/commonjs/api/memoryStores/operations.js +2 -16
  64. package/dist/commonjs/api/memoryStores/operations.js.map +1 -1
  65. package/dist/commonjs/api/telemetry/index.d.ts +2 -0
  66. package/dist/commonjs/api/telemetry/index.d.ts.map +1 -0
  67. package/dist/commonjs/api/telemetry/index.js +8 -0
  68. package/dist/commonjs/api/telemetry/index.js.map +1 -0
  69. package/dist/commonjs/api/telemetry/operations.d.ts +22 -0
  70. package/dist/commonjs/api/telemetry/operations.d.ts.map +1 -0
  71. package/dist/commonjs/api/telemetry/operations.js +58 -0
  72. package/dist/commonjs/api/telemetry/operations.js.map +1 -0
  73. package/dist/commonjs/classic/index.d.ts +1 -0
  74. package/dist/commonjs/classic/index.d.ts.map +1 -1
  75. package/dist/commonjs/classic/index.js.map +1 -1
  76. package/dist/commonjs/classic/memoryStores/index.d.ts +3 -3
  77. package/dist/commonjs/classic/memoryStores/index.d.ts.map +1 -1
  78. package/dist/commonjs/classic/memoryStores/index.js.map +1 -1
  79. package/dist/commonjs/classic/telemetry/index.d.ts +8 -0
  80. package/dist/commonjs/classic/telemetry/index.d.ts.map +1 -0
  81. package/dist/commonjs/classic/telemetry/index.js +16 -0
  82. package/dist/commonjs/classic/telemetry/index.js.map +1 -0
  83. package/dist/commonjs/constants.d.ts +1 -1
  84. package/dist/commonjs/constants.js +1 -1
  85. package/dist/commonjs/constants.js.map +1 -1
  86. package/dist/commonjs/index.d.ts +2 -1
  87. package/dist/commonjs/index.d.ts.map +1 -1
  88. package/dist/commonjs/index.js.map +1 -1
  89. package/dist/commonjs/models/models.d.ts.map +1 -1
  90. package/dist/commonjs/models/models.js.map +1 -1
  91. package/dist/commonjs/restorePollerHelpers.d.ts.map +1 -1
  92. package/dist/commonjs/restorePollerHelpers.js +12 -4
  93. package/dist/commonjs/restorePollerHelpers.js.map +1 -1
  94. package/dist/commonjs/tsdoc-metadata.json +1 -1
  95. package/dist/esm/aiProjectClient.d.ts +4 -0
  96. package/dist/esm/aiProjectClient.d.ts.map +1 -1
  97. package/dist/esm/aiProjectClient.js +6 -1
  98. package/dist/esm/aiProjectClient.js.map +1 -1
  99. package/dist/esm/api/aiProjectContext.js +1 -1
  100. package/dist/esm/api/aiProjectContext.js.map +1 -1
  101. package/dist/esm/api/memoryStores/index.d.ts +1 -0
  102. package/dist/esm/api/memoryStores/index.d.ts.map +1 -1
  103. package/dist/esm/api/memoryStores/index.js.map +1 -1
  104. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  105. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  106. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +160 -0
  107. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  108. package/dist/esm/api/memoryStores/operations.d.ts +3 -4
  109. package/dist/esm/api/memoryStores/operations.d.ts.map +1 -1
  110. package/dist/esm/api/memoryStores/operations.js +3 -16
  111. package/dist/esm/api/memoryStores/operations.js.map +1 -1
  112. package/dist/esm/api/telemetry/index.d.ts +2 -0
  113. package/dist/esm/api/telemetry/index.d.ts.map +1 -0
  114. package/dist/esm/api/telemetry/index.js +4 -0
  115. package/dist/esm/api/telemetry/index.js.map +1 -0
  116. package/dist/esm/api/telemetry/operations.d.ts +22 -0
  117. package/dist/esm/api/telemetry/operations.d.ts.map +1 -0
  118. package/dist/esm/api/telemetry/operations.js +55 -0
  119. package/dist/esm/api/telemetry/operations.js.map +1 -0
  120. package/dist/esm/classic/index.d.ts +1 -0
  121. package/dist/esm/classic/index.d.ts.map +1 -1
  122. package/dist/esm/classic/index.js.map +1 -1
  123. package/dist/esm/classic/memoryStores/index.d.ts +3 -3
  124. package/dist/esm/classic/memoryStores/index.d.ts.map +1 -1
  125. package/dist/esm/classic/memoryStores/index.js.map +1 -1
  126. package/dist/esm/classic/telemetry/index.d.ts +8 -0
  127. package/dist/esm/classic/telemetry/index.d.ts.map +1 -0
  128. package/dist/esm/classic/telemetry/index.js +13 -0
  129. package/dist/esm/classic/telemetry/index.js.map +1 -0
  130. package/dist/esm/constants.d.ts +1 -1
  131. package/dist/esm/constants.js +1 -1
  132. package/dist/esm/constants.js.map +1 -1
  133. package/dist/esm/index.d.ts +2 -1
  134. package/dist/esm/index.d.ts.map +1 -1
  135. package/dist/esm/index.js.map +1 -1
  136. package/dist/esm/models/models.d.ts.map +1 -1
  137. package/dist/esm/models/models.js.map +1 -1
  138. package/dist/esm/restorePollerHelpers.d.ts.map +1 -1
  139. package/dist/esm/restorePollerHelpers.js +12 -4
  140. package/dist/esm/restorePollerHelpers.js.map +1 -1
  141. package/dist/react-native/aiProjectClient.d.ts +4 -0
  142. package/dist/react-native/aiProjectClient.d.ts.map +1 -1
  143. package/dist/react-native/aiProjectClient.js +6 -1
  144. package/dist/react-native/aiProjectClient.js.map +1 -1
  145. package/dist/react-native/api/aiProjectContext.js +1 -1
  146. package/dist/react-native/api/aiProjectContext.js.map +1 -1
  147. package/dist/react-native/api/memoryStores/index.d.ts +1 -0
  148. package/dist/react-native/api/memoryStores/index.d.ts.map +1 -1
  149. package/dist/react-native/api/memoryStores/index.js.map +1 -1
  150. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  151. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  152. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +160 -0
  153. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  154. package/dist/react-native/api/memoryStores/operations.d.ts +3 -4
  155. package/dist/react-native/api/memoryStores/operations.d.ts.map +1 -1
  156. package/dist/react-native/api/memoryStores/operations.js +3 -16
  157. package/dist/react-native/api/memoryStores/operations.js.map +1 -1
  158. package/dist/react-native/api/telemetry/index.d.ts +2 -0
  159. package/dist/react-native/api/telemetry/index.d.ts.map +1 -0
  160. package/dist/react-native/api/telemetry/index.js +4 -0
  161. package/dist/react-native/api/telemetry/index.js.map +1 -0
  162. package/dist/react-native/api/telemetry/operations.d.ts +22 -0
  163. package/dist/react-native/api/telemetry/operations.d.ts.map +1 -0
  164. package/dist/react-native/api/telemetry/operations.js +55 -0
  165. package/dist/react-native/api/telemetry/operations.js.map +1 -0
  166. package/dist/react-native/classic/index.d.ts +1 -0
  167. package/dist/react-native/classic/index.d.ts.map +1 -1
  168. package/dist/react-native/classic/index.js.map +1 -1
  169. package/dist/react-native/classic/memoryStores/index.d.ts +3 -3
  170. package/dist/react-native/classic/memoryStores/index.d.ts.map +1 -1
  171. package/dist/react-native/classic/memoryStores/index.js.map +1 -1
  172. package/dist/react-native/classic/telemetry/index.d.ts +8 -0
  173. package/dist/react-native/classic/telemetry/index.d.ts.map +1 -0
  174. package/dist/react-native/classic/telemetry/index.js +13 -0
  175. package/dist/react-native/classic/telemetry/index.js.map +1 -0
  176. package/dist/react-native/constants.d.ts +1 -1
  177. package/dist/react-native/constants.js +1 -1
  178. package/dist/react-native/constants.js.map +1 -1
  179. package/dist/react-native/index.d.ts +2 -1
  180. package/dist/react-native/index.d.ts.map +1 -1
  181. package/dist/react-native/index.js.map +1 -1
  182. package/dist/react-native/models/models.d.ts.map +1 -1
  183. package/dist/react-native/models/models.js.map +1 -1
  184. package/dist/react-native/restorePollerHelpers.d.ts.map +1 -1
  185. package/dist/react-native/restorePollerHelpers.js +12 -4
  186. package/dist/react-native/restorePollerHelpers.js.map +1 -1
  187. package/package.json +13 -9
package/README.md CHANGED
@@ -1,19 +1,23 @@
1
1
  # Azure AI Projects client library for JavaScript
2
2
 
3
- The AI Projects client library provides easy access to resources in your Microsoft Foundry project.
4
- Use it to:
3
+ The AI Projects client library (in preview) is part of the Microsoft Foundry SDK, and provides easy access to
4
+ resources in your Microsoft Foundry Project. Use it to:
5
5
 
6
6
  - **Create and run Agents** using the `.agents` property on the client.
7
- - **Get an OpenAI client** using the `.getOpenAIClient.` method.
7
+ - **Get an OpenAI client** using the `.getOpenAIClient.` method to run Responses, Conversations, Evals and FineTuning operations with your Agent.
8
+ * **Manage memory stores** for Agent conversations, using the `.memoryStores` operations.
9
+ * **Explore additional evaluation tools** to assess the performance of your generative AI application, using the `.evaluationRules`,
10
+ `.evaluationTaxonomies`, `.evaluators`, `.insights`, and `.schedules` operations.
11
+ * **Run Red Team scans** to identify risks associated with your generative AI application, using the ".redTeams" operations.
12
+ * **Fine tune** AI Models on your data.
8
13
  - **Enumerate AI Models** deployed to your Foundry Project using the `.deployments` operations.
9
14
  - **Enumerate connected Azure resources** in your Foundry project using the `.connections` operations.
10
15
  - **Upload documents and create Datasets** to reference them using the `.datasets` operations.
11
- - **Upload, retrieve, list, and delete files** using the OpenAI client obtained from `.getOpenAIClient()`. upload files to be used for fine-tuning and other AI model operations.
12
16
  - **Create and enumerate Search Indexes** using the `.indexes` operations.
13
17
 
14
- The client library uses version `2025-11-15-preview` of the Microsoft Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects/rest-api-reference).
18
+ The client library uses version `2025-11-15-preview` of the Microsoft Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects-v2/api-reference-2025-11-15-preview).
15
19
 
16
- [Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc)
20
+ [Product documentation](https://aka.ms/azsdk/azure-ai-projects-v2/product-doc)
17
21
  | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples)
18
22
  | [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects)
19
23
  | [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-v1)
@@ -30,6 +34,9 @@ The client library uses version `2025-11-15-preview` of the Microsoft Foundry [d
30
34
  - [Examples](#examples)
31
35
  - [Performing Responses operations using OpenAI client](#performing-responses-operations-using-openai-client)
32
36
  - [Performing Agent operations](#performing-agent-operations)
37
+ - [Using Agent tools](#using-agent-tools)
38
+ - [Built-in Tools](#built-in-tools)
39
+ - [Connection-Based Tools](#connection-based-tools)
33
40
  - [Deployments operations](#deployments-operations)
34
41
  - [Connections operations](#connections-operations)
35
42
  - [Dataset operations](#dataset-operations)
@@ -68,14 +75,13 @@ npm install @azure/ai-projects @azure/identity
68
75
 
69
76
  ### Create and authenticate the client
70
77
 
71
- To construct an `AIProjectsClient`, the `projectEndpoint` can be fetched from [projectEndpoint][ai_project_client_endpoint]. Below we will assume the environment variable `AZURE_AI_PROJECT_ENDPOINT_STRING` was defined to hold this value:
78
+ To construct an `AIProjectsClient`, the `projectEndpoint` can be fetched from [projectEndpoint][ai_project_client_endpoint]. Below we will assume the environment variable `AZURE_AI_PROJECT_ENDPOINT` was defined to hold this value:
72
79
 
73
80
  ```ts snippet:setup
74
81
  import { AIProjectClient } from "@azure/ai-projects";
75
82
  import { DefaultAzureCredential } from "@azure/identity";
76
83
 
77
- const projectEndpoint =
78
- process.env["AZURE_AI_PROJECT_ENDPOINT_STRING"] || "<project endpoint string>";
84
+ const projectEndpoint = process.env["AZURE_AI_PROJECT_ENDPOINT"] || "<project endpoint string>";
79
85
  const client = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());
80
86
  ```
81
87
 
@@ -85,13 +91,12 @@ The client uses API version `2025-11-15-preview`, refer to the [API documentatio
85
91
 
86
92
  ### Performing Responses operations using OpenAI client
87
93
 
88
- Your Microsoft Foundry project may have one or more OpenAI models deployed that support chat completions. Use the code below to get an authenticated [OpenAI](https://github.com/openai/openai-python?tab=readme-ov-file#microsoft-azure-openai) from the [openai](https://pypi.org/project/openai/) package, and execute a chat completions call.
94
+ Your Microsoft Foundry project may have one or more OpenAI models deployed that support chat completions. Use the code below to get an authenticated [OpenAI](https://github.com/openai/openai-node?tab=readme-ov-file#microsoft-azure-openai) from the [openai](https://www.npmjs.com/package/openai) package, and execute a chat completions call.
89
95
 
90
96
  Run the code below. Here we assume `deploymentName` (str) is defined. It's the deployment name of an AI model in your Foundry Project. As shown in the "Models + endpoints" tab, under the "Name" column.
91
97
 
92
- Update the `api_version` value with one found in the "Data plane - inference" row [in this table](https://learn.microsoft.com/azure/ai-foundry/openai/reference#api-specs)..
98
+ For openai logging, please refer [OpenAI Logging](https://github.com/openai/openai-node/tree/master?tab=readme-ov-file#logging).
93
99
 
94
- For openai logging, please refer [OpenAI Logging]( https://github.com/openai/openai-node/tree/master?tab=readme-ov-file#logging).
95
100
 
96
101
  ```ts snippet:openAI
97
102
  const openAIClient = await project.getOpenAIClient();
@@ -100,10 +105,14 @@ const response = await openAIClient.responses.create({
100
105
  input: "What is the size of France in square miles?",
101
106
  });
102
107
  console.log("response = ", JSON.stringify(response, null, 2));
108
+ const detailResponse = await openAIClient.responses.create({
109
+ model: deploymentName,
110
+ input: "And what is the capital city?",
111
+ previous_response_id: response.id,
112
+ });
113
+ console.log("detailed response = ", JSON.stringify(detailResponse, null, 2));
103
114
  ```
104
115
 
105
- See the "responses" folder in the [package samples][samples] for additional samples, including streaming responses.
106
-
107
116
  ### Performing Agent operations
108
117
 
109
118
  The `.agents` property on the `AIProjectsClient` gives you access to all Agent operations. Agents use an extension of the
@@ -158,6 +167,571 @@ console.log("Conversation deleted");
158
167
  await project.agents.deleteVersion(agent.name, agent.version);
159
168
  console.log("Agent deleted");
160
169
  ```
170
+
171
+ ### Using Agent tools
172
+
173
+ Agents can be enhanced with specialized tools for various capabilities. Tools are organized by their connection requirements:
174
+
175
+ #### Built-in Tools
176
+
177
+ These tools work immediately without requiring external connections.
178
+
179
+ **Code Interpreter**
180
+
181
+ Write and run Javascript code in a sandboxed environment, process files and work with diverse data formats. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-code-interpreter)
182
+
183
+ ```ts snippet:agent-code-interpreter
184
+ const openAIClient = await project.getOpenAIClient();
185
+ const response = await openAIClient.responses.create({
186
+ model: deploymentName,
187
+ input: "I need to solve the equation 3x + 11 = 14. Can you help me?",
188
+ tools: [{ type: "code_interpreter", container: { type: "auto" } }],
189
+ });
190
+ console.log(`Response output: ${response.output_text}`);
191
+ ```
192
+
193
+ See the full sample code in [agentCodeInterpreter.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/agentCodeInterpreter.ts).
194
+
195
+ **File Search**
196
+
197
+ Built-in RAG (Retrieval-Augmented Generation) tool to process and search through documents using vector stores for knowledge retrieval. [OpenAI Documentation](https://platform.openai.com/docs/assistants/tools/file-search)
198
+
199
+ ```ts snippet:agent-file-search
200
+ const openAIClient = await project.getOpenAIClient();
201
+ const assetFilePath = path.join(
202
+ __dirname,
203
+ "..",
204
+ "samples-dev",
205
+ "agents",
206
+ "assets",
207
+ "product_info.txt",
208
+ );
209
+ const vectorStore = await openAIClient.vectorStores.create({
210
+ name: "ProductInfoStreamStore",
211
+ });
212
+ console.log(`Vector store created (id: ${vectorStore.id})`);
213
+ // Upload file to vector store
214
+ const fileStream = fs.createReadStream(assetFilePath);
215
+ const uploadedFile = await openAIClient.vectorStores.files.uploadAndPoll(
216
+ vectorStore.id,
217
+ fileStream,
218
+ );
219
+ console.log(`File uploaded to vector store (id: ${uploadedFile.id})`);
220
+ // Create agent with file search tool
221
+ const agent = await project.agents.createVersion("StreamingFileSearchAgent", {
222
+ kind: "prompt",
223
+ model: deploymentName,
224
+ instructions:
225
+ "You are a helpful assistant that can search through product information and provide detailed responses. Use the file search tool to find relevant information before answering.",
226
+ tools: [
227
+ {
228
+ type: "file_search",
229
+ vector_store_ids: [vectorStore.id],
230
+ },
231
+ ],
232
+ });
233
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
234
+ ```
235
+
236
+ See the full sample code in [agentFileSearch.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/agentFileSearch.ts).
237
+
238
+ **Image Generation**
239
+
240
+ Generate images based on text prompts with customizable resolution, quality, and style settings:
241
+
242
+ ```ts snippet:agent-image-generation
243
+ const agent = await project.agents.createVersion("agent-image-generation", {
244
+ kind: "prompt",
245
+ model: deploymentName,
246
+ instructions: "Generate images based on user prompts",
247
+ tools: [
248
+ {
249
+ type: "image_generation",
250
+ quality: "low",
251
+ size: "1024x1024",
252
+ },
253
+ ],
254
+ });
255
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
256
+ ```
257
+
258
+ After calling `responses.create()`, you can download file using the returned response:
259
+
260
+ ```ts snippet:agent-image-generation-download
261
+ import { fileURLToPath } from "url";
262
+
263
+ const openAIClient = await project.getOpenAIClient();
264
+ const agent = await project.agents.createVersion("agent-image-generation", {
265
+ kind: "prompt",
266
+ model: deploymentName,
267
+ instructions: "Generate images based on user prompts",
268
+ tools: [
269
+ {
270
+ type: "image_generation",
271
+ quality: "low",
272
+ size: "1024x1024",
273
+ },
274
+ ],
275
+ });
276
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
277
+ const response = await openAIClient.responses.create(
278
+ {
279
+ input: "Generate an image of Microsoft logo.",
280
+ },
281
+ {
282
+ body: { agent: { name: agent.name, type: "agent_reference" } },
283
+ },
284
+ );
285
+ console.log(`Response created: ${response.id}`);
286
+ const imageData = response.output?.filter((output) => output.type === "image_generation_call");
287
+ if (imageData && imageData.length > 0 && imageData[0].result) {
288
+ console.log("Downloading generated image...");
289
+ const __filename = fileURLToPath(import.meta.url);
290
+ const __dirname = path.dirname(__filename);
291
+ const filename = "microsoft.png";
292
+ const filePath = path.join(__dirname, filename);
293
+ // Decode base64 and save to file
294
+ const imageBuffer = Buffer.from(imageData[0].result, "base64");
295
+ fs.writeFileSync(filePath, imageBuffer);
296
+ console.log(`Image downloaded and saved to: ${path.resolve(filePath)}`);
297
+ } else {
298
+ console.log("No image data found in the response.");
299
+ }
300
+ ```
301
+
302
+ **Web Search**
303
+
304
+ Perform general web searches to retrieve current information from the internet. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-web-search)
305
+
306
+ ```ts snippet:agent-web-search
307
+ const openAIClient = await project.getOpenAIClient();
308
+ // Create Agent with web search tool
309
+ const agent = await project.agents.createVersion("agent-web-search", {
310
+ kind: "prompt",
311
+ model: deploymentName,
312
+ instructions: "You are a helpful assistant that can search the web",
313
+ tools: [
314
+ {
315
+ type: "web_search_preview",
316
+ user_location: {
317
+ type: "approximate",
318
+ country: "GB",
319
+ city: "London",
320
+ region: "London",
321
+ },
322
+ },
323
+ ],
324
+ });
325
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
326
+ // Create a conversation for the agent interaction
327
+ const conversation = await openAIClient.conversations.create();
328
+ console.log(`Created conversation (id: ${conversation.id})`);
329
+ // Send a query to search the web
330
+ console.log("\nSending web search query...");
331
+ const response = await openAIClient.responses.create(
332
+ {
333
+ conversation: conversation.id,
334
+ input: "Show me the latest London Underground service updates",
335
+ },
336
+ {
337
+ body: { agent: { name: agent.name, type: "agent_reference" } },
338
+ },
339
+ );
340
+ console.log(`Response: ${response.output_text}`);
341
+ ```
342
+
343
+ See the full sample code in [agentWebSearch.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentWebSearch.ts).
344
+
345
+
346
+ **Model Context Protocol (MCP)**
347
+
348
+ Integrate MCP servers to extend agent capabilities with standardized tools and resources. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-connectors-mcp)
349
+
350
+ ```ts snippet:agent-mcp
351
+ const openAIClient = await project.getOpenAIClient();
352
+ const agent = await project.agents.createVersion("agent-mcp", {
353
+ kind: "prompt",
354
+ model: deploymentName,
355
+ instructions:
356
+ "You are a helpful agent that can use MCP tools to assist users. Use the available MCP tools to answer questions and perform tasks.",
357
+ tools: [
358
+ {
359
+ type: "mcp",
360
+ server_label: "api-specs",
361
+ server_url: "https://gitmcp.io/Azure/azure-rest-api-specs",
362
+ require_approval: "always",
363
+ },
364
+ ],
365
+ });
366
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
367
+ // Create a conversation thread to maintain context across multiple interactions
368
+ console.log("\nCreating conversation...");
369
+ const conversation = await openAIClient.conversations.create();
370
+ console.log(`Created conversation (id: ${conversation.id})`);
371
+ // Send initial request that will trigger the MCP tool to access Azure REST API specs
372
+ // This will generate an approval request since requireApproval="always"
373
+ console.log("\nSending request that will trigger MCP approval...");
374
+ const response = await openAIClient.responses.create(
375
+ {
376
+ conversation: conversation.id,
377
+ input: "Please summarize the Azure REST API specifications Readme",
378
+ },
379
+ {
380
+ body: { agent: { name: agent.name, type: "agent_reference" } },
381
+ },
382
+ );
383
+ ```
384
+
385
+ *After calling `responses.create()`, check for `mcp_approval_request` items in the response output. Send back `McpApprovalResponse` with your approval decision to allow the agent to continue its work.*
386
+
387
+ See the full sample code in [agentMcp.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentMcp.ts).
388
+
389
+ **OpenAPI**
390
+
391
+ Call external APIs defined by OpenAPI specifications without additional client-side code. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-openapi)
392
+
393
+ ```ts snippet:agent-openapi
394
+ const weatherSpecPath = path.resolve(__dirname, "../assets", "weather_openapi.json");
395
+ const agent = await project.agents.createVersion("MyOpenApiAgent", {
396
+ kind: "prompt",
397
+ model: deploymentName,
398
+ instructions:
399
+ "You are a helpful assistant that can call external APIs defined by OpenAPI specs to answer user questions.",
400
+ tools: [
401
+ {
402
+ type: "openapi",
403
+ openapi: {
404
+ name: "get_weather",
405
+ description: "Retrieve weather information for a location using wttr.in",
406
+ spec: weatherSpecPath,
407
+ auth: { type: "anonymous" },
408
+ },
409
+ },
410
+ ],
411
+ });
412
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
413
+ ```
414
+
415
+ See the full sample code in [agentOpenApi.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentOpenApi.ts).
416
+
417
+ **Function Tool**
418
+
419
+ Define custom functions that allow agents to interact with external APIs, databases, or application logic. [OpenAI Documentation](https://platform.openai.com/docs/guides/function-calling)
420
+
421
+ ```ts snippet:agent-function-tool
422
+ /**
423
+ * Define a function tool for the model to use
424
+ */
425
+ const funcTool = {
426
+ type: "function" as const,
427
+ function: {
428
+ name: "get_horoscope",
429
+ description: "Get today's horoscope for an astrological sign.",
430
+ strict: true,
431
+ parameters: {
432
+ type: "object",
433
+ properties: {
434
+ sign: {
435
+ type: "string",
436
+ description: "An astrological sign like Taurus or Aquarius",
437
+ },
438
+ },
439
+ required: ["sign"],
440
+ additional_properties: false,
441
+ },
442
+ },
443
+ };
444
+ const agent = await project.agents.createVersion("function-tool-agent", {
445
+ kind: "prompt",
446
+ model: deploymentName,
447
+ instructions: "You are a helpful assistant that can use function tools.",
448
+ tools: [funcTool],
449
+ });
450
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
451
+ ```
452
+
453
+ *After calling `responses.create()`, process `function_call` items from response output, execute your function logic with the provided arguments, and send back `FunctionCallOutput` with the results.*
454
+
455
+ See the full sample code in [agentFunctionTool.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/agentFunctionTool.ts).
456
+
457
+ #### Connection-Based Tools
458
+
459
+ These tools require configuring connections in your AI Foundry project and use `projectConnectionId`.
460
+
461
+ **Azure AI Search**
462
+
463
+ Integrate with Azure AI Search indexes for powerful knowledge retrieval and semantic search capabilities:
464
+
465
+ ```ts snippet:agent-azure-ai-search
466
+ const aiSearchConnectionId = process.env["AI_SEARCH_CONNECTION_ID"] || "";
467
+ const aiSearchIndexName = process.env["AI_SEARCH_INDEX_NAME"] || "";
468
+ const agent = await project.agents.createVersion("MyAISearchAgent", {
469
+ kind: "prompt",
470
+ model: deploymentName,
471
+ instructions:
472
+ "You are a helpful assistant. You must always provide citations for answers using the tool and render them as: `[message_idx:search_idx†source]`.",
473
+ tools: [
474
+ {
475
+ type: "azure_ai_search",
476
+ azure_ai_search: {
477
+ indexes: [
478
+ {
479
+ project_connection_id: aiSearchConnectionId,
480
+ index_name: aiSearchIndexName,
481
+ query_type: "simple",
482
+ },
483
+ ],
484
+ },
485
+ },
486
+ ],
487
+ });
488
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
489
+ ```
490
+
491
+ See the full sample code in [agentAiSearch.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentAiSearch.ts).
492
+
493
+ **Bing Grounding**
494
+
495
+ Ground agent responses with real-time web search results from Bing to provide up-to-date information:
496
+
497
+ ```ts snippet:agent-bing-grounding
498
+ const bingProjectConnectionId = process.env["BING_GROUNDING_CONNECTION_ID"] || "";
499
+ const agent = await project.agents.createVersion("MyBingGroundingAgent", {
500
+ kind: "prompt",
501
+ model: deploymentName,
502
+ instructions: "You are a helpful assistant.",
503
+ tools: [
504
+ {
505
+ type: "bing_grounding",
506
+ bing_grounding: {
507
+ search_configurations: [
508
+ {
509
+ project_connection_id: bingProjectConnectionId,
510
+ },
511
+ ],
512
+ },
513
+ },
514
+ ],
515
+ });
516
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
517
+ ```
518
+
519
+ See the full sample code in [agentBingGrounding.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentBingGrounding.ts).
520
+
521
+ **Bing Custom Search**
522
+
523
+ Use custom-configured Bing search instances for domain-specific or filtered web search results:
524
+ ```ts snippet:agent-bing-custom-search
525
+ const bingCustomSearchProjectConnectionId = process.env["BING_CUSTOM_SEARCH_CONNECTION_ID"] || "";
526
+ const bingCustomSearchInstanceName = process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || "";
527
+ const agent = await project.agents.createVersion("MyAgent", {
528
+ kind: "prompt",
529
+ model: deploymentName,
530
+ instructions:
531
+ "You are a helpful agent that can use Bing Custom Search tools to assist users. Use the available Bing Custom Search tools to answer questions and perform tasks.",
532
+ tools: [
533
+ {
534
+ type: "bing_custom_search_preview",
535
+ bing_custom_search_preview: {
536
+ search_configurations: [
537
+ {
538
+ project_connection_id: bingCustomSearchProjectConnectionId,
539
+ instance_name: bingCustomSearchInstanceName,
540
+ },
541
+ ],
542
+ },
543
+ },
544
+ ],
545
+ });
546
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
547
+ ```
548
+
549
+ See the full sample code in [agentBingCustomSearch.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentBingCustomSearch.ts).
550
+
551
+ **Microsoft Fabric**
552
+
553
+ Connect to and query Microsoft Fabric:
554
+
555
+ ```ts snippet:agent-microsoft-fabric
556
+ const fabricProjectConnectionId = process.env["FABRIC_PROJECT_CONNECTION_ID"] || "";
557
+ const agent = await project.agents.createVersion("MyFabricAgent", {
558
+ kind: "prompt",
559
+ model: deploymentName,
560
+ instructions: "You are a helpful assistant.",
561
+ tools: [
562
+ {
563
+ type: "fabric_dataagent_preview",
564
+ fabric_dataagent_preview: {
565
+ project_connections: [
566
+ {
567
+ project_connection_id: fabricProjectConnectionId,
568
+ },
569
+ ],
570
+ },
571
+ },
572
+ ],
573
+ });
574
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
575
+ ```
576
+
577
+ See the full sample code in [agentFabric.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentFabric.ts).
578
+
579
+ **SharePoint**
580
+
581
+ Access and search SharePoint documents, lists, and sites for enterprise knowledge integration:
582
+
583
+ ```ts snippet:agent-sharepoint
584
+ const sharepointProjectConnectionId = process.env["SHAREPOINT_PROJECT_CONNECTION_ID"] || "";
585
+ const agent = await project.agents.createVersion("MyAgent", {
586
+ kind: "prompt",
587
+ model: deploymentName,
588
+ instructions:
589
+ "You are a helpful agent that can use SharePoint tools to assist users. Use the available SharePoint tools to answer questions and perform tasks.",
590
+ // Define SharePoint tool that searches SharePoint content
591
+ tools: [
592
+ {
593
+ type: "sharepoint_grounding_preview",
594
+ sharepoint_grounding_preview: {
595
+ project_connections: [
596
+ {
597
+ project_connection_id: sharepointProjectConnectionId,
598
+ },
599
+ ],
600
+ },
601
+ },
602
+ ],
603
+ });
604
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
605
+ ```
606
+
607
+ See the full sample code in [agentSharepoint.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentSharepoint.ts).
608
+
609
+ **Browser Automation**
610
+
611
+ Automate browser interactions for web scraping, testing, and interaction with web applications:
612
+
613
+ ```ts snippet:agent-browser-automation
614
+ const browserAutomationProjectConnectionId = process.env["BROWSER_AUTOMATION_CONNECTION_ID"] || "";
615
+ const agent = await project.agents.createVersion("MyAgent", {
616
+ kind: "prompt",
617
+ model: deploymentName,
618
+ instructions: `You are an Agent helping with browser automation tasks.
619
+ You can answer questions, provide information, and assist with various tasks
620
+ related to web browsing using the Browser Automation tool available to you.`,
621
+ // Define Browser Automation tool
622
+ tools: [
623
+ {
624
+ type: "browser_automation_preview",
625
+ browser_automation_preview: {
626
+ connection: {
627
+ project_connection_id: browserAutomationProjectConnectionId,
628
+ },
629
+ },
630
+ },
631
+ ],
632
+ });
633
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
634
+ ```
635
+
636
+ See the full sample code in [agentBrowserAutomation.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentBrowserAutomation.ts).
637
+
638
+ **MCP with Project Connection**
639
+
640
+ MCP integration using project-specific connections for accessing connected MCP servers:
641
+
642
+ ```ts snippet:agent-mcp-connection
643
+ const mcpProjectConnectionId = process.env["MCP_PROJECT_CONNECTION_ID"] || "";
644
+ const agent = await project.agents.createVersion("agent-mcp-connection-auth", {
645
+ kind: "prompt",
646
+ model: deploymentName,
647
+ instructions: "Use MCP tools as needed",
648
+ tools: [
649
+ {
650
+ type: "mcp",
651
+ server_label: "api-specs",
652
+ server_url: "https://api.githubcopilot.com/mcp",
653
+ require_approval: "always",
654
+ project_connection_id: mcpProjectConnectionId,
655
+ },
656
+ ],
657
+ });
658
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
659
+ ```
660
+
661
+ See the full sample code in [agentMcpConnectionAuth.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentMcpConnectionAuth.ts).
662
+
663
+ **Agent-to-Agent (A2A)**
664
+
665
+ Enable multi-agent collaboration where agents can communicate and delegate tasks to other specialized agents:
666
+
667
+ ```ts snippet:agent-a2a
668
+ const a2aProjectConnectionId = process.env["A2A_PROJECT_CONNECTION_ID"] || "";
669
+ const agent = await project.agents.createVersion("MyA2AAgent", {
670
+ kind: "prompt",
671
+ model: deploymentName,
672
+ instructions: "You are a helpful assistant.",
673
+ // Define A2A tool for agent-to-agent communication
674
+ tools: [
675
+ {
676
+ type: "a2a_preview",
677
+ project_connection_id: a2aProjectConnectionId,
678
+ },
679
+ ],
680
+ });
681
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
682
+ ```
683
+
684
+ See the full sample code in [agentAgentToAgent.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentAgentToAgent.ts).
685
+
686
+ **OpenAPI with Project Connection**
687
+
688
+ Call external APIs defined by OpenAPI specifications using project connection authentication:
689
+
690
+ ```ts snippet:agent-openapi-connection
691
+ const tripAdvisorProjectConnectionId = process.env["TRIPADVISOR_PROJECT_CONNECTION_ID"] || "";
692
+ function loadOpenApiSpec(specPath: string): unknown {
693
+ if (!fs.existsSync(specPath)) {
694
+ throw new Error(`OpenAPI specification not found at: ${specPath}`);
695
+ }
696
+ try {
697
+ const data = fs.readFileSync(specPath, "utf-8");
698
+ return JSON.parse(data);
699
+ } catch (error) {
700
+ throw new Error(`Failed to read or parse OpenAPI specification at ${specPath}: ${error}`);
701
+ }
702
+ }
703
+ const tripAdvisorSpecPath = path.resolve(__dirname, "../assets", "tripadvisor_openapi.json");
704
+ const tripAdvisorSpec = loadOpenApiSpec(tripAdvisorSpecPath);
705
+ const agent = await project.agents.createVersion("MyOpenApiConnectionAgent", {
706
+ kind: "prompt",
707
+ model: deploymentName,
708
+ instructions:
709
+ "You are a travel assistant that consults the TripAdvisor Content API via project connection to answer user questions about locations.",
710
+ tools: [
711
+ {
712
+ type: "openapi",
713
+ openapi: {
714
+ name: "get_tripadvisor_location_details",
715
+ description:
716
+ "Fetch TripAdvisor location details, reviews, or photos using the Content API via project connection auth.",
717
+ spec: tripAdvisorSpec,
718
+ auth: {
719
+ type: "project_connection",
720
+ security_scheme: {
721
+ project_connection_id: tripAdvisorProjectConnectionId,
722
+ },
723
+ },
724
+ },
725
+ },
726
+ ],
727
+ });
728
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
729
+ ```
730
+
731
+ See the full sample code in [agentOpenApiConnectionAuth.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentOpenApiConnectionAuth.ts).
732
+
733
+ For complete working examples of all tools, see the [samples-dev directory](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples-dev).
734
+
161
735
  ### Deployments operations
162
736
 
163
737
  The code below shows some Deployments operations, which allow you to enumerate the AI models deployed to your Microsoft Foundry Projects. These models can be seen in the "Models + endpoints" tab in your Microsoft Foundry Project. Full samples can be found under the "deployment" folder in the [package samples][samples].
@@ -402,6 +976,7 @@ for await (const i of allIndexes) {
402
976
  console.log("Delete the Index versions created above:");
403
977
  await project.indexes.delete(indexName, version);
404
978
  ```
979
+
405
980
  ## Tracing
406
981
 
407
982
  **Note:** Tracing functionality is in preliminary preview and is subject to change. Spans, attributes, and events may be modified in future versions.