Prompts & AI use

Function Calling

AI-assisted editorial review:

Function calling

Function calling is an API capability that OpenAI introduced in June 2023. Developers describe functions to the model with JSON Schema, and the model can answer with a function name and JSON arguments instead of plain text. The application then runs the function and sends the result back, which lets the model work with tools, databases and live data.[1][2] Anthropic calls the same capability "tool use", and Google's Gemini API also supports it.[4][6]

What does Function Calling mean in simple terms?

With function calling, the model can decide partway through an answer that "this part should be handled by an outside function." It then returns the function name and the arguments (which values to pass) as clean JSON. Think of a presenter who does not calculate the figures personally, but writes a request slip to the spreadsheet owner: "please total 2025 revenue." The model writes the slip; your code does the actual work and returns the result.[2] This is the basic building block behind chatbots that can look up live weather, exchange rates or stock levels, so it is worth understanding even if you never write the code yourself.

How can Function Calling be explained with an analogy?

It is like a new hire's draft approval form: it says which form to use and what to fill in, but someone else checks it and carries it out.

Where is Function Calling used?

Case 1

OpenAI documentation — Defining a get_weather function

OpenAI's guide shows the standard pattern: declare a tool with JSON Schema, receive a function call from the model, run it in your code, and send the output back.[2] Its example get_weather function takes location (a string) and units (an enum of celsius or fahrenheit). For a request such as "What's the weather in Seoul?", the model could return an illustrative call like {"name":"get_weather","arguments":{"location":"Seoul, South Korea","units":"celsius"}}.[2] Since August 2024, setting strict: true turns on Structured Outputs, so the model's arguments match the supplied schema. Structured Outputs does not stop the model from choosing wrong values.[3]
Result: In OpenAI's internal eval of complex JSON Schema following, gpt-4o-2024-08-06 with Structured Outputs scored 100%, compared with under 40% for gpt-4-0613.[3]

Case 2

Klarna — An assistant that handles refunds and returns (company-reported figures)

Klarna's AI assistant, powered by OpenAI, was described as handling tasks from multilingual customer service to managing refunds and returns.[12] In its first month it held 2.3 million conversations, two-thirds of Klarna's customer service chats. Klarna said this equalled the work of 700 full-time agents and cut repeat inquiries by 25%.[12] Klarna has not published exactly how the assistant connects to its systems. Actions like these, though, require the model to reach company systems through defined interfaces. In May 2025 Klarna said customers should always be able to reach a human, and it began recruiting human service staff again.[13]
Result (company-reported): Customers resolved errands in under 2 minutes, down from 11 minutes.[12]

Case 3

Stripe — Exposing payment APIs as agent tools, with human confirmation

Stripe runs an MCP server that turns its API into tools an agent can call. These include stripe_api_read for GET methods and stripe_api_write for write methods such as creating payment links or invoices.[14] For certain write actions, such as refunds and outbound payments, Stripe requires a person to confirm the request before it runs. Stripe also recommends OAuth or agent API keys limited to the permissions the client needs. From October 31, 2026, the Stripe MCP server stops accepting full-access secret keys and restricted keys without the Agent tag.[14]
Result: Refunds and outbound payments requested by an agent wait for human approval; unapproved requests expire after 24 hours.[14]

Case 4

UC Berkeley BFCL — A common benchmark for function calling

The Berkeley Function Calling Leaderboard (BFCL), built by UC Berkeley researchers, was published at ICML 2025. It evaluates serial and parallel function calls with an Abstract Syntax Tree (AST) method that scales to thousands of functions. It also tests whether a model can abstain from calling and can reason in stateful, multi-step agent settings.[15] The authors describe BFCL as the de facto standard for evaluating function calls.[15]
Result: State-of-the-art models did well on single-turn calls, but memory, dynamic decision-making and long-horizon reasoning remained open challenges.[15]

Try it today

  1. Copy the get_weather JSON Schema example from the OpenAI or Anthropic documentation as it is.[2][4]
  2. Pick one internal API your team calls often and write a schema for it in the same structure.
  3. Test natural-language requests in a playground or sandbox and check which arguments the model fills in.[2]
  4. Collect failures (missing arguments, wrong enum values) and improve the function and parameter descriptions.[2]
  5. Turn on strict mode (strict: true, available from both OpenAI and Anthropic) and compare stability. With Anthropic, you can also limit calls to at most one per turn with disable_parallel_tool_use.[3][4]

Limits

The official documents state the limits directly. Structured Outputs supports only a subset of JSON Schema, and the values inside a valid JSON object can still be wrong.[3] OpenAI suggests keeping fewer than 20 functions available at the start of a turn, as a soft guideline.[2] Anthropic reports that the most common failures are choosing the wrong tool and passing incorrect parameters, especially when tools have similar names.[11] Tool outputs can also contain untrusted instructions. In its 2023 launch post, OpenAI advised developers to use only trusted tools and to ask the user to confirm actions with real-world impact, such as sending an email or making a purchase.[1] Klarna's 2025 shift back toward human support shows that automation needs a clear path to a person.[13] Each vendor also uses its own format, for example parameters at OpenAI and input_schema at Anthropic, so the same tool often has to be defined more than once.[2][4]

