Function Calling

Simple Definition

Function calling is a feature of AI APIs that lets a language model output a structured request to call a specific function in your code, instead of just generating text.

When you ask an AI “What’s the weather in Paris right now?”, it can’t know that from its training data. With function calling, it outputs a structured call like get_weather(city="Paris"), your code runs that function, gets the real data, and passes it back to the model to generate a natural response.

How It Works

  1. You define functions the model can call, with a description and parameter schema
  2. User sends a message that might require one of those functions
  3. Model decides whether to generate text or call a function
  4. If calling a function, it outputs the function name and parameters in a structured format
  5. Your code runs the actual function and returns the result
  6. Model uses the result to generate a natural-language response

Why Function Calling Is Important

It’s what bridges the gap between AI text generation and real-world action. Without it, AI can only tell you things. With function calling, AI can:

  • Look up current information
  • Write to databases
  • Send emails or messages
  • Create calendar events
  • Interact with any external service

Example Use Cases

  • Customer service bot that can actually look up your order status
  • AI assistant that schedules meetings by accessing your calendar
  • Data analysis tool that queries a live database
  • AI that can take actions in your app on a user’s behalf
  • Tool Use, the broader concept; function calling is the implementation
  • AI Agent, agents use function calling to take real-world actions
  • API, the external interfaces AI calls via function calling
  • LLM, the models that support function calling

Continue learning

Explore related guides, tools, workflows, and prompts that help you go deeper into this topic.

See AI terms in action

Browse practical AI workflows that use the concepts in this glossary.

Last updated: