Edit

Share via


MicrosoftExtensionsAIResponsesExtensions.AsAITool(ResponseTool) Method

Definition

Creates an AITool to represent a raw ResponseTool.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::AI::AITool ^ AsAITool(OpenAI::Responses::ResponseTool ^ tool);
public static Microsoft.Extensions.AI.AITool AsAITool(this OpenAI.Responses.ResponseTool tool);
static member AsAITool : OpenAI.Responses.ResponseTool -> Microsoft.Extensions.AI.AITool
<Extension()>
Public Function AsAITool (tool As ResponseTool) As AITool

Parameters

tool
ResponseTool

The tool to wrap as an AITool.

Returns

The tool wrapped as an AITool.

Remarks

The returned tool is only suitable for use with the IChatClient returned by AsIChatClient(OpenAIResponseClient) (or IChatClients that delegate to such an instance). It is likely to be ignored by any other IChatClient implementation.

When a tool has a corresponding AITool-derived type already defined in Microsoft.Extensions.AI, such as AIFunction, HostedWebSearchTool, HostedMcpServerTool, or HostedFileSearchTool, those types should be preferred instead of this method, as they are more portable, capable of being respected by any IChatClient implementation. This method does not attempt to map the supplied ResponseTool to any of those types, it simply wraps it as-is: the IChatClient returned by AsIChatClient(OpenAIResponseClient) will be able to unwrap the ResponseTool when it processes the list of tools.

Applies to