{"head":{"title":"What Is Tool Calling (Function Calling) in LLMs? | OceanLab","description":"Tool calling lets a language model ask your code to run a function, such as a search or a lookup, and use the result. How it works and common pitfalls.","canonical":"https://oceanlab.in/glossary/tool-calling"},"crumbs":[{"name":"Home","path":"/"},{"name":"Glossary","path":"/glossary"},{"name":"tool calling","path":"/glossary/tool-calling"}],"slug":"tool-calling","term":"Tool calling (function calling)","aka":["function calling","tool use"],"category":"AI building blocks","short":"A way for a language model to ask your application to run a defined function and give it the result.","body":[["You describe each tool to the model: its name, what it does and the inputs it takes, usually as a JSON schema. When the model decides a tool would help, it replies with a tool call, the tool name plus arguments, instead of plain text. Your code runs the function and sends the result back, and the model continues."],["The model never runs anything itself. Your application decides whether to run each call, with what permissions, and what to send back. That is where security and business rules belong."]],"why":["Tool calling is how an ",{"href":"/glossary/llm","text":"LLM"}," gets live data and takes actions: checking stock, booking a slot, creating a ticket. It is the base layer of every ",{"href":"/glossary/ai-agent","text":"AI agent"},". Done well, it keeps the model on facts from your systems instead of guesses, which cuts down on ",{"href":"/glossary/hallucination","text":"hallucinations"},"."],"example":["A travel assistant has two tools: search_flights and hold_seat. The user asks for a morning flight to Berlin on Friday. The model calls search_flights with the date and city, picks an option from the result, and asks the user to confirm before calling hold_seat."],"inBuild":null,"mistakes":[["Trusting the model's arguments. Validate every input as you would user input."],["Exposing too many similar tools. The model picks better from a short, clearly named list."],["Letting write actions run without confirmation or limits."]],"related":[{"href":"/glossary/ai-agent","label":"AI agent","detail":"Software where a language model decides which steps to take and which tools to call, in a loop, to reach a goal."},{"href":"/glossary/structured-output","label":"Structured output","detail":"Getting a language model to reply in a fixed, machine-readable format, such as JSON that matches a schema you define."},{"href":"/glossary/guardrails","label":"Guardrails (AI)","detail":"Checks placed around an AI model that block, fix or flag unsafe, off-topic or incorrect inputs and outputs."},{"href":"/glossary/llm","label":"LLM (large language model)","detail":"An AI model trained on very large amounts of text that predicts the next piece of text, which lets it read, write and reason in language."}],"tools":[{"href":"/tools/ai-agent-cost","label":"AI agent cost","detail":"Free tool"}],"links":[{"href":"/ai-automation","label":"AI automation","detail":"How OceanLab automates company workflows with AI."},{"href":"/ai","label":"AI by industry","detail":"AI use cases, costs and risks per industry."}],"sources":[],"legal":false,"updatedAt":"2026-10-25"}