Third-Party Tools
Pydantic AI supports integration with various third-party tool libraries, allowing you to leverage existing tool ecosystems in your agents.
MCP Tools
See the MCP Client documentation for how to use MCP servers with Pydantic AI as toolsets.
LangChain Tools
If you'd like to use a tool from LangChain's community tool library with Pydantic AI, you can use the tool_from_langchain
convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the LangChain tool, and up to the LangChain tool to raise an error if the arguments are invalid.
You will need to install the langchain-community
package and any others required by the tool in question.
Here is how you can use the LangChain DuckDuckGoSearchRun
tool, which requires the ddgs
package:
from langchain_community.tools import DuckDuckGoSearchRun
from pydantic_ai import Agent
from pydantic_ai.ext.langchain import tool_from_langchain
search = DuckDuckGoSearchRun()
search_tool = tool_from_langchain(search)
agent = Agent(
'google-gla:gemini-2.0-flash',
tools=[search_tool],
)
result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (1)!
print(result.output)
#> Elden Ring Nightreign is planned to be released on May 30, 2025.
- The release date of this game is the 30th of May 2025, which is after the knowledge cutoff for Gemini 2.0 (August 2024).
If you'd like to use multiple LangChain tools or a LangChain toolkit, you can use the LangChainToolset
toolset which takes a list of LangChain tools:
from langchain_community.agent_toolkits import SlackToolkit
from pydantic_ai import Agent
from pydantic_ai.ext.langchain import LangChainToolset
toolkit = SlackToolkit()
toolset = LangChainToolset(toolkit.get_tools())
agent = Agent('openai:gpt-4o', toolsets=[toolset])
# ...
ACI.dev Tools
If you'd like to use a tool from the ACI.dev tool library with Pydantic AI, you can use the tool_from_aci
convenience method. Note that Pydantic AI will not validate the arguments in this case -- it's up to the model to provide arguments matching the schema specified by the ACI tool, and up to the ACI tool to raise an error if the arguments are invalid.
You will need to install the aci-sdk
package, set your ACI API key in the ACI_API_KEY
environment variable, and pass your ACI "linked account owner ID" to the function.
Here is how you can use the ACI.dev TAVILY__SEARCH
tool:
import os
from pydantic_ai import Agent
from pydantic_ai.ext.aci import tool_from_aci
tavily_search = tool_from_aci(
'TAVILY__SEARCH',
linked_account_owner_id=os.getenv('LINKED_ACCOUNT_OWNER_ID'),
)
agent = Agent(
'google-gla:gemini-2.0-flash',
tools=[tavily_search],
)
result = agent.run_sync('What is the release date of Elden Ring Nightreign?') # (1)!
print(result.output)
#> Elden Ring Nightreign is planned to be released on May 30, 2025.
- The release date of this game is the 30th of May 2025, which is after the knowledge cutoff for Gemini 2.0 (August 2024).
If you'd like to use multiple ACI.dev tools, you can use the ACIToolset
toolset which takes a list of ACI tool names as well as the linked_account_owner_id
:
import os
from pydantic_ai import Agent
from pydantic_ai.ext.aci import ACIToolset
toolset = ACIToolset(
[
'OPEN_WEATHER_MAP__CURRENT_WEATHER',
'OPEN_WEATHER_MAP__FORECAST',
],
linked_account_owner_id=os.getenv('LINKED_ACCOUNT_OWNER_ID'),
)
agent = Agent('openai:gpt-4o', toolsets=[toolset])
See Also
- Function Tools - Basic tool concepts and registration
- Toolsets - Managing collections of tools
- MCP Client - Using MCP servers with Pydantic AI
- LangChain Toolsets - Using LangChain toolsets
- ACI.dev Toolsets - Using ACI.dev toolsets