llm.createTool(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Creates a tool definition that you can provide when calling llm.generateText(options) or llm.generateTextStreamed(options).

Tools are callable operations that the large language model (LLM) can request to augment its responses. They are custom utilities that you define, and they let the LLM retrieve external data (such as data from NetSuite using SuiteQL), perform calculations, or trigger business logic as part of an LLM interaction. By providing tools that the LLM can request, the LLM can use the tool results to generate more accurate and dynamic responses.

After you create a tool definition, you can provide it to llm.generateText(options) or llm.generateTextStreamed(options) using the options.tools parameter. Doing so makes the tool available for the LLM to request during an interaction. You can create and provide multiple tool definitions based on your use cases.

Returns

llm.Tool

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/llm Module

Since

2025.2

Parameters

Parameter

Type

Required / Optional

Description

Since

options.description

string

required

A description of what the tool does.

This parameter helps the LLM understand when to request the tool.

2025.2

options.name

string

required

A unique identifier for the tool.

This parameter is used when the LLM refers to this tool in tool call requests (which are represented as llm.ToolCall objects).

2025.2

options.parameters

llm.ToolParameter[]

required

An array of tool parameters, which are created using llm.createToolParameter(options).

These parameters specify the input values required to run the tool.

2025.2

Syntax

Important:

The following code sample shows the syntax for this member. It isn't a functional example. For a complete script example, see N/llm Module Script Samples.

            // Add additional code
...

const findUserIdTool = llm.createTool({
    name: "findUserId",
    description: "Looks up user ID based on user name",
    parameters: [
        llm.createToolParameter({
            name: "userName",
            description: "Name of the user",
            type: llm.ToolParameterType.STRING
        })
    ]
});

...
// Add additional code 

          

Related Topics

General Notices