---
title: "What is tool calling (function calling) in LLM APIs?"
description: "Tool calling lets an LLM ask your code to run a function with JSON arguments. How the request-and-result loop works, what it costs in tokens, and how agents use it."
url: https://broadrouter.com/glossary/tool-calling/
lang: en
updated: 2026-11-14
publisher: BroadRouter (a BroadNet site); API by BroadNet Inference, https://inference.broadnet.ai
---

# Tool calling

Updated 2026-11-14

Tool calling, also called function calling, is an LLM API feature in which the model returns a structured request to run a function the developer has defined, with JSON arguments. The application runs the function and sends the result back; the model never runs code itself.

Also called: function calling, tool use, tools, tool\_calls

Tool calling is how a language model acts on the world: it asks your code to look something up, run a query or edit a file, and then uses the result.

## How it works

OpenAI’s guide describes a loop between your app and the model:

1.  **Send tools.** The request lists functions with a name, a description and a JSON Schema for the arguments.
2.  **Get a tool call.** If the model needs a tool, it returns the function name and JSON arguments instead of a final answer.
3.  **Run it.** Your code executes the function. OpenAI’s guide puts this step on “the application side”; the model never runs code itself.
4.  **Return the result** with the matching call ID.
5.  **Get the answer**, or another tool call. Repeat as needed.

In the Chat Completions format, a tool definition looks like this:

```json
{
  "type": "function",
  "function": {
    "name": "get_order_status",
    "description": "Look up an order by ID",
    "parameters": {
      "type": "object",
      "properties": { "order_id": { "type": "string" } },
      "required": ["order_id"]
    }
  }
}
```

The reply has `finish_reason: "tool_calls"` and a `tool_calls` list. Each entry has an `id`, the function name and `arguments` as a JSON string. You append a message with `role: "tool"`, the same `tool_call_id` and the result, then call the API again.

## Why it matters

-   **Agents.** Coding agents, support bots and data assistants are mostly loops of tool calls.
-   **Cost.** Every round trip is a new request that resends the conversation, tool definitions and tool results as [input tokens](https://broadrouter.com/glossary/input-and-output-tokens/). Long tool loops make [cached input](https://broadrouter.com/glossary/cached-input-tokens/) and a stable tool order important.
-   **Safety.** Arguments come from the model. Validate them before running anything that changes data or spends money.

For a reply that must match a schema but needs no function, [structured output](https://broadrouter.com/glossary/structured-output/) is the simpler tool.

## On BroadNet Inference

BroadNet’s docs list tool calling for [GLM 5.3](https://broadrouter.com/models/glm-5.3/) and [Qwen3.8 27B](https://broadrouter.com/models/qwen3.8-27b/), both with structured output and reasoning. The docs do not state tool support for DeepSeek V4.1 Flash or BroadNet Gemma 4 VL 26B. Test your own tool loop on the model you plan to ship.

Both listed models reason before answering, and reasoning counts toward `max_tokens`, so leave room or a tool call can be cut off. See [reasoning tokens](https://broadrouter.com/glossary/reasoning-tokens/). For agent tools that bring their own tool format, see the [Cline guide](https://broadrouter.com/guides/cline-openai-compatible/) and the [Vercel AI SDK guide](https://broadrouter.com/guides/vercel-ai-sdk-openai-compatible/).

## Common mistakes

-   Parsing `arguments` as an object. It arrives as a JSON string; decode it and handle errors.
-   Forgetting the `tool_call_id`. The model cannot match results to calls without it.

## Questions

### Does the model run my function?

No. The model only returns the function name and arguments. Your code decides whether to run it, runs it, and sends the result back in a tool message.

### Can the model call several tools at once?

Many APIs allow parallel tool calls, returning several entries in tool\_calls in one response. Your code runs each and returns one result per tool\_call\_id.

### Which BroadNet models support tool calling?

BroadNet's docs list tools for GLM 5.3 and Qwen3.8 27B. They do not state tool support for DeepSeek V4.1 Flash or BroadNet Gemma 4 VL 26B, so test before you rely on it there.

## See also

-   [Structured output](https://broadrouter.com/glossary/structured-output/) (term)
-   [Input and output tokens](https://broadrouter.com/glossary/input-and-output-tokens/) (term)
-   [Cached input tokens](https://broadrouter.com/glossary/cached-input-tokens/) (term)
-   [OpenAI-compatible API](https://broadrouter.com/glossary/openai-compatible-api/) (term)
-   [AI agent](https://broadrouter.com/glossary/agent/) (term)
-   [MCP (Model Context Protocol)](https://broadrouter.com/glossary/mcp/) (term)
-   [JSON mode](https://broadrouter.com/glossary/json-mode/) (term)
-   [Prompt injection](https://broadrouter.com/glossary/prompt-injection/) (term)
-   [tool\_choice](https://broadrouter.com/glossary/tool-choice/) (term)
-   [Parallel tool calls](https://broadrouter.com/glossary/parallel-tool-calls/) (term)
-   [JSON Schema](https://broadrouter.com/glossary/json-schema/) (term)
-   [Use the OpenAI Python SDK with BroadNet Inference](https://broadrouter.com/guides/openai-python-sdk/) (guide)
-   [Use Cline with BroadNet Inference (OpenAI Compatible provider)](https://broadrouter.com/guides/cline-openai-compatible/) (guide)
-   [Use the Vercel AI SDK with BroadNet Inference](https://broadrouter.com/guides/vercel-ai-sdk-openai-compatible/) (guide)
-   [How to run parallel coding agents on a flat-rate LLM API](https://broadrouter.com/blog/run-parallel-coding-agents-flat-rate/) (article)
-   [When a 1M-token context window is worth it (and when not)](https://broadrouter.com/blog/million-token-context-window-guide/) (article)

Try it on your real workload. New accounts start with $5 of credit for Gemma and transcription. DeepSeek, GLM and Qwen3.8 need a top-up.

[Get started](https://inference.broadnet.ai/account/?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-tool-calling&utm_content=page-cta) ·

**Sources**

-   [OpenAI, function calling guide](https://developers.openai.com/api/docs/guides/function-calling)
-   [OpenAI API reference, create chat completion (tools)](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
-   [BroadNet Inference API reference, models](https://inference.broadnet.ai/docs?utm_source=broadrouter&utm_medium=referral&utm_campaign=glossary-tool-calling&utm_content=sources#models)
