# Can a Python class object be used for a custom tool?

**URL:** <https://community.crewai.com/t/can-a-python-class-object-be-used-for-a-custom-tool/1858>\
**Category:** General\
**Tags:** tools\_issues, agent\
**Created:** [December 5, 2024, 7:20pm UTC](https://community.crewai.com/t/can-a-python-class-object-be-used-for-a-custom-tool/1858 "2024-12-05T19:20:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Rocha](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/jorge_rocha/32/1341_2.png) [@Jorge\_Rocha](https://community.crewai.com/u/Jorge_Rocha)\
**Post date:** [December 5, 2024, 7:20pm UTC](https://community.crewai.com/t/can-a-python-class-object-be-used-for-a-custom-tool/1858/1 "2024-12-05T19:20:17Z")

</div>

![image](https://us1.discourse-cdn.com/flex025/uploads/crewai/original/2X/9/935308694d64157fadebbf1324988c5c3641c49b.png)  
I’m working on a class object that interacts with Google’s Places API, allowing my agents to retrieve up-to-date information for their tasks. However, there’s currently no documentation for this setup. Would it be better to break down the functions into separate tools ?

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [December 6, 2024, 5:11pm UTC](https://community.crewai.com/t/can-a-python-class-object-be-used-for-a-custom-tool/1858/2 "2024-12-06T17:11:19Z")

</div>

@Jorge_Rocha Actually, one of the two ways of setting your custom tool is by subclassing the `BaseTool` class. See the [docs](https://docs.crewai.com/how-to/create-custom-tools#subclassing-basetool).

Here’s an example from the docs:

```
from typing import Type
from crewai.tools import BaseTool
from pydantic import BaseModel, Field

class MyToolInput(BaseModel):
    """Input schema for MyCustomTool."""
    argument: str = Field(..., description="Description of the argument.")

class MyCustomTool(BaseTool):
    name: str = "Name of my tool"
    description: str = "What this tool does. It's vital for effective utilization."
    args_schema: Type[BaseModel] = MyToolInput

    def _run(self, argument: str) -> str:
        # Your tool's logic here
        return "Tool's result"

```

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [December 9, 2024, 7:19pm UTC](https://community.crewai.com/t/can-a-python-class-object-be-used-for-a-custom-tool/1858/3 "2024-12-09T19:19:35Z")

</div>


