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 up Arcade
- Create an Arcade API key, if you haven’t already
Set environment variables
You can find your Arcade API key in one of these locations:
- Arcade Dashboard under API Keys
~/.arcade/credentials.yaml
Export your Arcade API key as an environment variable:
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 variableCall 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="user@example.com",
)
print(response.output.value) # 25Is this tool call too simple for your needs? Try executing a tool with authentication.