> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tools

> Explains LangChain tools that connect LLMs to external APIs and services, built-in and custom tool creation, usage patterns, security practices, and organizing tools into reusable toolkits

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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/Xqjckn2TzkOV2Gz2/images/LangChain/Key-Components-of-LangChain/Tools/tools-functions-services-api-icons.jpg?fit=max&auto=format&n=Xqjckn2TzkOV2Gz2&q=85&s=8d95731b014aa937f71dd284a706301b" alt="The image displays a section labeled &#x22;Tools&#x22; with icons for &#x22;Functions,&#x22; &#x22;Services,&#x22; and &#x22;API&#x22; beneath it." width="1920" height="1080" data-path="images/LangChain/Key-Components-of-LangChain/Tools/tools-functions-services-api-icons.jpg" />
</Frame>

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.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/Xqjckn2TzkOV2Gz2/images/LangChain/Key-Components-of-LangChain/Tools/langchain-logo-wikipedia-youtube-google-tools.jpg?fit=max&auto=format&n=Xqjckn2TzkOV2Gz2&q=85&s=66718b08ee1795e743864aee396f30bc" alt="The image shows the LangChain logo alongside icons for Wikipedia, YouTube, and Google Search, labeled as tools." width="1920" height="1080" data-path="images/LangChain/Key-Components-of-LangChain/Tools/langchain-logo-wikipedia-youtube-google-tools.jpg" />
</Frame>

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:

```python theme={null}
# Example: simple custom tool using LangChain's decorator pattern
from langchain.tools import tool

@tool
def get_internal_user_profile(user_id: str) -> str:
    """Fetch a user profile from an internal API and return a summary string."""
    # Replace this with your HTTP/db call or application logic
    profile = call_internal_api(user_id)  # implement call_internal_api(...)
    return f"User {profile['id']}: {profile['name']} — {profile['role']}"
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/Xqjckn2TzkOV2Gz2/images/LangChain/Key-Components-of-LangChain/Tools/tools-flow-diagram-user-text-output.jpg?fit=max&auto=format&n=Xqjckn2TzkOV2Gz2&q=85&s=cb7bfd775f7858af0220a4455ce86ba1" alt="The image is a flow diagram titled &#x22;Tools,&#x22; showing a process from a &#x22;User&#x22; to &#x22;Text,&#x22; then processed by a &#x22;Custom Tool,&#x22; leading to an &#x22;Output.&#x22;" width="1920" height="1080" data-path="images/LangChain/Key-Components-of-LangChain/Tools/tools-flow-diagram-user-text-output.jpg" />
</Frame>

Tool behavior and usage notes

| Aspect             | What it means                                                                                                      | Best practice                                                                          |
| ------------------ | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| Inputs & outputs   | Tools accept text prompts or structured arguments and return text, JSON, or other structured data                  | Normalize I/O formats and document the tool's contract (input types, expected outputs) |
| Integration points | Tools are invoked inside pipelines, agents, or higher-level workflows to augment the LLM with live data or actions | Keep tool responsibilities focused and side effects explicit                           |
| Toolkits           | Collections of related tools grouped together for a single purpose (e.g., search, user management)                 | Package related tools into toolkits for easier reuse and permissioning                 |
| Extensibility      | LangChain provides many built-in toolkits; you can also create custom tools for private systems                    | Prefer built-ins when they meet requirements; add custom tools only when needed        |

<Callout icon="lightbulb" color="#1CB2FE">
  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.
</Callout>

<Callout icon="warning" color="#FF6B6B">
  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.
</Callout>

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:

* LangChain documentation: [https://python.langchain.com/](https://python.langchain.com/)
* Wikipedia: [https://www.wikipedia.org](https://www.wikipedia.org)
* YouTube: [https://www.youtube.com](https://www.youtube.com)
* Google Search: [https://www.google.com](https://www.google.com)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/langchain/module/5bedac05-3eaa-4d0d-9892-e05b80c528fb/lesson/f956bded-e65d-4693-b89d-31cb29adb543" />
</CardGroup>
