# PromptAgentBuilderExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Foundry](/reference/api/csharp/aspire.hosting.foundry.md)
- Version: `13.4.0-preview.1.26281.18`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Foundry/PromptAgent/PromptAgentBuilderExtensions.cs)

Extension methods for adding Microsoft Foundry prompt agents and tools to the distributed application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class PromptAgentBuilderExtensions
{
    // ...
}
```

## Methods

- [AddAISearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string?)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addaisearchtool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string) : `IResourceBuilder<AzureAISearchToolResource>` `extension` `ats export` -- Adds an Azure AI Search tool to a Microsoft Foundry project, enabling agents to ground their responses using data from an Azure AI Search index.
- [AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, BinaryData, string, string, string, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addazurefunctiontool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string-string-binarydata-string-string-string-string) : `IResourceBuilder<AzureFunctionToolResource>` `extension` `ats ignored` -- Adds an Azure Function tool to a Microsoft Foundry project, enabling agents to invoke a serverless Azure Function with queue-based input/output bindings.
- [AddAzureFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, string, string, string, string, string, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addazurefunctiontool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string-string-string-string-string-string-string) : `IResourceBuilder<AzureFunctionToolResource>` `extension` `ats export` -- Adds an Azure Function tool to a Microsoft Foundry project, enabling agents to invoke a serverless Azure Function with queue-based input/output bindings.
- [AddBingGroundingTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addbinggroundingtool-iresourcebuilder-azurecognitiveservicesprojectresource-string) : `IResourceBuilder<BingGroundingToolResource>` `extension` `ats export` -- Adds a Bing Grounding tool to a Microsoft Foundry project, enabling agents to ground their responses using Bing Search results.
- [AddCodeInterpreterTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addcodeinterpretertool-iresourcebuilder-azurecognitiveservicesprojectresource-string) : `IResourceBuilder<CodeInterpreterToolResource>` `extension` `ats export` -- Adds a Code Interpreter tool to a Microsoft Foundry project, enabling agents to write and run Python code in a sandboxed environment for data analysis, math, and chart generation.
- [AddComputerUseTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, int, int, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addcomputerusetool-iresourcebuilder-azurecognitiveservicesprojectresource-string-int-int-string) : `IResourceBuilder<ComputerToolResource>` `extension` `ats export` -- Adds a Computer Use tool to a Microsoft Foundry project, enabling agents to interact with a computer desktop by taking screenshots, moving the mouse, clicking, and typing.
- [AddFabricTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[])](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addfabrictool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string) : `IResourceBuilder<FabricToolResource>` `extension` `ats export` -- Adds a Microsoft Fabric data agent tool to a Microsoft Foundry project, enabling agents to query data through Fabric data agents.
- [AddFileSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[])](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addfilesearchtool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string) : `IResourceBuilder<FileSearchToolResource>` `extension` `ats export` -- Adds a File Search tool to a Microsoft Foundry project, enabling agents to search uploaded files and proprietary documents using vector search.
- [AddFunctionTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string, BinaryData, string?, bool?)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addfunctiontool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string-binarydata-string-bool) : `IResourceBuilder<FunctionToolResource>` `extension` `ats ignored` -- Adds a function calling tool to a Microsoft Foundry project, enabling agents to call application-defined functions with structured parameters.
- [AddImageGenerationTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addimagegenerationtool-iresourcebuilder-azurecognitiveservicesprojectresource-string) : `IResourceBuilder<ImageGenerationToolResource>` `extension` `ats export` -- Adds an Image Generation tool to a Microsoft Foundry project, enabling agents to generate and edit images.
- [AddPromptAgent(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, IResourceBuilder<FoundryDeploymentResource>, string?)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addpromptagent-iresourcebuilder-azurecognitiveservicesprojectresource-string-iresourcebuilder-foundrydeploymentresource-string) : `IResourceBuilder<AzurePromptAgentResource>` `extension` `ats export` -- Adds a prompt agent to a Microsoft Foundry project with the specified tools.
- [AddSharePointTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string, string[])](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addsharepointtool-iresourcebuilder-azurecognitiveservicesprojectresource-string-string) : `IResourceBuilder<SharePointToolResource>` `extension` `ats export` -- Adds a SharePoint grounding tool to a Microsoft Foundry project, enabling agents to search data from SharePoint sites configured as Foundry project connections.
- [AddWebSearchTool(IResourceBuilder<AzureCognitiveServicesProjectResource>, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#addwebsearchtool-iresourcebuilder-azurecognitiveservicesprojectresource-string) : `IResourceBuilder<WebSearchToolResource>` `extension` `ats export` -- Adds a Web Search tool to a Microsoft Foundry project, enabling agents to retrieve real-time information from the public web and return answers with inline citations.
- [WithCustomTool(IResourceBuilder<AzurePromptAgentResource>, IFoundryTool)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withcustomtool-iresourcebuilder-azurepromptagentresource-ifoundrytool) : `IResourceBuilder<AzurePromptAgentResource>` `extension` `ats ignored` -- Adds a custom tool implementation to a prompt agent using the [IFoundryTool](/reference/api/csharp/aspire.hosting.foundry/ifoundrytool.md) interface.
- [WithReference(IResourceBuilder<AzureAISearchToolResource>, IResourceBuilder<AzureSearchResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-azureaisearchtoolresource-iresourcebuilder-azuresearchresource) : `IResourceBuilder<AzureAISearchToolResource>` `extension` `ats export` -- Links an Azure AI Search tool to a backing `Azure.AzureSearchResource`, creating the necessary Foundry project connection and role assignments.
- [WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<BingGroundingConnectionResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-binggroundingtoolresource-iresourcebuilder-binggroundingconnectionresource) : `IResourceBuilder<BingGroundingToolResource>` `extension` `ats ignored` -- Links a Bing Grounding tool to a Foundry project connection for the Bing Search service.
- [WithReference(IResourceBuilder<BingGroundingToolResource>, string)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-binggroundingtoolresource-string) : `IResourceBuilder<BingGroundingToolResource>` `extension` `ats ignored` -- Links a Bing Grounding tool to a Bing Search resource by using its Azure resource ID.
- [WithReference(IResourceBuilder<BingGroundingToolResource>, IResourceBuilder<ParameterResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withreference-iresourcebuilder-binggroundingtoolresource-iresourcebuilder-parameterresource) : `IResourceBuilder<BingGroundingToolResource>` `extension` `ats ignored` -- Links a Bing Grounding tool to a Bing Search resource by using a parameter that contains its Azure resource ID.
- [WithTool(IResourceBuilder<AzurePromptAgentResource>, IResourceBuilder<FoundryToolResource>)](/reference/api/csharp/aspire.hosting.foundry/promptagentbuilderextensions/methods.md#withtool-iresourcebuilder-azurepromptagentresource-iresourcebuilder-foundrytoolresource) : `IResourceBuilder<AzurePromptAgentResource>` `extension` `ats export` -- Adds a tool to a prompt agent.
