> For the complete documentation index, see [llms.txt](https://docs.contextual.io/documentation-and-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextual.io/documentation-and-resources/components-and-data/flows/node-reference/ai-gateway/ai-tool.md).

# AI Tool

Define a tool that can be invoked by AI Generate.

## Where to Find It

In the Flow Editor, look in the left palette under **AI Gateway**, then drag **Tool** onto your canvas.

<figure><img src="/files/t6xDyXXRPPGM2zcIblsS" alt="AI Tool node configuration" width="375"><figcaption><p>AI Tool configuration with Tool ID, Description, and Schema.</p></figcaption></figure>

## What It Does

The Tool node is the entry point for tool execution when the model decides to call a tool. When invoked, it emits a copy of the AI Generate message with the tool parameters in `msg.payload`.

## Configuration

1. **Name** (optional) - Provide a friendly label for the node.
2. **Tool ID** (required) - The unique identifier the model calls. Tool IDs must be unique within the tools selected by the same AI Generate node and can include letters, numbers, `_`, and `-`.
3. **Description** (optional) - Describe what the tool does to help the model choose it.
4. **Input Schema** (required) - The JSON Schema for tool parameters.
   * Use the editor for static schema definitions.
   * Use a `msg` reference when you want the schema sourced dynamically from the AI Generate message.

## Outputs

When the model invokes the tool, the node emits a message with:

* `msg.payload` set to the tool parameters
* the rest of the original AI Generate message preserved for context

Use downstream nodes to implement the tool behavior, then finish the tool path with [AI Tool Response](/documentation-and-resources/components-and-data/flows/node-reference/ai-gateway/ai-tool-response.md) to send the result back to AI Generate.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.contextual.io/documentation-and-resources/components-and-data/flows/node-reference/ai-gateway/ai-tool.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
