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

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 (211) hide show
  1. package/README.md +799 -20
  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 +12 -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/getCustomFetch-browser.d.mts.map +1 -0
  41. package/dist/browser/getCustomFetch-browser.mjs.map +1 -0
  42. package/dist/browser/getCustomFetch.d.ts +13 -0
  43. package/dist/browser/getCustomFetch.js +40 -0
  44. package/dist/browser/index.d.ts +2 -1
  45. package/dist/browser/index.d.ts.map +1 -1
  46. package/dist/browser/index.js.map +1 -1
  47. package/dist/browser/models/models.d.ts +10 -10
  48. package/dist/browser/models/models.d.ts.map +1 -1
  49. package/dist/browser/models/models.js +1 -1
  50. package/dist/browser/models/models.js.map +1 -1
  51. package/dist/browser/restorePollerHelpers.d.ts.map +1 -1
  52. package/dist/browser/restorePollerHelpers.js +12 -4
  53. package/dist/browser/restorePollerHelpers.js.map +1 -1
  54. package/dist/commonjs/aiProjectClient.d.ts +4 -0
  55. package/dist/commonjs/aiProjectClient.d.ts.map +1 -1
  56. package/dist/commonjs/aiProjectClient.js +16 -5
  57. package/dist/commonjs/aiProjectClient.js.map +1 -1
  58. package/dist/commonjs/api/aiProjectContext.js +1 -1
  59. package/dist/commonjs/api/aiProjectContext.js.map +1 -1
  60. package/dist/commonjs/api/memoryStores/index.d.ts +1 -0
  61. package/dist/commonjs/api/memoryStores/index.d.ts.map +1 -1
  62. package/dist/commonjs/api/memoryStores/index.js.map +1 -1
  63. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  64. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  65. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +163 -0
  66. package/dist/commonjs/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  67. package/dist/commonjs/api/memoryStores/operations.d.ts +3 -4
  68. package/dist/commonjs/api/memoryStores/operations.d.ts.map +1 -1
  69. package/dist/commonjs/api/memoryStores/operations.js +2 -16
  70. package/dist/commonjs/api/memoryStores/operations.js.map +1 -1
  71. package/dist/commonjs/api/telemetry/index.d.ts +2 -0
  72. package/dist/commonjs/api/telemetry/index.d.ts.map +1 -0
  73. package/dist/commonjs/api/telemetry/index.js +8 -0
  74. package/dist/commonjs/api/telemetry/index.js.map +1 -0
  75. package/dist/commonjs/api/telemetry/operations.d.ts +22 -0
  76. package/dist/commonjs/api/telemetry/operations.d.ts.map +1 -0
  77. package/dist/commonjs/api/telemetry/operations.js +58 -0
  78. package/dist/commonjs/api/telemetry/operations.js.map +1 -0
  79. package/dist/commonjs/classic/index.d.ts +1 -0
  80. package/dist/commonjs/classic/index.d.ts.map +1 -1
  81. package/dist/commonjs/classic/index.js.map +1 -1
  82. package/dist/commonjs/classic/memoryStores/index.d.ts +3 -3
  83. package/dist/commonjs/classic/memoryStores/index.d.ts.map +1 -1
  84. package/dist/commonjs/classic/memoryStores/index.js.map +1 -1
  85. package/dist/commonjs/classic/telemetry/index.d.ts +8 -0
  86. package/dist/commonjs/classic/telemetry/index.d.ts.map +1 -0
  87. package/dist/commonjs/classic/telemetry/index.js +16 -0
  88. package/dist/commonjs/classic/telemetry/index.js.map +1 -0
  89. package/dist/commonjs/constants.d.ts +1 -1
  90. package/dist/commonjs/constants.js +1 -1
  91. package/dist/commonjs/constants.js.map +1 -1
  92. package/dist/commonjs/getCustomFetch.d.ts +13 -0
  93. package/dist/commonjs/getCustomFetch.d.ts.map +1 -0
  94. package/dist/commonjs/getCustomFetch.js +45 -0
  95. package/dist/commonjs/getCustomFetch.js.map +1 -0
  96. package/dist/commonjs/index.d.ts +2 -1
  97. package/dist/commonjs/index.d.ts.map +1 -1
  98. package/dist/commonjs/index.js.map +1 -1
  99. package/dist/commonjs/models/models.d.ts +10 -10
  100. package/dist/commonjs/models/models.d.ts.map +1 -1
  101. package/dist/commonjs/models/models.js +1 -1
  102. package/dist/commonjs/models/models.js.map +1 -1
  103. package/dist/commonjs/restorePollerHelpers.d.ts.map +1 -1
  104. package/dist/commonjs/restorePollerHelpers.js +12 -4
  105. package/dist/commonjs/restorePollerHelpers.js.map +1 -1
  106. package/dist/commonjs/tsdoc-metadata.json +1 -1
  107. package/dist/esm/aiProjectClient.d.ts +4 -0
  108. package/dist/esm/aiProjectClient.d.ts.map +1 -1
  109. package/dist/esm/aiProjectClient.js +12 -1
  110. package/dist/esm/aiProjectClient.js.map +1 -1
  111. package/dist/esm/api/aiProjectContext.js +1 -1
  112. package/dist/esm/api/aiProjectContext.js.map +1 -1
  113. package/dist/esm/api/memoryStores/index.d.ts +1 -0
  114. package/dist/esm/api/memoryStores/index.d.ts.map +1 -1
  115. package/dist/esm/api/memoryStores/index.js.map +1 -1
  116. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  117. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  118. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +160 -0
  119. package/dist/esm/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  120. package/dist/esm/api/memoryStores/operations.d.ts +3 -4
  121. package/dist/esm/api/memoryStores/operations.d.ts.map +1 -1
  122. package/dist/esm/api/memoryStores/operations.js +3 -16
  123. package/dist/esm/api/memoryStores/operations.js.map +1 -1
  124. package/dist/esm/api/telemetry/index.d.ts +2 -0
  125. package/dist/esm/api/telemetry/index.d.ts.map +1 -0
  126. package/dist/esm/api/telemetry/index.js +4 -0
  127. package/dist/esm/api/telemetry/index.js.map +1 -0
  128. package/dist/esm/api/telemetry/operations.d.ts +22 -0
  129. package/dist/esm/api/telemetry/operations.d.ts.map +1 -0
  130. package/dist/esm/api/telemetry/operations.js +55 -0
  131. package/dist/esm/api/telemetry/operations.js.map +1 -0
  132. package/dist/esm/classic/index.d.ts +1 -0
  133. package/dist/esm/classic/index.d.ts.map +1 -1
  134. package/dist/esm/classic/index.js.map +1 -1
  135. package/dist/esm/classic/memoryStores/index.d.ts +3 -3
  136. package/dist/esm/classic/memoryStores/index.d.ts.map +1 -1
  137. package/dist/esm/classic/memoryStores/index.js.map +1 -1
  138. package/dist/esm/classic/telemetry/index.d.ts +8 -0
  139. package/dist/esm/classic/telemetry/index.d.ts.map +1 -0
  140. package/dist/esm/classic/telemetry/index.js +13 -0
  141. package/dist/esm/classic/telemetry/index.js.map +1 -0
  142. package/dist/esm/constants.d.ts +1 -1
  143. package/dist/esm/constants.js +1 -1
  144. package/dist/esm/constants.js.map +1 -1
  145. package/dist/esm/getCustomFetch.d.ts +13 -0
  146. package/dist/esm/getCustomFetch.d.ts.map +1 -0
  147. package/dist/esm/getCustomFetch.js +42 -0
  148. package/dist/esm/getCustomFetch.js.map +1 -0
  149. package/dist/esm/index.d.ts +2 -1
  150. package/dist/esm/index.d.ts.map +1 -1
  151. package/dist/esm/index.js.map +1 -1
  152. package/dist/esm/models/models.d.ts +10 -10
  153. package/dist/esm/models/models.d.ts.map +1 -1
  154. package/dist/esm/models/models.js +1 -1
  155. package/dist/esm/models/models.js.map +1 -1
  156. package/dist/esm/restorePollerHelpers.d.ts.map +1 -1
  157. package/dist/esm/restorePollerHelpers.js +12 -4
  158. package/dist/esm/restorePollerHelpers.js.map +1 -1
  159. package/dist/react-native/aiProjectClient.d.ts +4 -0
  160. package/dist/react-native/aiProjectClient.d.ts.map +1 -1
  161. package/dist/react-native/aiProjectClient.js +12 -1
  162. package/dist/react-native/aiProjectClient.js.map +1 -1
  163. package/dist/react-native/api/aiProjectContext.js +1 -1
  164. package/dist/react-native/api/aiProjectContext.js.map +1 -1
  165. package/dist/react-native/api/memoryStores/index.d.ts +1 -0
  166. package/dist/react-native/api/memoryStores/index.d.ts.map +1 -1
  167. package/dist/react-native/api/memoryStores/index.js.map +1 -1
  168. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts +43 -0
  169. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.d.ts.map +1 -0
  170. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.js +160 -0
  171. package/dist/react-native/api/memoryStores/memoryStoreUpdateMemoriesPoller.js.map +1 -0
  172. package/dist/react-native/api/memoryStores/operations.d.ts +3 -4
  173. package/dist/react-native/api/memoryStores/operations.d.ts.map +1 -1
  174. package/dist/react-native/api/memoryStores/operations.js +3 -16
  175. package/dist/react-native/api/memoryStores/operations.js.map +1 -1
  176. package/dist/react-native/api/telemetry/index.d.ts +2 -0
  177. package/dist/react-native/api/telemetry/index.d.ts.map +1 -0
  178. package/dist/react-native/api/telemetry/index.js +4 -0
  179. package/dist/react-native/api/telemetry/index.js.map +1 -0
  180. package/dist/react-native/api/telemetry/operations.d.ts +22 -0
  181. package/dist/react-native/api/telemetry/operations.d.ts.map +1 -0
  182. package/dist/react-native/api/telemetry/operations.js +55 -0
  183. package/dist/react-native/api/telemetry/operations.js.map +1 -0
  184. package/dist/react-native/classic/index.d.ts +1 -0
  185. package/dist/react-native/classic/index.d.ts.map +1 -1
  186. package/dist/react-native/classic/index.js.map +1 -1
  187. package/dist/react-native/classic/memoryStores/index.d.ts +3 -3
  188. package/dist/react-native/classic/memoryStores/index.d.ts.map +1 -1
  189. package/dist/react-native/classic/memoryStores/index.js.map +1 -1
  190. package/dist/react-native/classic/telemetry/index.d.ts +8 -0
  191. package/dist/react-native/classic/telemetry/index.d.ts.map +1 -0
  192. package/dist/react-native/classic/telemetry/index.js +13 -0
  193. package/dist/react-native/classic/telemetry/index.js.map +1 -0
  194. package/dist/react-native/constants.d.ts +1 -1
  195. package/dist/react-native/constants.js +1 -1
  196. package/dist/react-native/constants.js.map +1 -1
  197. package/dist/react-native/getCustomFetch.d.ts +13 -0
  198. package/dist/react-native/getCustomFetch.d.ts.map +1 -0
  199. package/dist/react-native/getCustomFetch.js +42 -0
  200. package/dist/react-native/getCustomFetch.js.map +1 -0
  201. package/dist/react-native/index.d.ts +2 -1
  202. package/dist/react-native/index.d.ts.map +1 -1
  203. package/dist/react-native/index.js.map +1 -1
  204. package/dist/react-native/models/models.d.ts +10 -10
  205. package/dist/react-native/models/models.d.ts.map +1 -1
  206. package/dist/react-native/models/models.js +1 -1
  207. package/dist/react-native/models/models.js.map +1 -1
  208. package/dist/react-native/restorePollerHelpers.d.ts.map +1 -1
  209. package/dist/react-native/restorePollerHelpers.js +12 -4
  210. package/dist/react-native/restorePollerHelpers.js.map +1 -1
  211. package/package.json +17 -10
