Course contentsShow
← Machine Learning and Deep Learning
Lesson 2071 of 3,53844. AI Agents: FoundationsFree lesson

Function Calling vs Raw Tool Use

Understanding the difference between structured function calling APIs and raw tool integration in agent systems.

Function Calling vs Raw Tool Use

What you'll learn: You'll understand the architectural difference between LLM-native function calling APIs and manually parsing tool invocations from agent responses.

The Two Approaches to Tool Integration

When building AI agents, you need a way for the LLM to invoke tools (search engines, calculators, databases, etc.). There are two fundamental approaches:

Raw Tool Use (The Manual Way)

In raw tool use, you craft prompts that instruct the LLM to output tool calls in a specific text format (like JSON or special markers). You then parse the LLM's text response yourself, extract the tool name and parameters, execute the tool, and feed results back.

Example flow:

  • Prompt: "When you need a tool, write: ACTION: tool_name(param1, param2)"
  • LLM outputs: "I need to search. ACTION: web_search(weather in Paris)"
  • You parse this string manually using regex or JSON parsing
  • You execute web_search("weather in Paris")
  • You format the result and continue the loop

Function Calling (The Structured Way)

Function calling uses LLM provider APIs (like OpenAI's function calling or Anthropic's tool use) that return structured, validated tool invocations directly. The LLM is fine-tuned to output tool calls in a specific schema, and the API returns them as parsed objects—no string parsing needed.

Example flow:

  • You register tools with schema definitions
  • LLM decides to use a tool, API returns: {tool: "web_search", args: {query: "weather in Paris"}}
  • You execute directly from the structured response
  • Results are formatted according to the schema

Why It Matters

Function calling is more reliable (less parsing errors), more type-safe (validated parameters), and easier to maintain. Raw tool use offers more flexibility and works with any LLM, but requires careful prompt engineering and robust parsing logic.

Key Takeaway: Function calling APIs provide structured, validated tool invocations from fine-tuned models, while raw tool use relies on prompt engineering and manual parsing—choose based on reliability needs vs. model flexibility.