langchain_azure_ai.tools. See also the tools provided as part of Microsoft Foundry Tools (formerly Azure AI Services).
Use these tools when you want agents to call capabilities in tools provided by Microsoft Foundry projects.
Overview
Setup
Install dependencies, create the resources used by the tools, and provide credentials.Installation
Install the integration package:Credentials
Pass eitherDefaultAzureCredential() or an API-key string through the credential argument (except for AzureAIProjectToolbox which doesn’t support keys.)
Initialize credential
Azure AI User for the resources where the models are deployed.
Configure endpoints
The tools support two endpoint styles:- An Azure AI Foundry project endpoint via
project_endpointorAZURE_AI_PROJECT_ENDPOINT(orFOUNDRY_PROJECT_ENDPOINT). - A direct OpenAI-compatible endpoint via
endpointorOPENAI_BASE_URL, for examplehttps://<resource>.services.ai.azure.com/openai/v1.
project_endpoint because it resolves the backing service endpoint automatically for Foundry-based workflows.
Configure endpoint
Tools
AzureOpenAIModelImageGenTool
AzureOpenAIModelImageGenTool (from langchain_azure_ai.tools) generates images using OpenAI-compatible image generation endpoints exposed by Microsoft Foundry Models or Azure OpenAI. You can use models including gpt-image-1.5 or MAI-Image-2.
Use this tool when you want explicit tool invocation for image generation in an agent flow. The tool calls the OpenAI client images.generate API and returns either base64 PNG output or saved file paths when output_directory is configured.
You must deploy an image generation model first, then pass the deployment name in model.
Configuration options
Configuration options
str
The Foundry project where the image model is deployed. Using this parameter requires using Microsoft Entra ID.
str
The OpenAI-compatible endpoint where the route
/images/generations is present.str | TokenCredential
The credentials to use, either keys or token credentials.
str
Text prompt describing the image to generate.
int
default:"1"
Number of images to generate.
str | None
default:"1024x1024"
Output image size (for example
1024x1024, 1024x1792, or 1792x1024, model-dependent).str | None
Optional quality parameter passed to the image-generation model (for example
hd, model-dependent).str | None
Optional style parameter such as
vivid or natural (model-dependent).str
Required deployment name of the image generation model to use. Create this deployment in Microsoft Foundry before using the tool. Any OpenAI-compatible model can be used (for example, MAI-Image-2).
str | None
If set, generated images are saved as PNG files and the tool returns saved file paths. If omitted, the tool returns base64 PNG data.
AzureOpenAITranscriptionsTool
AzureOpenAITranscriptionsTool (from langchain_azure_ai.tools) transcribes audio to text using OpenAI-compatible speech-to-text endpoints exposed by Microsoft Foundry Models or Azure OpenAI (such as Whisper).
Use this tool when you want to convert audio files or remote audio URLs into text transcriptions within an agent flow. The tool handles both local files and remote URLs automatically, supporting multiple audio formats (MP3, MP4, MPEG, MPGA, M4A, OGG, FLAC, WAV).
You must deploy a speech-to-text model first, then pass the deployment name in model.
Configuration options
Configuration options
str
The Foundry project where the speech-to-text model is deployed. Using this parameter requires using Microsoft Entra ID.
str
The OpenAI-compatible endpoint where the route
/audio/transcriptions is present.str | TokenCredential
The credentials to use, either keys or token credentials.
str
Path to a local audio file or a URL pointing to an audio file.
str | None
Optional language code in ISO-639-1 format (e.g.,
"en", "es", "fr"). If not specified, the language will be auto-detected by the model.str
Required deployment name of the speech-to-text model to use. Create this deployment in Microsoft Foundry before using the tool.
CodeInterpreterTool
CodeInterpreterTool allows the model to write and execute Python code within a sandboxed container and include the results in its response. This is useful for data analysis, mathematical computations, visualization, and general problem-solving.
Configuration options
Configuration options
WebSearchTool
WebSearchTool allows the model to search the internet for current information and sources related to its queries. This is useful for providing up-to-date information, research, fact-checking, and accessing real-time data.
Configuration options
Configuration options
'low' | 'medium' | 'high' | None
High-level guidance for the amount of context window space to use for the search results. Defaults to
"medium".dict | None
Approximate location of the user. Can include optional keys:
city, country (ISO-3166 two-letter code), region, timezone (IANA), and type="approximate".dict | None
Search filters. Can include an optional
allowed_domains list to restrict results to specific domains.FileSearchTool
FileSearchTool searches for relevant content from uploaded vector stores. This is useful for retrieving information from large document collections, knowledge bases, and custom data sources that have been indexed in vector stores.
Configuration options
Configuration options
list[str]
required
IDs of the vector stores to search. At least one ID must be provided.
int | None
Maximum number of results to return (1-50). Defaults to a reasonable number.
dict | None
Optional metadata filter to narrow results using comparison or compound filters.
dict | None
Ranking options. Can include optional keys
ranker and score_threshold to control result ranking.ImageGenerationTool
ImageGenerationTool allows the model to generate or edit images using GPT image models. This is useful for creating visuals, editing images, and generating artwork based on text descriptions. This tool must be used with an OpenAI model deployed in a Microsoft Foundry project. If you are using another model, use AzureOpenAIModelImageGenTool instead.
Configuration options
Configuration options
str | None
Deployment name of the image generation model in Azure AI Foundry. When set, the tool automatically injects the
x-ms-oai-image-generation-deployment HTTP request header.'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | None
Image generation model to use.
'generate' | 'edit' | 'auto' | None
Whether to generate a new image or edit an existing one. Defaults to
"auto".'low' | 'medium' | 'high' | 'auto' | None
Image quality. Defaults to
"auto".'1024x1024' | '1024x1536' | '1536x1024' | 'auto' | None
Image size. Defaults to
"auto".'png' | 'webp' | 'jpeg' | None
Output format. Defaults to
"png".'transparent' | 'opaque' | 'auto' | None
Background type for image generation.
str | None
How closely the output should match style and facial features of input images. One of
"high" or "low".dict | None
Mask for inpainting operations.
'auto' | 'low' | None
Moderation level. Defaults to
"auto".int | None
Compression level (0-100, default 100).
int | None
Number of partial images to stream (0-3).
McpTool
McpTool gives the model access to an external Model Context Protocol (MCP) server. This allows the model to call tools exposed by remote MCP servers within a single conversational turn, enabling integration with custom services and external systems.
Configuration options
Configuration options
str
required
A label for this MCP server, used to identify it in tool calls.
str | None
The URL for the MCP server. Either
server_url or connector_id must be provided.str | None
Identifier for a built-in service connector (e.g.,
"connector_gmail"). Either server_url or connector_id must be provided.list[str] | dict | None
List of tool names, or a tool filter dict, that the model is allowed to call on this server.
dict[str, str] | None
Optional HTTP headers to send with every request to the MCP server (e.g., for authentication).
'always' | 'never' | dict | None
Whether tool calls require human approval before execution.
str | None
Optional description of the MCP server for the model.
str | None
OAuth access token for the MCP server.
Toolboxes
Setup
Install required dependencies:AzureAIProjectToolbox
AzureAIProjectToolbox (from langchain_azure_ai.tools) loads tools from an Azure AI Foundry Toolbox and makes them available via the Model Context Protocol (MCP).
Azure AI Foundry Toolbox is a managed multi-MCP server that aggregates multiple configured tools behind a single MCP endpoint. Use this when you want to dynamically load and use a collection of tools from your Azure AI Foundry project in an agent.
The toolbox automatically handles:
- Azure Identity Bearer-token authentication
- Graceful OAuth consent-error handling: returns a fallback tool with the consent URL instead of raising
- Automatic tool-schema sanitization for MCP servers that emit incomplete JSON schemas
Configuration parameters
Configuration parameters
str
Azure AI Foundry project endpoint, e.g.,
https://<resource>.services.ai.azure.com/api/projects/<project>. Falls back to AZURE_AI_PROJECT_ENDPOINT or FOUNDRY_PROJECT_ENDPOINT environment variables.str
Name of the toolbox as configured in Azure AI Foundry. This parameter is required.
str
default:"v1"
Toolbox API version appended to the MCP URL.
str | TokenCredential
Azure credential for Bearer-token authentication. Accepts a string (static Bearer token) or any
TokenCredential such as DefaultAzureCredential. Defaults to DefaultAzureCredential().dict[str, str]
Additional HTTP headers to include in MCP requests. The
Foundry-Features header is automatically added with the default value unless already present.Basic usage
toolbox_name):
Using async context manager
async with is supported for ergonomic compatibility:
Integration with agents
Theget_tools() method returns a list of BaseTool instances ready for use with any LangChain agent pattern:
Agent with AzureAIProjectToolbox
API reference
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

