HomeTool CallingTool execution

Call tools directly

In this guide, you’ll learn how to call tools programmatically using Arcade.

Unlike calling tools with models, calling tools directly doesn’t use an AI model to decide which tool to call and what arguments to pass. Instead, you specify the tool and its arguments in code.

You still get the benefits of Arcade managing authorization and tool execution, but you have more control over when and how the tool is called. This is useful in apps and AI agents where the workflows are more complex than a single model call.

Prerequisites

Set environment variables

You can find your API key in ~/.arcade/credentials.yaml.

export ARCADE_API_KEY=<your-api-key>

Initialize the client

Import and initialize the Arcade client. The client automatically uses the ARCADE_API_KEY environment variable.

from arcadepy import Arcade
 
client = Arcade()  # Automatically finds the `ARCADE_API_KEY` env variable

Call a tool

Let’s use the Math.Sqrt tool from the Arcade Math toolkit to calculate the square root of 625.

response = client.tools.execute(
    tool_name="Math.Sqrt",
    input={"a": 625},
    user_id="[email protected]",
)
 
print(response.output.value)  # 25

Is this tool call too simple for your needs? Try executing a tool with authentication.