AI
How Function Calling Works in LLM Applications
A simple guide to function calling, tool use and how LLMs can take real actions using APIs.
By 7CRM Team8 min read

Large language models are excellent at understanding and producing text. On their own, though, they can’t check today’s room availability, look up a student’s fee balance or create a booking. Function calling — also called tool use — is the feature that closes that gap. It’s the building block behind every useful AI agent.
The idea in one sentence
You describe some functions to the model; when a user’s request needs one of them, the model replies not with prose but with a structured request to call that function with specific arguments — and your code runs it.
The model never executes anything itself. It proposes a call; your application decides whether to run it.
A worked example
Suppose a hotel assistant has two functions:
check_availability(check_in, nights, guests)— returns available room types and prices.create_reservation(room_type, check_in, nights, guest_name, phone)— creates a booking and returns a reference.
A guest writes: “I need a room tomorrow for two, just one night.”
- Your app sends the message to the model along with the two function descriptions.
- The model responds with a function call:
check_availability(check_in: "2026-10-06", nights: 1, guests: 2). - Your code validates the arguments, queries the booking system and sends the result back: Deluxe ₹4,500, Standard ₹3,200.
- The model writes a reply offering both options.
- The guest picks Standard and gives their name. The model calls
create_reservation(...). - Your code creates the booking and returns the reference; the model confirms it to the guest.
Notice how much of the “intelligence” is ordinary software: the booking system, the validation, the permissions. The model’s job is understanding the request and choosing the next step.
Why structured output matters
Function calls come back as structured data that matches a schema you define — names, types, required fields. That makes them far more reliable than asking a model to “reply in JSON” in free text. Your code can reject anything that doesn’t fit before it touches a real system.
The same idea is useful even without actions. In SchoolBee, for example, AI analysis of a progress report is returned in a fixed structure — summary, strengths, growth areas, action items, home activities — so the app can display it consistently and check it before anyone reads it.
Designing good functions
A few rules make function calling robust:
- Small and specific.
check_availabilityis better than a genericrun_query. - Clear names and descriptions. The model chooses functions based on their descriptions; vague descriptions lead to wrong calls.
- Strict types. Dates as ISO dates, enums for room types, required fields marked as required.
- Validate everything server-side. Treat arguments from the model like input from a web form.
- Enforce permissions in code. The function should check what the current user is allowed to do — never rely on the prompt for security.
- Return useful errors. “No rooms available on that date” lets the model recover gracefully; a stack trace doesn’t.
Common pitfalls
- Too many tools at once. Dozens of similar functions confuse models. Group or narrow them.
- Side effects without confirmation. Payments, cancellations and bulk messages should usually need a human “yes”.
- Assuming the model remembers. Pass the facts the function needs explicitly; don’t rely on earlier conversation.
- No logging. Keep a record of every call and result so you can debug and audit.
Function calling in 7CRM products
Function calling is how Hotel AI is being designed to check availability and complete bookings, and it’s the foundation of the AI agents and workflow automation we build for businesses. If you have an internal API you’d like an assistant to use safely, get in touch.