package/README.md CHANGED
@@ -1,19 +1,40 @@
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
+ * **Enhance Agents with specialized tools**:
8
+ * Agent Memory Search
9
+ * Agent-to-Agent (A2A)
10
+ * Azure AI Search
11
+ * Bing Custom Search
12
+ * Bing Grounding
13
+ * Browser Automation
14
+ * Code Interpreter
15
+ * Computer Use
16
+ * File Search
17
+ * Function Tool
18
+ * Image Generation
19
+ * Microsoft Fabric
20
+ * Model Context Protocol (MCP)
21
+ * OpenAPI
22
+ * SharePoint
23
+ * Web Search
24
+ - **Get an OpenAI client** using the `.getOpenAIClient.` method to run Responses, Conversations, Evals and FineTuning operations with your Agent.
25
+ * **Manage memory stores** for Agent conversations, using the `.memoryStores` operations.
26
+ * **Explore additional evaluation tools** to assess the performance of your generative AI application, using the `.evaluationRules`,
27
+ `.evaluationTaxonomies`, `.evaluators`, `.insights`, and `.schedules` operations.
28
+ * **Run Red Team scans** to identify risks associated with your generative AI application, using the ".redTeams" operations.
29
+ * **Fine tune** AI Models on your data.
8
30
  - **Enumerate AI Models** deployed to your Foundry Project using the `.deployments` operations.
