Link a Tool for Function Calling

Managing and versioning a Tool separately from your Prompts

It’s possible to reuse tool definitions across multiple Prompts. You achieve this by having a Tool file that defines a JSON schema, and linking them to your Prompts.

This guide will run through creating a JSON Schema Tool defining a get_current_weather function, and linking that to a Prompt. You can repeat this linking for other Prompts (or Agents) if necessary.

Prerequisites

  • You already have a Prompt — if not, please follow our Prompt creation guide first.

Creating a JSON Schema Tool

To create a reusable JSON Schema tool, follow these steps:

1

Create a new Tool file

Navigate to the homepage or sidebar and click the ‘New File’ button.

2

Choose the JSON Schema Tool type

From the available options, select Json Schema as the Tool type.

After you create the Tool, you can edit the file name in the sidebar. Rename the file to “Weather tool”.

3

Define your tool’s structure

Paste the following JSON into the provided dialog to define your tool’s structure:

1{
2 "name": "get_current_weather",
3 "description": "Get the current weather in a given location",
4 "parameters": {
5 "type": "object",
6 "properties": {
7 "location": {
8 "type": "string",
9 "name": "Location",
10 "description": "The city and state, e.g. San Francisco, CA"
11 },
12 "unit": {
13 "type": "string",
14 "name": "Unit",
15 "enum": [
16 "celsius",
17 "fahrenheit"
18 ]
19 }
20 },
21 "required": [
22 "location",
23 "unit"
24 ]
25 }
26}

If you choose to edit or create your own Tool, you’ll need to use the JSON Schema syntax. When creating a custom Tool, it should correspond to a function you have defined in your own code. The JSON Schema you define here specifies the parameters and structure you want the AI model to use when interacting with your function.

4

Save Tool version

Press the Save button to save this version of the Tool.

Click the Deploy… button to deploy the Tool to your production environment, following the steps in the dialog.

Linked Tool changes can affect existing Prompts

When deploying a new version of your Tool, remember that the change may affect Prompts that link to it. Prompts that link to Tools will automatically use the default deployed version of the Tool. Be careful when making updates to not inadvertently change something you didn’t intend.

We now have a get_current_weather Tool that our Prompt can call.

1

Open Prompt Editor

Navigate to the Editor of a Prompt. Ensure you are using a model that supports tool calling, such as gpt-4.1-nano.

Models supporting Tool Calling

To view the list of models that support Tool calling, see the Models page.

2

Add Tool to the Prompt definition

Click the + Tool button in the bottom left of the Editor. Select the Link File… option, then select the Weather tool file you created earlier.

You should now see “Weather tool” in the list of Tools.

3

Run Prompt with Tool

Now that your Tool is linked, you can start using it. In the panel on the right, add a User message with “What is the weather in London?”.

Press the Run button.

You should see the Assistant respond with the tool call.

Press the Add to Messages button so you can make a subsequent call to the Prompt with the tool call result, to see how the model uses the tool call.

This will move the Assistant’s messages, containing the tool call, to the Messages section. You should now also see an Output section within the tool call, allowing you to insert an answer.

Enter 22 into the Output section and press Continue. The model will respond with “The current temperature in London is 22°C.”

4

Save the Prompt

Now that you’ve linked a Tool to your Prompt, let’s save it. Press the Save button and name this Prompt version weather-model.

You’ve now created a reusable Tool that can be used across multiple Prompts, and linked it to a Prompt. In this guide, we simulated the tool call by manually entering a value for temperature. In a real scenario, your code would be responsible for handling the tool call and returning the result.

Next steps

Try using Tools to extend your Agents’ capabilities. For example, if you link a Python code Tool (a Runnable Tool), Humanloop will automatically execute the Tool when it’s called by an Agent. Additionally, the Tool output will be saved as a Log.