Tool & Function Calling
Tool use (also called function calling ) lets an AI ask your code to run a defined task and then continue with the result. You describe each tool; the model returns a structured call; your code runs it and hands back the answer.
Learn Tool & Function Calling in our free Prompt Engineering course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a…
Part of the free Prompt Engineering course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
This unlocks live data, private information, and real actions the model cannot do from memory alone. This lesson walks through the call, execute, observe loop.
A tool is defined by three parts: a name , a description of what it does and when to use it, and a JSON schema of its parameters:
The model does not run the tool itself. It asks; your code answers. The rhythm:
The loop repeats: the model may call another tool, or finish its answer once it has what it needs.
Reach for a tool only when the model needs something beyond its own knowledge:
⏱ Test Yourself — Timed Quiz
10 quick questions, 12 seconds each. Instant feedback — beat the clock!
Practice quiz
What is 'tool use' or 'function calling' with an AI?
- The model can request that your code run a defined tool and use the result
- The model fixes your hardware
- A way to delete tools
- A type of font
Answer: The model can request that your code run a defined tool and use the result. Tool use lets the model ask your code to run a function and continue with the result.
How do you describe a tool to the model?
- Only its color
- Just a single word
- A name, a description, and a JSON-schema of its parameters
- Nothing is needed
Answer: A name, a description, and a JSON-schema of its parameters. Tools are defined by name, description, and a parameter schema the model fills in.
When the model decides to use a tool, it returns…
- A random number
- A structured call naming the tool and its arguments
- A picture
- An error
Answer: A structured call naming the tool and its arguments. The model emits a structured tool call with the chosen arguments.
Who actually executes the tool?
- The model runs it itself secretly
- Nobody
- The user types it by hand
- Your code runs it and returns the result to the model
Answer: Your code runs it and returns the result to the model. Your application executes the function and feeds the result back to the model.
After your code returns a tool result, the model…
- Continues, using the result to finish its answer
- Starts over from scratch
- Stops forever
- Deletes the tool
Answer: Continues, using the result to finish its answer. The model incorporates the result and continues the conversation.
The basic loop of tool use is…
- encrypt, decrypt
- call, execute, observe, then continue
- guess, guess, guess
- sleep, wake, repeat
Answer: call, execute, observe, then continue. The model calls a tool, your code executes it, the model observes the result, and continues.
Why use a tool instead of plain prompting?
- It is always slower
- To use more emojis
- There is never a reason
- To access live data or real actions the model cannot do from memory alone
Answer: To access live data or real actions the model cannot do from memory alone. Tools fetch current data or take real actions the model cannot do on its own.
A clear tool description mainly helps the model…
- Look nicer
- Run faster hardware
- Decide WHEN to call the tool and HOW to fill its parameters
- Avoid all tools
Answer: Decide WHEN to call the tool and HOW to fill its parameters. Good descriptions guide correct tool selection and argument formatting.
Which task is a good fit for a tool rather than plain prompting?
- Brainstorming names
- Looking up today's live weather for a city
- Rephrasing a sentence
- Summarizing a pasted paragraph
Answer: Looking up today's live weather for a city. Live, external data like current weather is exactly what a tool provides.
The parameter schema for a tool is written in…
- JSON schema describing the expected fields and types
- Morse code
- A spreadsheet only
- Random text
Answer: JSON schema describing the expected fields and types. Tool parameters are described with a JSON schema of fields and types.