HomeTool CallingCall Tools Directly

Call Tools Directly

In this guide, you’ll learn how to call tools directly, instead of having the LLM choosing which tool to call.

Direct tool calling is useful in situations where you already know what tool is needed or when there is no prompt for an LLM to interpret and decide on the tool calling. It also gives you full control over what is executed by the Arcade Engine and how.

Prerequisites

  1. Create an Arcade account
  2. Get an Arcade API key and take note, you’ll need it in the next steps.

Install the Arcade client

pip install arcadepy

Instantiate the client

Create a new script called call_tools_directly.py and instantiate the Arcade client:

from arcadepy import Arcade
 
client = Arcade(api_key="arcade_api_key")

You can also set the ARCADE_API_KEY environment variable instead of passing it as a parameter.

Set the user ID

Arcade needs a unique identifier for your application user (this could be an email address, a UUID, etc). In this example, simply use your email address as the user ID:

user_id = "[email protected]"

Call a tool

Let’s use the Math.Sqrt tool from the Arcade Math toolkit to get the square root of a number.

response = client.tools.execute(
    tool_name="Math.Sqrt",
    input={"a": 625},
    user_id=user_id,
)
 
print(response.output.value)
 

Run the code

python3 example.py
> 25

Next Steps

This was a very simple tool call. Try executing a tool with user authorization next.