9
31
  - **Enumerate connected Azure resources** in your Foundry project using the `.connections` operations.
10
32
  - **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
33
  - **Create and enumerate Search Indexes** using the `.indexes` operations.
13
34
 
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).
35
+ 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
36
 
16
- [Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc)
37
+ [Product documentation](https://aka.ms/azsdk/azure-ai-projects-v2/product-doc)
17
38
  | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples)
18
39
  | [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects)
19
40
  | [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-v1)
@@ -30,12 +51,19 @@ The client library uses version `2025-11-15-preview` of the Microsoft Foundry [d
30
51
  - [Examples](#examples)
31
52
  - [Performing Responses operations using OpenAI client](#performing-responses-operations-using-openai-client)
32
53
  - [Performing Agent operations](#performing-agent-operations)
54
+ - [Using Agent tools](#using-agent-tools)
55
+ - [Built-in Tools](#built-in-tools)
56
+ - [Connection-Based Tools](#connection-based-tools)
57
+ - [Evaluation operations](#evaluation)
33
58
  - [Deployments operations](#deployments-operations)
34
59
  - [Connections operations](#connections-operations)
35
60
  - [Dataset operations](#dataset-operations)
36
61
  - [Files operations](#files-operations)
37
62
  - [Indexes operations](#indexes-operations)
63
+ - [fine-tuning operations](#fine-tuning-operations)
38
64
  - [Tracing](#tracing)
65
+ - [Installation](#installation)
66
+ - [How to enable tracing](#how-to-enable-tracing)
39
67
  - [Troubleshooting](#troubleshooting)
40
68
  - [Exceptions](#exceptions)
41
69
  - [Reporting issues](#reporting-issues)
@@ -49,11 +77,12 @@ The client library uses version `2025-11-15-preview` of the Microsoft Foundry [d
49
77
  - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
50
78
  - An [Azure subscription][azure_sub].
51
79
  - A [project in Microsoft Foundry](https://learn.microsoft.com/azure/ai-studio/how-to/create-projects?tabs=ai-studio).
80
+ - The project endpoint URL of the form `https://your-ai-services-account-name.services.ai.azure.com/api/projects/your-project-name`. It can be found in your Microsoft Foundry Project overview page. Below we will assume the environment variable `AZURE_AI_PROJECT_ENDPOINT` was defined to hold this value.
52
81
 
53
82
  ### Authorization
54
83
 
55
84
  - [Entra ID][entra_id] is needed to authenticate the client. Your application needs an object that implements the [TokenCredential](https://learn.microsoft.com/javascript/api/@azure/core-auth/tokencredential) interface. Code samples here use [DefaultAzureCredential][default_azure_credential]. To get that working, you will need:
56
- - The `Contributor` role. Role assigned can be done via the "Access Control (IAM)" tab of your Azure AI Project resource in the Azure portal. Learn more about role assignments [here](https://learn.microsoft.com/azure/role-based-access-control/role-assignments-portal).
85
+ - An appropriate role assignment. see [Role-based access control in Microsoft Foundry portal](https://learn.microsoft.com/azure/ai-foundry/concepts/rbac-ai-foundry). Role assigned can be done via the "Access Control (IAM)" tab of your Azure AI Project resource in the Azure portal.
57
86
  - [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed.
58
87
  - You are logged into your Azure account by running `az login`.
59
88
  - Note that if you have multiple Azure subscriptions, the subscription that contains your Azure AI Project resource must be your default subscription. Run `az account list --output table` to list all your subscription and see which one is the default. Run `az account set --subscription "Your Subscription ID or Name"` to change your default subscription.
@@ -61,37 +90,35 @@ The client library uses version `2025-11-15-preview` of the Microsoft Foundry [d
61
90
  ### Install the package
62
91
 
63
92
  ```bash
64
- npm install @azure/ai-projects @azure/identity
93
+ npm install @azure/ai-projects @azure/identity dotenv
65
94
  ```
66
95
 
67
96
  ## Key concepts
68
97
 
69
- ### Create and authenticate the client
98
+ ### Create and authenticate the client with Entra ID
70
99
 
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:
100
+ Entra ID is the only authentication method supported at the moment by the client.
101
+
102
+ 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
103
 
73
104
  ```ts snippet:setup
74
105
  import { AIProjectClient } from "@azure/ai-projects";
75
106
  import { DefaultAzureCredential } from "@azure/identity";
76
107
 
77
- const projectEndpoint =
78
- process.env["AZURE_AI_PROJECT_ENDPOINT_STRING"] || "<project endpoint string>";
108
+ const projectEndpoint = process.env["AZURE_AI_PROJECT_ENDPOINT"] || "<project endpoint string>";
79
109
  const client = new AIProjectClient(projectEndpoint, new DefaultAzureCredential());
80
110
  ```
81
111
 
82
- The client uses API version `2025-11-15-preview`, refer to the [API documentation][ai_foundry_data_plane_rest_apis] to learn more about the supported features.
83
-
84
112
  ## Examples
85
113
 
86
114
  ### Performing Responses operations using OpenAI client
87
115
 
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.
116
+ Your Microsoft Foundry project may have one or more AI models deployed. These could be OpenAI models, Microsoft models, or models from other providers. 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
117
 
90
118
  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
119
 
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)..
120
+ See the "responses" folder in the [package samples][samples] for additional samples, including streaming responses.
93
121
 
94
- For openai logging, please refer [OpenAI Logging]( https://github.com/openai/openai-node/tree/master?tab=readme-ov-file#logging).
95
122
 
96
123
  ```ts snippet:openAI
97
124
  const openAIClient = await project.getOpenAIClient();
@@ -100,10 +127,14 @@ const response = await openAIClient.responses.create({
100
127
  input: "What is the size of France in square miles?",
101
128
  });
102
129
  console.log("response = ", JSON.stringify(response, null, 2));
130
+ const detailResponse = await openAIClient.responses.create({
131
+ model: deploymentName,
132
+ input: "And what is the capital city?",
133
+ previous_response_id: response.id,
134
+ });
135
+ console.log("detailed response = ", JSON.stringify(detailResponse, null, 2));
103
136
  ```
104
137
 
105
- See the "responses" folder in the [package samples][samples] for additional samples, including streaming responses.
106
-
107
138
  ### Performing Agent operations
108
139
 
109
140
  The `.agents` property on the `AIProjectsClient` gives you access to all Agent operations. Agents use an extension of the
@@ -158,6 +189,682 @@ console.log("Conversation deleted");
158
189
  await project.agents.deleteVersion(agent.name, agent.version);
159
190
  console.log("Agent deleted");
160
191
  ```
192
+
193
+ ### Using Agent tools
194
+
195
+ Agents can be enhanced with specialized tools for various capabilities. Tools are organized by their connection requirements:
196
+
197
+ #### Built-in Tools
198
+
199
+ These tools work immediately without requiring external connections.
200
+
201
+ **Code Interpreter**
202
+
203
+ 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)
204
+
205
+ ```ts snippet:agent-code-interpreter
206
+ const openAIClient = await project.getOpenAIClient();
207
+ const response = await openAIClient.responses.create({
208
+ model: deploymentName,
209
+ input: "I need to solve the equation 3x + 11 = 14. Can you help me?",
210
+ tools: [{ type: "code_interpreter", container: { type: "auto" } }],
211
+ });
212
+ console.log(`Response output: ${response.output_text}`);
213
+ ```
214
+
215
+ 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).
216
+
217
+ **File Search**
218
+
219
+ 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)
220
+
221
+ ```ts snippet:agent-file-search
222
+ const openAIClient = await project.getOpenAIClient();
223
+ const assetFilePath = path.join(
224
+ __dirname,
225
+ "..",
226
+ "samples-dev",
227
+ "agents",
228
+ "assets",
229
+ "product_info.txt",
230
+ );
231
+ const vectorStore = await openAIClient.vectorStores.create({
232
+ name: "ProductInfoStreamStore",
233
+ });
234
+ console.log(`Vector store created (id: ${vectorStore.id})`);
235
+ // Upload file to vector store
236
+ const fileStream = fs.createReadStream(assetFilePath);
237
+ const uploadedFile = await openAIClient.vectorStores.files.uploadAndPoll(
238
+ vectorStore.id,
239
+ fileStream,
240
+ );
241
+ console.log(`File uploaded to vector store (id: ${uploadedFile.id})`);
242
+ // Create agent with file search tool
243
+ const agent = await project.agents.createVersion("StreamingFileSearchAgent", {
244
+ kind: "prompt",
245
+ model: deploymentName,
246
+ instructions:
247
+ "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.",
248
+ tools: [
249
+ {
250
+ type: "file_search",
251
+ vector_store_ids: [vectorStore.id],
252
+ },
253
+ ],
254
+ });
255
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
256
+ ```
257
+
258
+ 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).
259
+
260
+ **Image Generation**
261
+
262
+ Generate images based on text prompts with customizable resolution, quality, and style settings:
263
+
264
+ ```ts snippet:agent-image-generation
265
+ const agent = await project.agents.createVersion("agent-image-generation", {
266
+ kind: "prompt",
267
+ model: deploymentName,
268
+ instructions: "Generate images based on user prompts",
269
+ tools: [
270
+ {
271
+ type: "image_generation",
272
+ quality: "low",
273
+ size: "1024x1024",
274
+ },
275
+ ],
276
+ });
277
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
278
+ ```
279
+
280
+ After calling `responses.create()`, you can download file using the returned response:
281
+
282
+ ```ts snippet:agent-image-generation-download
283
+ import { fileURLToPath } from "url";
284
+
285
+ const openAIClient = await project.getOpenAIClient();
286
+ const agent = await project.agents.createVersion("agent-image-generation", {
287
+ kind: "prompt",
288
+ model: deploymentName,
289
+ instructions: "Generate images based on user prompts",
290
+ tools: [
291
+ {
292
+ type: "image_generation",
293
+ quality: "low",
294
+ size: "1024x1024",
295
+ },
296
+ ],
297
+ });
298
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
299
+ const response = await openAIClient.responses.create(
300
+ {
301
+ input: "Generate an image of Microsoft logo.",
302
+ },
303
+ {
304
+ body: { agent: { name: agent.name, type: "agent_reference" } },
305
+ },
306
+ );
307
+ console.log(`Response created: ${response.id}`);
308
+ const imageData = response.output?.filter((output) => output.type === "image_generation_call");
309
+ if (imageData && imageData.length > 0 && imageData[0].result) {
310
+ console.log("Downloading generated image...");
311
+ const __filename = fileURLToPath(import.meta.url);
312
+ const __dirname = path.dirname(__filename);
313
+ const filename = "microsoft.png";
314
+ const filePath = path.join(__dirname, filename);
315
+ // Decode base64 and save to file
316
+ const imageBuffer = Buffer.from(imageData[0].result, "base64");
317
+ fs.writeFileSync(filePath, imageBuffer);
318
+ console.log(`Image downloaded and saved to: ${path.resolve(filePath)}`);
319
+ } else {
320
+ console.log("No image data found in the response.");
321
+ }
322
+ ```
323
+
324
+ **Web Search**
325
+
326
+ Perform general web searches to retrieve current information from the internet. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-web-search)
327
+
328
+ ```ts snippet:agent-web-search
329
+ const openAIClient = await project.getOpenAIClient();
330
+ // Create Agent with web search tool
331
+ const agent = await project.agents.createVersion("agent-web-search", {
332
+ kind: "prompt",
333
+ model: deploymentName,
334
+ instructions: "You are a helpful assistant that can search the web",
335
+ tools: [
336
+ {
337
+ type: "web_search_preview",
338
+ user_location: {
339
+ type: "approximate",
340
+ country: "GB",
341
+ city: "London",
342
+ region: "London",
343
+ },
344
+ },
345
+ ],
346
+ });
347
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
348
+ // Create a conversation for the agent interaction
349
+ const conversation = await openAIClient.conversations.create();
350
+ console.log(`Created conversation (id: ${conversation.id})`);
351
+ // Send a query to search the web
352
+ console.log("\nSending web search query...");
353
+ const response = await openAIClient.responses.create(
354
+ {
355
+ conversation: conversation.id,
356
+ input: "Show me the latest London Underground service updates",
357
+ },
358
+ {
359
+ body: { agent: { name: agent.name, type: "agent_reference" } },
360
+ },
361
+ );
362
+ console.log(`Response: ${response.output_text}`);
363
+ ```
364
+
365
+ 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).
366
+
367
+ **Computer Use**
368
+
369
+ Enable agents to interact directly with computer systems for task automation and system operations:
370
+
371
+ ```ts snippet:agent-computer-use
372
+ const agent = await project.agents.createVersion("ComputerUseAgent", {
373
+ kind: "prompt" as const,
374
+ model: deploymentName,
375
+ instructions: `
376
+ You are a computer automation assistant.
377
+
378
+ Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.
379
+ `.trim(),
380
+ tools: [
381
+ {
382
+ type: "computer_use_preview",
383
+ display_width: 1026,
384
+ display_height: 769,
385
+ environment: "windows" as const,
386
+ },
387
+ ],
388
+ });
389
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
390
+ ```
391
+
392
+ *After calling `responses.create()`, process the response in an interaction loop. Handle `computer_call` output items and provide screenshots as `computer_call_output` with `computer_screenshot` type to continue the interaction.*
393
+
394
+ See the full sample code in [agentComputerUse.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentComputerUse.ts).
395
+
396
+ **Model Context Protocol (MCP)**
397
+
398
+ Integrate MCP servers to extend agent capabilities with standardized tools and resources. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-connectors-mcp)
399
+
400
+ ```ts snippet:agent-mcp
401
+ const openAIClient = await project.getOpenAIClient();
402
+ const agent = await project.agents.createVersion("agent-mcp", {
403
+ kind: "prompt",
404
+ model: deploymentName,
405
+ instructions:
406
+ "You are a helpful agent that can use MCP tools to assist users. Use the available MCP tools to answer questions and perform tasks.",
407
+ tools: [
408
+ {
409
+ type: "mcp",
410
+ server_label: "api-specs",
411
+ server_url: "https://gitmcp.io/Azure/azure-rest-api-specs",
412
+ require_approval: "always",
413
+ },
414
+ ],
415
+ });
416
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
417
+ // Create a conversation thread to maintain context across multiple interactions
418
+ console.log("\nCreating conversation...");
419
+ const conversation = await openAIClient.conversations.create();
420
+ console.log(`Created conversation (id: ${conversation.id})`);
421
+ // Send initial request that will trigger the MCP tool to access Azure REST API specs
422
+ // This will generate an approval request since requireApproval="always"
423
+ console.log("\nSending request that will trigger MCP approval...");
424
+ const response = await openAIClient.responses.create(
425
+ {
426
+ conversation: conversation.id,
427
+ input: "Please summarize the Azure REST API specifications Readme",
428
+ },
429
+ {
430
+ body: { agent: { name: agent.name, type: "agent_reference" } },
431
+ },
432
+ );
433
+ ```
434
+
435
+ *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.*
436
+
437
+ 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).
438
+
439
+ **OpenAPI**
440
+
441
+ Call external APIs defined by OpenAPI specifications without additional client-side code. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-openapi)
442
+
443
+ ```ts snippet:agent-openapi
444
+ const weatherSpecPath = path.resolve(__dirname, "../assets", "weather_openapi.json");
445
+ const agent = await project.agents.createVersion("MyOpenApiAgent", {
446
+ kind: "prompt",
447
+ model: deploymentName,
448
+ instructions:
449
+ "You are a helpful assistant that can call external APIs defined by OpenAPI specs to answer user questions.",
450
+ tools: [
451
+ {
452
+ type: "openapi",
453
+ openapi: {
454
+ name: "get_weather",
455
+ description: "Retrieve weather information for a location using wttr.in",
456
+ spec: weatherSpecPath,
457
+ auth: { type: "anonymous" },
458
+ },
459
+ },
460
+ ],
461
+ });
462
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
463
+ ```
464
+
465
+ 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).
466
+
467
+ **Function Tool**
468
+
469
+ 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)
470
+
471
+ ```ts snippet:agent-function-tool
472
+ /**
473
+ * Define a function tool for the model to use
474
+ */
475
+ const funcTool = {
476
+ type: "function" as const,
477
+ function: {
478
+ name: "get_horoscope",
479
+ description: "Get today's horoscope for an astrological sign.",
480
+ strict: true,
481
+ parameters: {
482
+ type: "object",
483
+ properties: {
484
+ sign: {
485
+ type: "string",
486
+ description: "An astrological sign like Taurus or Aquarius",
487
+ },
488
+ },
489
+ required: ["sign"],
490
+ additional_properties: false,
491
+ },
492
+ },
493
+ };
494
+ const agent = await project.agents.createVersion("function-tool-agent", {
495
+ kind: "prompt",
496
+ model: deploymentName,
497
+ instructions: "You are a helpful assistant that can use function tools.",
498
+ tools: [funcTool],
499
+ });
500
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
501
+ ```
502
+
503
+ *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.*
504
+
505
+ 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).
506
+
507
+ * **Memory Search Tool**
508
+
509
+ The Memory Store Tool adds Memory to an Agent, allowing the Agent's AI model to search for past information related to the current user prompt.
510
+
511
+ The `embeddingModelDeployment` is the name of the model used to create vector embeddings for storing and searching memories.
512
+
513
+ ```ts snippet:agent-memory-search
514
+ const memoryStoreName = "AgentMemoryStore";
515
+ const embeddingModelDeployment =
516
+ process.env["AZURE_AI_EMBEDDING_MODEL_DEPLOYMENT_NAME"] || "<embedding model>";
517
+ const scope = "user_123";
518
+ const memoryStore = await project.memoryStores.create(
519
+ memoryStoreName,
520
+ {
521
+ kind: "default",
522
+ chat_model: deploymentName,
523
+ embedding_model: embeddingModelDeployment,
524
+ options: {
525
+ user_profile_enabled: true,
526
+ chat_summary_enabled: true,
527
+ },
528
+ },
529
+ {
530
+ description: "Memory store for agent conversations",
531
+ },
532
+ );
533
+ console.log(
534
+ `Created memory store: ${memoryStore.name} (${memoryStore.id}) using chat model '${deploymentName}'`,
535
+ );
536
+ // Create an agent that will use the Memory Search tool
537
+ const agent = await project.agents.createVersion("MemorySearchAgent", {
538
+ kind: "prompt",
539
+ model: deploymentName,
540
+ instructions:
541
+ "You are a helpful assistant that remembers user preferences using the memory search tool.",
542
+ tools: [
543
+ {
544
+ type: "memory_search",
545
+ memory_store_name: memoryStore.name,
546
+ scope,
547
+ update_delay: 1, // wait briefly after conversation inactivity before updating memories
548
+ },
549
+ ],
550
+ });
551
+ ```
552
+
553
+ See the full sample code in [agentMemorySearch.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/agents/tools/agentMemorySearch.ts).
554
+
555
+ #### Connection-Based Tools
556
+
557
+ These tools require configuring connections in your AI Foundry project and use `projectConnectionId`.
558
+
559
+ **Azure AI Search**
560
+
561
+ Integrate with Azure AI Search indexes for powerful knowledge retrieval and semantic search capabilities:
562
+
563
+ ```ts snippet:agent-azure-ai-search
564
+ const aiSearchConnectionId = process.env["AI_SEARCH_CONNECTION_ID"] || "";
565
+ const aiSearchIndexName = process.env["AI_SEARCH_INDEX_NAME"] || "";
566
+ const agent = await project.agents.createVersion("MyAISearchAgent", {
567
+ kind: "prompt",
568
+ model: deploymentName,
569
+ instructions:
570
+ "You are a helpful assistant. You must always provide citations for answers using the tool and render them as: `[message_idx:search_idx†source]`.",
571
+ tools: [
572
+ {
573
+ type: "azure_ai_search",
574
+ azure_ai_search: {
575
+ indexes: [
576
+ {
577
+ project_connection_id: aiSearchConnectionId,
578
+ index_name: aiSearchIndexName,
579
+ query_type: "simple",
580
+ },
581
+ ],
582
+ },
583
+ },
584
+ ],
585
+ });
586
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
587
+ ```
588
+
589
+ 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).
590
+
591
+ **Bing Grounding**
592
+
593
+ Ground agent responses with real-time web search results from Bing to provide up-to-date information:
594
+
595
+ ```ts snippet:agent-bing-grounding
596
+ const bingProjectConnectionId = process.env["BING_GROUNDING_CONNECTION_ID"] || "";
597
+ const agent = await project.agents.createVersion("MyBingGroundingAgent", {
598
+ kind: "prompt",
599
+ model: deploymentName,
600
+ instructions: "You are a helpful assistant.",
601
+ tools: [
602
+ {
603
+ type: "bing_grounding",
604
+ bing_grounding: {
605
+ search_configurations: [
606
+ {
607
+ project_connection_id: bingProjectConnectionId,
608
+ },
609
+ ],
610
+ },
611
+ },
612
+ ],
613
+ });
614
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
615
+ ```
616
+
617
+ 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).
618
+
619
+ **Bing Custom Search**
620
+
621
+ Use custom-configured Bing search instances for domain-specific or filtered web search results:
622
+ ```ts snippet:agent-bing-custom-search
623
+ const bingCustomSearchProjectConnectionId = process.env["BING_CUSTOM_SEARCH_CONNECTION_ID"] || "";
624
+ const bingCustomSearchInstanceName = process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || "";
625
+ const agent = await project.agents.createVersion("MyAgent", {
626
+ kind: "prompt",
627
+ model: deploymentName,
628
+ instructions:
629
+ "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.",
630
+ tools: [
631
+ {
632
+ type: "bing_custom_search_preview",
633
+ bing_custom_search_preview: {
634
+ search_configurations: [
635
+ {
636
+ project_connection_id: bingCustomSearchProjectConnectionId,
637
+ instance_name: bingCustomSearchInstanceName,
638
+ },
639
+ ],
640
+ },
641
+ },
642
+ ],
643
+ });
644
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
645
+ ```
646
+
647
+ 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).
648
+
649
+ **Microsoft Fabric**
650
+
651
+ Connect to and query Microsoft Fabric:
652
+
653
+ ```ts snippet:agent-microsoft-fabric
654
+ const fabricProjectConnectionId = process.env["FABRIC_PROJECT_CONNECTION_ID"] || "";
655
+ const agent = await project.agents.createVersion("MyFabricAgent", {
656
+ kind: "prompt",
657
+ model: deploymentName,
658
+ instructions: "You are a helpful assistant.",
659
+ tools: [
660
+ {
661
+ type: "fabric_dataagent_preview",
662
+ fabric_dataagent_preview: {
663
+ project_connections: [
664
+ {
665
+ project_connection_id: fabricProjectConnectionId,
666
+ },
667
+ ],
668
+ },
669
+ },
670
+ ],
671
+ });
672
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
673
+ ```
674
+
675
+ 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).
676
+
677
+ **SharePoint**
678
+
679
+ Access and search SharePoint documents, lists, and sites for enterprise knowledge integration:
680
+
681
+ ```ts snippet:agent-sharepoint
682
+ const sharepointProjectConnectionId = process.env["SHAREPOINT_PROJECT_CONNECTION_ID"] || "";
683
+ const agent = await project.agents.createVersion("MyAgent", {
684
+ kind: "prompt",
685
+ model: deploymentName,
686
+ instructions:
687
+ "You are a helpful agent that can use SharePoint tools to assist users. Use the available SharePoint tools to answer questions and perform tasks.",
688
+ // Define SharePoint tool that searches SharePoint content
689
+ tools: [
690
+ {
691
+ type: "sharepoint_grounding_preview",
692
+ sharepoint_grounding_preview: {
693
+ project_connections: [
694
+ {
695
+ project_connection_id: sharepointProjectConnectionId,
696
+ },
697
+ ],
698
+ },
699
+ },
700
+ ],
701
+ });
702
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
703
+ ```
704
+
705
+ 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).
706
+
707
+ **Browser Automation**
708
+
709
+ Automate browser interactions for web scraping, testing, and interaction with web applications:
710
+
711
+ ```ts snippet:agent-browser-automation
712
+ const browserAutomationProjectConnectionId = process.env["BROWSER_AUTOMATION_CONNECTION_ID"] || "";
713
+ const agent = await project.agents.createVersion("MyAgent", {
714
+ kind: "prompt",
715
+ model: deploymentName,
716
+ instructions: `You are an Agent helping with browser automation tasks.
717
+ You can answer questions, provide information, and assist with various tasks
718
+ related to web browsing using the Browser Automation tool available to you.`,
719
+ // Define Browser Automation tool
720
+ tools: [
721
+ {
722
+ type: "browser_automation_preview",
723
+ browser_automation_preview: {
724
+ connection: {
725
+ project_connection_id: browserAutomationProjectConnectionId,
726
+ },
727
+ },
728
+ },
729
+ ],
730
+ });
731
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
732
+ ```
733
+
734
+ 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).
735
+
736
+ **MCP with Project Connection**
737
+
738
+ MCP integration using project-specific connections for accessing connected MCP servers:
739
+
740
+ ```ts snippet:agent-mcp-connection
741
+ const mcpProjectConnectionId = process.env["MCP_PROJECT_CONNECTION_ID"] || "";
742
+ const agent = await project.agents.createVersion("agent-mcp-connection-auth", {
743
+ kind: "prompt",
744
+ model: deploymentName,
745
+ instructions: "Use MCP tools as needed",
746
+ tools: [
747
+ {
748
+ type: "mcp",
749
+ server_label: "api-specs",
750
+ server_url: "https://api.githubcopilot.com/mcp",
751
+ require_approval: "always",
752
+ project_connection_id: mcpProjectConnectionId,
753
+ },
754
+ ],
755
+ });
756
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
757
+ ```
758
+
759
+ 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).
760
+
761
+ **Agent-to-Agent (A2A)**
762
+
763
+ Enable multi-agent collaboration where agents can communicate and delegate tasks to other specialized agents:
764
+
765
+ ```ts snippet:agent-a2a
766
+ const a2aProjectConnectionId = process.env["A2A_PROJECT_CONNECTION_ID"] || "";
767
+ const agent = await project.agents.createVersion("MyA2AAgent", {
768
+ kind: "prompt",
769
+ model: deploymentName,
770
+ instructions: "You are a helpful assistant.",
771
+ // Define A2A tool for agent-to-agent communication
772
+ tools: [
773
+ {
774
+ type: "a2a_preview",
775
+ project_connection_id: a2aProjectConnectionId,
776
+ },
777
+ ],
778
+ });
779
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
780
+ ```
781
+
782
+ 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).
783
+
784
+ **OpenAPI with Project Connection**
785
+
786
+ Call external APIs defined by OpenAPI specifications using project connection authentication:
787
+
788
+ ```ts snippet:agent-openapi-connection
789
+ const tripAdvisorProjectConnectionId = process.env["TRIPADVISOR_PROJECT_CONNECTION_ID"] || "";
790
+ function loadOpenApiSpec(specPath: string): unknown {
791
+ if (!fs.existsSync(specPath)) {
792
+ throw new Error(`OpenAPI specification not found at: ${specPath}`);
793
+ }
794
+ try {
795
+ const data = fs.readFileSync(specPath, "utf-8");
796
+ return JSON.parse(data);
797
+ } catch (error) {
798
+ throw new Error(`Failed to read or parse OpenAPI specification at ${specPath}: ${error}`);
799
+ }
800
+ }
801
+ const tripAdvisorSpecPath = path.resolve(__dirname, "../assets", "tripadvisor_openapi.json");
802
+ const tripAdvisorSpec = loadOpenApiSpec(tripAdvisorSpecPath);
803
+ const agent = await project.agents.createVersion("MyOpenApiConnectionAgent", {
804
+ kind: "prompt",
805
+ model: deploymentName,
806
+ instructions:
807
+ "You are a travel assistant that consults the TripAdvisor Content API via project connection to answer user questions about locations.",
808
+ tools: [
809
+ {
810
+ type: "openapi",
811
+ openapi: {
812
+ name: "get_tripadvisor_location_details",
813
+ description:
814
+ "Fetch TripAdvisor location details, reviews, or photos using the Content API via project connection auth.",
815
+ spec: tripAdvisorSpec,
816
+ auth: {
817
+ type: "project_connection",
818
+ security_scheme: {
819
+ project_connection_id: tripAdvisorProjectConnectionId,
820
+ },
821
+ },
822
+ },
823
+ },
824
+ ],
825
+ });
826
+ console.log(`Agent created (id: ${agent.id}, name: ${agent.name}, version: ${agent.version})`);
827
+ ```
828
+
829
+ 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).
830
+
831
+ 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).
832
+
833
+ ### Evaluation
834
+
835
+ Evaluation in Azure AI Project client library provides quantitative, AI-assisted quality and safety metrics to asses performance and Evaluate LLM Models, GenAI Application and Agents. Metrics are defined as evaluators. Built-in or custom evaluators can provide comprehensive evaluation insights.
836
+
837
+ The code below shows some evaluation operations. Full list of sample can be found under "evaluations" folder in the [package samples][samples]
838
+
839
+
840
+ ```ts snippet:evaluations
841
+ const openAIClient = await project.getOpenAIClient();
842
+ const dataSourceConfig = {
843
+ type: "custom" as const,
844
+ item_schema: {
845
+ type: "object",
846
+ properties: { query: { type: "string" } },
847
+ required: ["query"],
848
+ },
849
+ include_sample_schema: true,
850
+ };
851
+ const evalObject = await openAIClient.evals.create({
852
+ name: "Agent Evaluation",
853
+ data_source_config: dataSourceConfig,
854
+ testing_criteria: [
855
+ {
856
+ type: "azure_ai_evaluator",
857
+ name: "violence_detection",
858
+ evaluator_name: "builtin.violence",
859
+ data_mapping: { query: "{{item.query}}", response: "{{item.response}}" },
860
+ } as any,
861
+ ],
862
+ });
863
+ console.log(`Evaluation created (id: ${evalObject.id}, name: ${evalObject.name})`);
864
+ ```
865
+
866
+ See the full sample code in [agentEvaluation.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/evaluations/agentEvaluation.ts).
867
+
161
868
  ### Deployments operations
162
869
 
163
870
  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].
@@ -310,7 +1017,7 @@ console.log("Get an existing Dataset version `1`:");
310
1017
  const datasetVersion1 = await project.datasets.get(datasetName, VERSION1);
311
1018
  console.log("Dataset version 1:", JSON.stringify(datasetVersion1, null, 2));
312
1019
  console.log(`Listing all versions of the Dataset named '${datasetName}':`);
313
- const datasetVersions = await project.datasets.listVersions(datasetName);
1020
+ const datasetVersions = project.datasets.listVersions(datasetName);
314
1021
  for await (const version of datasetVersions) {
315
1022
  console.log("List versions:", version);
316
1023
  }
@@ -402,12 +1109,84 @@ for await (const i of allIndexes) {
402
1109
  console.log("Delete the Index versions created above:");
403
1110
  await project.indexes.delete(indexName, version);
404
1111
  ```
1112
+
1113
+ ### Fine-tuning operations
1114
+
1115
+ The code below shows how to create fine-tuning jobs using the OpenAI client. These operations support various fine-tuning techniques like Supervised Fine-Tuning (SFT), Reinforcement Fine-Tuning (RFT), and Direct Performance Optimization (DPO). Full samples can be found under the "finetuning" folder in the [package samples][samples].
1116
+
1117
+ ```ts snippet:finetuning
1118
+ import { JobCreateParams } from "openai/resources/fine-tuning/jobs";
1119
+
1120
+ const trainingFilePath = "training_data_path.jsonl";
1121
+ const validationFilePath = "validation_data_path.jsonl";
1122
+ const openAIClient = await project.getOpenAIClient();
1123
+ // 1) Create the training and validation files
1124
+ const trainingFile = await openAIClient.files.create({
1125
+ file: fs.createReadStream(trainingFilePath),
1126
+ purpose: "fine-tune",
1127
+ });
1128
+ console.log(`Uploaded file with ID: ${trainingFile.id}`);
1129
+ const validationFile = await openAIClient.files.create({
1130
+ file: fs.createReadStream(validationFilePath),
1131
+ purpose: "fine-tune",
1132
+ });
1133
+ console.log(`Uploaded file with ID: ${validationFile.id}`);
1134
+ // 2) Wait for the files to be processed
1135
+ await openAIClient.files.waitForProcessing(trainingFile.id);
1136
+ await openAIClient.files.waitForProcessing(validationFile.id);
1137
+ console.log("Files processed.");
1138
+ // 3) Create a supervised fine-tuning job
1139
+ const fineTuningJob = await openAIClient.fineTuning.jobs.create({} as JobCreateParams, {
1140
+ body: {
1141
+ trainingType: "Standard",
1142
+ training_file: trainingFile.id,
1143
+ validation_file: validationFile.id,
1144
+ model: deploymentName,
1145
+ method: {
1146
+ type: "supervised",
1147
+ supervised: {
1148
+ hyperparameters: {
1149
+ n_epochs: 3,
1150
+ batch_size: 1,
1151
+ learning_rate_multiplier: 1.0,
1152
+ },
1153
+ },
1154
+ },
1155
+ },
1156
+ });
1157
+ console.log("Created fine-tuning job:\n", JSON.stringify(fineTuningJob));
1158
+ ```
1159
+
405
1160
  ## Tracing
406
1161
 
407
1162
  **Note:** Tracing functionality is in preliminary preview and is subject to change. Spans, attributes, and events may be modified in future versions.
408
1163
 
409
1164
  You can add an Application Insights Azure resource to your Microsoft Foundry project. See the Tracing tab in your Microsoft Foundry project. If one was enabled, you can get the Application Insights connection string, configure your AI Projects client, and observe the full execution path through Azure Monitor. Typically, you might want to start tracing before you create a client or Agent.
410
1165
 
1166
+ ### Installation
1167
+
1168
+ ```bash
1169
+ npm install @azure/monitor-opentelemetry@^1.14.2 @opentelemetry/api@^1.9.0
1170
+ ```
1171
+
1172
+ ### How to enable tracing
1173
+
1174
+ Here is a code sample that shows how to enable Azure Monitor tracing:
1175
+
1176
+ ```ts snippet:tracing
1177
+ import { AzureMonitorOpenTelemetryOptions, useAzureMonitor } from "@azure/monitor-opentelemetry";
1178
+
1179
+ const TELEMETRY_CONNECTION_STRING = process.env["TELEMETRY_CONNECTION_STRING"];
1180
+ const options: AzureMonitorOpenTelemetryOptions = {
1181
+ azureMonitorExporterOptions: {
1182
+ connectionString: TELEMETRY_CONNECTION_STRING,
1183
+ },
1184
+ };
1185
+ useAzureMonitor(options);
1186
+ ```
1187
+
1188
+ See the full sample code in [remoteTelemetry.ts](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples-dev/telemetry/remoteTelemetry.ts).
1189
+
411
1190
  ## Troubleshooting
412
1191
 
413
1192
  ### Exceptions