Standard 19 stops to get here

Function Calling

The API mechanism behind LLM tool use: you describe functions with a schema, the model replies with a structured call, and your code runs it and returns the result.

Your route here

19 stops · basics first
  1. Natural Language Processing ✓ understood

    The field of AI that lets computers read, interpret, translate and generate human language, from spam filters and search to chatbots.

  2. Token ✓ understood

    The unit of text a language model reads and writes: a word, part of a word, or a character, drawn from the model's fixed vocabulary.

  3. Tokenization ✓ understood

    Splitting text into tokens, usually subword pieces, and mapping each to an integer ID so a language model can process it.

  4. Language Modeling ✓ understood

    Assigning probabilities to sequences of text, in practice by predicting each next token from the ones before it; the objective behind large language models.

  5. Dataset ✓ understood

    A collection of data examples used for training, validating, or testing machine learning models.

  6. Training ✓ understood

    The process of fitting a model to data by repeatedly measuring how wrong its outputs are and adjusting its parameters to reduce that error.

  7. Machine Learning ✓ understood

    Building systems that learn patterns from data instead of following hand-written rules, getting better at a task as they see more examples.

  8. Unsupervised Learning ✓ understood

    Learning from unlabeled data to discover hidden patterns, structures, or relationships without explicit target outputs.

  9. Self-Supervised Learning ✓ understood

    Training on unlabeled data by making the data supply its own answers: hide or alter part of an input and have the model predict or match it.

  10. Pre-training ✓ understood

    Training a model on a large dataset (often self-supervised) before fine-tuning on specific tasks, enabling transfer learning.

  11. Feature ✓ understood

    A single measurable property of an example, such as a house's floor area or how many links an email contains, used as an input to a model.

  12. Neural Network ✓ understood

    A model built from layers of simple units, each taking a weighted sum of its inputs and applying a nonlinearity; training adjusts the weights so the whole stack maps inputs to useful outputs.

  13. Deep Learning ✓ understood

    A subset of machine learning that uses neural networks with multiple layers (deep neural networks) to learn hierarchical representations of data.

  14. Representation Learning ✓ understood

    Letting a model learn its own internal description of the data, such as embeddings or layered visual features, instead of relying on features designed by hand.

  15. Embedding ✓ understood

    A list of numbers (a vector) that represents a word, sentence, image or other item, learned so that similar items end up close together.

  16. Attention Mechanism ✓ understood

    A technique that lets a neural network weigh every part of its input when producing each output, focusing on the parts most relevant at that step.

  17. Transformer ✓ understood

    A neural network architecture, introduced in 2017, built from stacked self-attention and feed-forward layers; the basis of nearly every modern large language model.

  18. Large Language Model ✓ understood

    A neural network, almost always a transformer, trained on vast amounts of text to predict the next token, which lets it write, answer, summarize and follow instructions.

  19. Tool Use ✓ understood

    A language model asking the application around it to run a function, such as search, a calculator or an API, then using the result in its answer.

  20. Function Calling · you are here ✓ understood

Picture it

  1. 01 Describe the tools Name, description and a JSON Schema for the arguments
  2. 02 Model returns a call A structured request: which function, which arguments
  3. 03 Your code runs it The model never executes anything itself
  4. 04 Send the result back Tagged with the call's id so the model can match it
  5. 05 Model answers Or asks for another call
Notice that the model only proposes the call; your application decides whether to run it and hands the result back for the next turn.

Function calling is how tool use is wired up in practice. A language model can only produce text, so it cannot look up the weather or query a database by itself. Function calling gives it a structured way to ask: the model emits a machine-readable request naming a function and its arguments, and the surrounding application does the work.

The round trip

  1. Declare the functions. Alongside the conversation, you send a list of tools. Each has a name, a plain-language description of when to use it, and a JSON Schema describing its arguments.
  2. The model decides. On each turn it either answers directly or returns one or more calls, each with arguments filled in from the conversation.
  3. Your code executes. The application parses the arguments, runs the real function and captures the output.
  4. Return the result. The output goes back to the model, linked to the call it answers, and the model continues from there.

Providers name the pieces differently (OpenAI’s API returns a function call with a call_id; Anthropic’s returns a tool_use block and expects a tool_result), but the loop is the same. Both offer a strict mode that constrains the model’s arguments to match the schema exactly.

Why the description matters

The model chooses functions by reading their names and descriptions, so these are effectively part of the prompt. Vague descriptions lead to missed or wrong calls, and every tool definition also costs input tokens on each request.

From one call to an agent

Put this loop in a cycle, letting the model call tools until it decides it is done, and you have the core of an AI agent. Research such as Toolformer showed models could also learn when to call simple APIs, like a calculator or search engine, during generation. Because the model can request actions, applications should validate arguments and gate anything with side effects rather than executing calls blindly.

Where it sits

Before this

Tool Use
Function Calling

Leads to

Nothing yet: a destination in its own right.

Explore nearby

Sources

  1. OpenAI, Function calling guide . API documentation
  2. Anthropic, Tool use with Claude . API documentation
  3. Schick et al., "Toolformer: Language Models Can Teach Themselves to Use Tools" . 2023