Skip to main content
In this lesson we cover tools — a core LangChain concept that extends a large language model’s capabilities by connecting it to external functions, services, and APIs. Tools let your LLM access real-world data sources (APIs, databases, internal services) and perform actions (I/O, computation, side effects), enabling richer, production-ready AI workflows.
The image displays a section labeled "Tools" with icons for "Functions," "Services," and "API" beneath it.
LangChain ships with many ready-made tools for popular services such as Wikipedia, YouTube, and Google Search. Use these built-ins to quickly add search and knowledge retrieval to your agents without building integrations from scratch.
The image shows the LangChain logo alongside icons for Wikipedia, YouTube, and Google Search, labeled as tools.
For private systems or custom workflows, implement a custom tool. A typical tool:
  • Accepts text or structured arguments,
  • Calls an external API, queries a database, or runs application logic,
  • Returns text or structured data (JSON, lists, etc.) that the LLM can consume.
Below is a minimal example showing the decorator-based pattern for creating a simple custom tool in Python. This pattern wraps your function so it can be invoked by LangChain agents and pipelines:
The image is a flow diagram titled "Tools," showing a process from a "User" to "Text," then processed by a "Custom Tool," leading to an "Output."
Tool behavior and usage notes
Use built-in tools for common services (e.g., Wikipedia, YouTube, Google Search). For proprietary data or specialized workflows, create a custom tool and publish it in a toolkit so multiple pipelines and agents can reuse it.
When tools perform actions (modify data, call external APIs, or trigger side effects), validate and sanitize all inputs and outputs. Apply least-privilege access, input validation, and rate-limiting to reduce security and stability risks.
Summary Tools are the mechanism by which LangChain connects LLMs to external data and capabilities. They range from simple adapters for well-known services to fully custom integrations for private systems. By grouping tools into toolkits and using them within pipelines and agents, you can assemble modular, maintainable, and secure AI workflows. Further reading and references:

Watch Video