Direction

First, standardization. On November 25, 2024, Anthropic open-sourced the Model Context Protocol (MCP), an open standard for connecting AI applications to data sources and tools.[7] OpenAI added MCP support to its Agents SDK and then, on May 21, 2025, to the Responses API for remote MCP servers. It also joined the MCP steering committee.[10] Second, smarter calling at scale. In November 2025 Anthropic released three beta features: a Tool Search Tool that finds tools on demand among hundreds or thousands, Programmatic Tool Calling that runs tools from code, and Tool Use Examples.[11] OpenAI's guide now describes tool search and namespaces for large tool sets.[2] Third, evaluation-based model choice. BFCL has expanded from single calls to multi-step agent settings.[15] For Korean, Kakao's FunctionChat-Bench (700 items) found that high single-turn accuracy does not necessarily carry over to multi-turn dialogue.[16]

How has Function Calling evolved?

2023-06-13
OpenAI function calling
Announced for gpt-4-0613 and gpt-3.5-turbo-0613: the model outputs JSON arguments that match a described function.[1]
2024-05-30
Anthropic tool use GA
Tool use became generally available across the Claude 3 model family.[5]
2024-11-25
MCP released
Anthropic open-sourced the Model Context Protocol, an open standard for connecting AI applications to tools and data.[7]
2025
Agentic tool use
OpenAI added remote MCP server support (May), and Anthropic released tool search and programmatic tool calling in beta (November).[10][11]

Which concepts are related to Function Calling?

  • Similar concept
    Tool UseAnthropic's name for the same capability.[4]
  • Next step
    MCPAn open protocol that standardizes how applications expose tools and data to models.[7]
  • Foundation
    Structured OutputConstrains model output to a supplied JSON Schema; used for function arguments with strict mode.[3]
  • Related tool
    JSON ModeProduces valid JSON, but unlike Structured Outputs it does not guarantee a specific schema.[3]

Function Calling vs MCP

ComparisonFunction CallingMCP
StandardizationEach vendor's own API format (e.g., OpenAI parameters, Anthropic input_schema)[2][4]Open protocol, open-sourced by Anthropic in 2024[7]
UnitIndividual function definitions and callsA server provides tools, resources and prompts[8]
Tool registrationThe app sends function schemas with the request[2]The client discovers tools with tools/list; the server can notify when the list changes[9]
ReuseIntegration code is often written per app and per vendorDevelopers build against one protocol instead of separate connectors[7]
Where usedOpenAI, Anthropic and Gemini APIs[2][4][6]MCP clients such as Claude Code, Cursor, VS Code and Codex[14]

Which sources explain Function Calling?

  1. OpenAI — Function calling and other API updates (2023-06-13) — https://openai.com/index/function-calling-and-other-api-updates/
  2. OpenAI API Docs — Function calling guide — https://developers.openai.com/api/docs/guides/function-calling
  3. OpenAI — Introducing Structured Outputs in the API (2024-08-06) — https://openai.com/index/introducing-structured-outputs-in-the-api/
  4. Anthropic (Claude Platform Docs) — Tool use with Claude — https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
  5. Anthropic — Claude can now use tools (2024-05-30) — https://claude.com/resources/articles/tool-use-ga
  6. Google AI for Developers — Function calling with the Gemini API — https://ai.google.dev/gemini-api/docs/function-calling
  7. Anthropic — Introducing the Model Context Protocol (2024-11-25) — https://www.anthropic.com/news/model-context-protocol
  8. Model Context Protocol — Specification 2025-06-18: Server overview — https://modelcontextprotocol.io/specification/2025-06-18/server
  9. Model Context Protocol — Specification 2025-06-18: Tools — https://modelcontextprotocol.io/specification/2025-06-18/server/tools
  10. OpenAI — New tools and features in the Responses API (2025-05-21) — https://openai.com/index/new-tools-and-features-in-the-responses-api/
  11. Anthropic Engineering — Introducing advanced tool use on the Claude Developer Platform (2025-11-24) — https://www.anthropic.com/engineering/advanced-tool-use
  12. OpenAI — Klarna customer story — https://openai.com/index/klarna/
  13. CX Dive — Klarna changes its AI tune and again recruits humans for customer service (2025-05-09) — https://www.customerexperiencedive.com/news/klarna-reinvests-human-talent-customer-service-AI-chatbot/747586/
  14. Stripe Docs — Model Context Protocol (MCP) — https://docs.stripe.com/mcp
  15. Patil et al., ICML 2025 (PMLR 267) — The Berkeley Function Calling Leaderboard (BFCL): From Tool Use to Agentic Evaluation of Large Language Models — https://proceedings.mlr.press/v267/patil25a.html
  16. Lee et al. (Kakao), arXiv — FunctionChat-Bench: Comprehensive Evaluation of Language Models' Generative Capabilities in Korean Tool-use Dialogs (2024-11-21) — https://arxiv.org/abs/2411.14054