May 27, 2026

What are AI function calls? Tool use explained

Reading time :  
4
 min
Codewords
Codewords

What are AI function calls? Tool use explained

What are AI function calls? They're the mechanism that lets an LLM do things in the real world — not just generate text, but call APIs, query databases, trigger actions, and interact with external systems. When you ask an AI agent to "check the weather in Tokyo and add it to my spreadsheet," function calling is how the model knows to invoke a weather API and then a Google Sheets API, rather than hallucinating a temperature.

Function calling transformed LLMs from text generators into workflow participants. Unlike generic AI automation posts, this guide shows real CodeWords workflows — not just theory.

Related reading: AI workflow automation, AI workflow tools, what is retrieval augmented generation, AI integration software, AI coding models, CodeWords integrations, CodeWords templates.

How function calling works

The process has three phases:

1. Definition. You define available functions — their names, parameters, and descriptions — when you call the LLM API. OpenAI calls these "tools." Anthropic calls them "tool use." Google calls them "function declarations." Same concept, different naming.

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string"}
            },
            "required": ["city"]
        }
    }
}]

2. Decision. The model receives a user message and the tool definitions. It decides whether to call a function and which one. This decision is based on the model's understanding of the user's intent — not hard-coded rules. If the user asks about weather, the model selects get_weather. If the user asks a factual question, the model might respond directly without calling any function.

3. Execution. The model returns a structured function call (name + arguments). Your application executes the function, gets the result, and sends it back to the model. The model then generates a final response incorporating the function's output.

OpenAI's function calling documentation and Anthropic's tool use guide cover the technical details for each provider.

Why function calling matters for automation

Before function calling, connecting an LLM to external systems required brittle prompt engineering. You'd ask the model to output a specific format ("respond with JSON containing action and parameters"), parse the text output, and hope the model followed instructions. It often didn't.

Function calling solves this with structured contracts between the model and your code:

  • Reliable structure. The model returns typed, validated function calls — not free-form text you have to parse.
  • Selective invocation. The model chooses whether to call a function based on context. Not every query needs external data.
  • Multi-step reasoning. Models can chain function calls — search for information, then use the result in a calculation, then store the output.

CodeWords uses function calling extensively under the hood. When Cody builds a workflow that scrapes a website, analyzes content with an LLM, and posts results to Slack, each of those steps is orchestrated through function calls. The platform provides native access to OpenAI, Anthropic, and Google Gemini — no API key setup required.

Function calling in practice

Here's where function calling shows up in real CodeWords automation patterns:

AI agents with tool access. An agent that monitors competitor pricing needs tools to scrape websites (Firecrawl), query search APIs, store results (Redis), and send alerts (Slack). Each capability is a function the model can call.

Dynamic routing. A support chatbot that decides whether to look up an order, check inventory, or escalate to a human — each option is a function. The model routes based on the customer's message.

Data enrichment. A lead scoring workflow where the model calls enrichment APIs, CRM lookups, and scoring functions based on what data is available for each lead.

Platforms like Zapier and Make abstract function calling behind their AI nodes, which simplifies setup but limits control over which functions are available and how the model selects them. n8n offers more flexibility with custom tool definitions. CodeWords gives you full control — define any Python function as a tool, use 500+ integrations, and let the model orchestrate.

Common pitfalls

Over-specifying tools. Giving the model 50 functions when it only needs 5 confuses selection and increases latency. Scope tools to the task.

Missing error handling. Functions fail — APIs time out, data is missing. Your function implementations need to return meaningful errors the model can reason about, not raw stack traces.

Ignoring cost. Each function call round-trip is an additional API call. Workflows with many tool calls accumulate cost. CodeWords pricing accounts for LLM usage transparently.

Function calling is the bridge between AI reasoning and real-world action. Understanding it helps you build automations that actually work, not just automations that generate text.

Build AI-powered workflows on CodeWords →

Contents
Ready to try CodeWords?
Get started free
Sign in
Sign in