BuildSpark AI

Map · Agents · 02 · Tool calling

Concept card · Agents

Tool calling

Tool calling is when the model asks your code to run a named function, then reads the result.

The model asks your code to run a named function, then reads the result.

Last checked 2026-10-18 Free card 4 min

Ask about Tool calling

What changed

Oct 18: First card. The picture switches between a named function call and the result your code would send back. Sources are the OpenAI, Gemini, and Anthropic tool-use guides.

1 What it is

Tool calling is the model asking your code to run a named function, then reading what your code sends back. OpenAI's function calling guide lists the flow as a request with tools, a tool call from the model, execution on the application side, a second request with the tool output, and a final response or more tool calls. Gemini's function calling guide says the model does not execute the function itself. Anthropic's tool-use guide says the model emits a structured request, and for a client tool your code runs it and returns the result.

Illustration. It simplifies tool calling to one named function. The call and the result are written for this picture. Your code is not running.

Picture call

get_close_time({ "warehouse": "north" })

The picture's model named the function and the argument. It did not run the function.

2 Why it matters

Cost

OpenAI's function calling guide says callable function definitions count against the context limit and are billed as input tokens. The same guide then makes another request that includes the tool output. Anthropic's tool-use guide says every client tool call is at least one extra round trip. This card does not add a price.

Quality

The model can read the result only on the request that includes it. OpenAI's flow ends in a final response or more tool calls, not in the tool call itself. OpenAI's guide can require the tool call to match the function schema. That constrains the arguments, not the truth of the value your code returns.

Risk

Your code runs the function, so the model can ask for an action with a side effect. Anthropic's tool-use guide lists sending an email or writing a file as actions only a tool can perform. A function in the tools list is a function the model can name.

3 How to apply · try today

Take one lookup you currently paste in by hand. Name it as a function with one argument, send it as a tool, and run the function in your own code before you send the result back.

Common mistake

Reading a tool call as if the function had already run. OpenAI's guide puts execution on the application side. Gemini's guide says the model does not execute the function itself.

Self-check

The model returns a tool call named get_close_time. Who runs that function?

Questions

What is tool calling?
Tool calling is when the model asks your code to run a named function, then reads the result.
Does the API run your function?
No. OpenAI's function calling guide puts execution on the application side. Gemini's guide says the model does not execute the function itself.
Does a schema make the tool result true?
No. OpenAI's guide can require the tool call to match the function schema. That constrains the arguments, not the truth of the value your code returns.