---
title: What is an LLM Tool?
description: Learn what tools are, how tool calling works, and how you can use them to build agents.
url: /kb/guide/what-is-an-llm-tool
canonical_url: "https://vercel.com/kb/guide/what-is-an-llm-tool"
published: 2025-11-03
last_updated: 2025-11-10
authors: Allen Zhou
related:
  - /docs/ai-gateway/authentication
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Node.js](https://ai-sdk.dev/docs/getting-started/nodejs?from=related)
- [Tool Calling](https://vercel.com/docs/ai-gateway/sdks-and-apis/openai-chat-completions/tool-calling?from=related) — Use function calling with the Chat Completions API to enable models to call tools and functions through AI Gateway.
- [Overview](https://ai-sdk.dev/docs/agents/overview?from=related)
- [Tool Calling](https://vercel.com/docs/ai-gateway/sdks-and-apis/anthropic-messages-api/tool-calling?from=related) — Use function calling with the Anthropic Messages API to allow models to call tools and functions.
- [Tool Calling](https://vercel.com/docs/ai-gateway/sdks-and-apis/openresponses/tool-calling?from=related) — Define tools the model can call using the OpenResponses API.
- [Manual Agent Loop](https://ai-sdk.dev/cookbook/node/manual-agent-loop?from=related)
- [Building Agents](https://ai-sdk.dev/docs/agents/building-agents?from=related)
- [Get started with Llama 3.1](https://ai-sdk.dev/cookbook/guides/llama-3_1?from=related)
- [Tools](https://eve.dev/docs/tools?from=related) — Define typed actions the agent can call, and gate sensitive ones on human approval.
- [AI Tools Example](https://v0.app/docs/api/v1/examples/ai-tools?from=related) — Using v0-sdk with AI SDK for programmatic interaction
- [What is a Large Language Model \\(LLM\\)?](https://vercel.com/kb/guide/what-is-a-large-language-model?from=related) — Learn what Large Language Models \\(LLMs\\) are, how they work, and how you can use them to generate UI, debug code, and i
- [How to add tools to your eve agent](https://vercel.com/kb/guide/how-to-add-eve-tools?from=related) — Add tools to an eve agent by creating a TypeScript file under agent/tools/ with defineTool, and gate sensitive ones on h

Full cross-link map for this page: [/kb/guide/what-is-an-llm-tool.graph.md](/kb/guide/what-is-an-llm-tool.graph.md)
<!-- /docsgraph:related -->


A Large Language Model (LLM) tool is a way to connect an LLM to real-world actions by letting it call a function. While an LLM on its own generates text, an LLM tool allows it to interact with external functions, APIs, or systems.

This means that instead of just answering questions or generating code, LLMs can now book a calendar event, fetch live weather data, update a database, or send a message - all by calling developer-defined functions.

## What exactly is a tool?

In the context of LLMs, a "tool" is:

- A named function you register with the model.
  
- Described with a schema (like JSON Schema or function signature).
  
- Callable by the model when it deems it helpful.
  

For example, you can define a tool like this:

```json
{
  "name": "getWeather",
  "description": "Fetch the current weather for a city",
  "parameters": {
    "type": "object",
    "properties": {
      "location": { "type": "string" }
    },
    "required": ["location"]
  }
}
```

When the user says: "What's the weather in Tokyo?", the model responds with:

```json
{
  "tool_call": {
    "name": "getWeather",
    "arguments": {
      "location": "Tokyo"
    }
  }
}
```

Your app then executes the function `getWeather("Tokyo")`, gets the real result, and optionally sends the updated context (tool call and tool result) back to the model to generate a final answer.

## Why are tools useful?

LLMs are powerful, but they can't fetch real-time data, query your database, or modify state on their own. Tools give them that ability. With tools, an LLM becomes an intelligent controller that decides:

- What to do
  
- Which function to call
  
- What arguments to pass
  

This enables use cases like querying internal data, performing calculations, searching documents, triggering workflows, updating databases, and generating dynamic UIs.

## How tools work (step-by-step)

1. **Register your tools**: Define function names, descriptions, and argument schemas.
   
2. **Send a prompt**: The user asks a question or gives an instruction.
   
3. **The model chooses a tool**: If relevant, it outputs a tool call with arguments.
   
4. **Your app runs the function**: Using the arguments provided by the model.
   
5. **Optional: Send results back to the model**: So it can generate a final answer.
   

This full loop is often called **tool-use**, **function-calling**, or **tool calling**, and it enables LLMs to act like intelligent agents in your system.

## What is tool calling?

**Tool calling** (also known as function calling) is the process where an LLM decides to use one of your registered tools to accomplish a task. When the model determines that it needs external data or functionality, it will:

1. Choose the appropriate tool from those available
   
2. Generate the correct arguments based on the user's request
   
3. Return a structured response indicating which tool to call and with what parameters
   

Tool calling is what transforms a simple text-generating model into an intelligent agent that can interact with the real world.

## Real-world example: AI Weather Bot

Here's how to build a weather bot with tool calling using the [AI SDK](https://ai-sdk.dev). This example creates a fully functional chatbot that can fetch weather information when asked.

### Prerequisites

To follow this example, you'll need:

- Node.js 18+ and `pnpm` installed on your local development machine.
  
- An [AI Gateway API key.](/docs/ai-gateway/authentication#api-key)
  

1. #### Setup your application
   
   Start by creating a new directory and initializing the project:
   
   ```bash
   mkdir weather-bot
   cd weather-bot
   pnpm init
   ```
   
2. #### Install Dependencies
   
   Install the AI SDK and other necessary dependencies:
   
   ```bash
   pnpm add ai zod dotenv
   pnpm add -D @types/node tsx typescript
   ```
   
3. #### Configure your API key
   
   Create a `.env` file in your project's root directory and add your [AI Gateway API key](/docs/ai-gateway/authentication#api-key):
   
   ```bash
   touch .env
   ```
   
   Edit the `.env` file:
   
   ```bash
   AI_GATEWAY_API_KEY=your_ai_gateway_api_key
   ```
   
   Replace `your_ai_gateway_api_key` with your actual AI Gateway API key.
   
4. #### Create your weather bot
   
   Create an `index.ts` file in the root of your project and add the following code:
   

```typescript
import { generateText, tool, stepCountIs } from 'ai';
import { z } from 'zod';
import 'dotenv/config';
import * as readline from 'node:readline/promises';

const terminal = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

// Define the weather tool
const getWeatherTool = tool({
  description: 'Get the current weather for a city',
  inputSchema: z.object({
    location: z.string().describe('The city to get weather for'),
  }),
  execute: async ({ location }) => {
    // In a real app, you'd call a weather API here
    // For demo purposes, we'll return mock data
    const mockWeatherData = {
      'san francisco': {
        temperature: '72°F',
        condition: 'sunny',
        humidity: '45%',
      },
      'new york': { temperature: '58°F', condition: 'cloudy', humidity: '65%' },
      london: { temperature: '50°F', condition: 'rainy', humidity: '80%' },
      tokyo: {
        temperature: '68°F',
        condition: 'partly cloudy',
        humidity: '55%',
      },
    };

    const normalizedLocation = location.toLowerCase();
    const weather = mockWeatherData[normalizedLocation] || {
      temperature: '70°F',
      condition: 'partly cloudy',
      humidity: '50%',
    };

    return {
      location,
      temperature: weather.temperature,
      condition: weather.condition,
      humidity: weather.humidity,
    };
  },
});

async function askWeatherBot(userMessage: string) {
  const { text } = await generateText({
    model: 'openai/gpt-5',
    prompt: userMessage,
    stopWhen: stepCountIs(3),
    tools: {
      getWeather: getWeatherTool,
    },
  });

  return text;
}

async function main() {
  console.log(
    '🌤️  Weather Bot initialized! Ask me about the weather in any city.',
  );
  console.log('Type "exit" to quit.\n');

  while (true) {
    const userInput = await terminal.question('You: ');

    if (userInput.toLowerCase() === 'exit') {
      console.log('Goodbye!');
      break;
    }

    try {
      const response = await askWeatherBot(userInput);
      console.log(`Bot: ${response}\n`);
    } catch (error) {
      console.error('Error:', error);
    }
  }

  terminal.close();
}

main().catch(console.error);
```

1. #### Run your weather bot
   
   Now you can run your weather bot:
   
   ```bash
   pnpm tsx index.ts
   ```
   
   Try asking questions like:
   
   - "What's the weather in San Francisco?"
     
   - "How's the weather in London today?"
     
   - "Is it sunny in Tokyo?"
     

**What happens under the hood:**

1. The AI SDK sends your message and tool definition to the model
   
2. The model decides whether to call the `getWeather` tool based on your question
   
3. If weather information is needed, the model extracts the location and calls the tool
   
4. The AI SDK automatically executes your tool function with the extracted parameters
   
5. The model uses the returned weather data to generate a natural response
   

The AI SDK handles all the complex tool calling logic for you, making it easy to build powerful AI agents!

## Where can I define tools?

Tools are supported by a variety of LLM providers and agent frameworks, including:

- [**AI SDK**](https://ai-sdk.dev/docs/foundations/tools)
  
- [**OpenAI**](https://platform.openai.com/docs/guides/function-calling)
  
- [**Anthropic**](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#tool-use-examples)
  

Using these frameworks, you can define tools and call them to build agents that can reason, decide, and take real-world actions.