Generative AI & LLMs

Function Calling (Tool Use)

In shortFunction calling lets a language model ask your code to run a defined tool, such as an API or database query, and use the result in its answer.

Updated 24 Oct 2026· 2 min read

Function calling, also called tool use or tool calling, is the ability of a large language model to ask for an external function to be run and then use the result. You describe the tools available (for example “get_search_volume” or “check_stock”), and when a request needs one, the model replies with the tool’s name and the arguments to pass. Your code runs the tool and sends the result back, and the model continues. It is what turns a chatbot into an AI agent that can act on live data.

How it works

  • Define tools: each has a name, a description in plain language and a JSON Schema describing its parameters.
  • Send the user request plus the tool definitions to the model.
  • The model decides whether a tool is needed. If so, it returns a structured tool call such as get_search_volume(keyword=”trail running shoes”, country=”GB”) instead of a final answer.
  • Your application executes the call (an API request, a database query, a calculation) and returns the output to the model.
  • The model uses the output to answer, or calls further tools in a loop until the task is done.

The model never runs code itself; it only proposes calls. The Model Context Protocol (MCP) standardises how tools are exposed to models, and WebMCP proposes the same idea for actions on websites.

How it’s used in SEO and marketing

  • Agent workflows that pull live data (Search Console, a SERP API, analytics) instead of relying on the model’s training data.
  • Structured extraction: defining a “record_result” tool forces the model to return clean, schema-shaped output for classification or entity tasks.
  • Content brief automation that calls keyword and SERP tools before drafting.
  • Understanding AI search: MLforSEO’s Agentic SEO course lists tool use as one of the five properties of agents. An agent that needs today’s weather in Rome calls a weather API directly instead of reading a web page, which means some information needs are now served by APIs rather than by content.

Example

An analyst asks an assistant, “Which of our top 20 pages lost the most clicks last month?” The model calls a search_console_query tool with the date range, receives the rows, calls it again for the previous month, compares the two and answers with a ranked list, citing the numbers it received.

Limitations and things to watch

  • Models can pick the wrong tool, pass wrong arguments or invent values; validate inputs before running anything.
  • Tools that change things (publishing, deleting, spending) need confirmation steps and limited permissions.
  • Every tool call adds latency and token cost, and tool output counts against the context window.
  • Provider APIs and syntax differ and change; check current documentation.

Learn it on MLforSEO

Where Function Calling (Tool Use) shows up on MLforSEO

Sources and further reading

Other terms from Generative AI & LLMs

See all 19 Generative AI & LLMs terms →