LLM Function Calling in Python — ELI5

Imagine a really smart friend who knows a lot about the world but is stuck in a room with no phone and no internet. You can pass notes back and forth. Your friend can think hard and write great answers, but if you ask “What is the weather right now?” they have to guess because they cannot look outside.

Function calling is like giving your friend a menu of buttons they can press. One button checks the weather, another looks up a price, another sends an email. Your friend cannot press the buttons directly — instead, they write a note saying “please press the weather button for Paris.” You press it, get the result, and pass it back so they can finish their answer.

In Python, you describe these buttons (functions) to the AI model. The model reads your descriptions and decides which button to press and what information to send. Your code actually runs the function and gives the answer back to the model.

This matters because without function calling, AI can only use what it already knows. With function calling, it can look things up, do math precisely, save data, and talk to other services — all through your code.

A common mistake is thinking the AI runs your code. It never does. It only asks your code to run. You stay in control of what actually happens.

The one thing to remember: Function calling lets an AI request actions from your Python code — the model decides what to call, but your program does the actual work and stays in control.

pythonllm-appsfunction-calling

See Also

  • Python Agent Frameworks An agent framework gives AI the ability to plan, use tools, and work through problems step by step — like upgrading a calculator into a research assistant.
  • Python Embedding Pipelines An embedding pipeline turns words into numbers that capture meaning — like translating every sentence into coordinates on a giant map of ideas.
  • Python Guardrails Ai Guardrails are safety bumpers for AI — they check what the model says before it reaches users, like a spellchecker but for facts, tone, and dangerous content.
  • Python Llm Evaluation Harness An LLM evaluation harness is like a report card for AI — it runs tests and grades how well the model answers questions so you know if it is actually improving.
  • Python Prompt Chaining Think of prompt chaining as a relay race where each runner hands a baton to the next — except the runners are AI prompts building on each other's work.