N/llm Module: llm.createTool Lets Scripts Define Callable Tools for LLM Interactions
SuiteScript 2.1 gains llm.createTool(options) in the N/llm module, enabling server scripts to define tool-calling functions that an LLM can invoke mid-generation to pull NetSuite data, run calculations, or trigger business logic.
What changed
The N/llm module now exposes llm.createTool(options), allowing server-side SuiteScript 2.1 to define tool definitions that a large language model can request during a llm.generateText(options) or llm.generateTextStreamed(options) call. This follows the standard agentic tool-calling pattern: you describe what a tool does, what parameters it accepts, and the LLM decides at inference time whether to invoke it.
API surface
- Method:
llm.createTool(options) - Returns:
llm.Tool - Governance: None (creating the definition itself costs zero governance units; governance for the tool's own logic — e.g., SuiteQL queries — is still counted when you execute it)
- Script types: Server scripts only
- Module:
N/llm(since 2025.2)
Required parameters
options.name(string) — unique identifier the LLM uses when it emits allm.ToolCallreferencing this tool.options.description(string) — natural-language description that tells the LLM when to request the tool. Quality of this description directly affects whether the model invokes the tool at the right time.options.parameters(llm.ToolParameter[]) — array of parameter definitions created viallm.createToolParameter(options). Each parameter specifies aname,description, andtype(e.g.,llm.ToolParameterType.STRING).
Example skeleton
The following illustrates definition only (not execution):
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
})
]
});Once defined, pass one or more llm.Tool objects to llm.generateText({ tools: [findUserIdTool] }). The LLM may then return llm.ToolCall objects in its response, which your script must handle — execute the requested logic, feed the results back, and optionally continue the generation loop.
Key considerations
- Tool execution is your responsibility.
createToolonly declares the schema. When the LLM returns allm.ToolCall, your script must match ontoolCall.name, extract the arguments, run the operation (SuiteQL query, record load, REST call, etc.), and return the result. Oracle's documentation does not yet detail the exact response-looping mechanism — check the N/llm Module Script Samples page for the full round-trip pattern. - Governance is indirect. The
createToolcall itself is free, but every SuiteScript API you call inside your tool handler (e.g.,query.runSuiteQL,record.load) still counts its normal governance units. Plan your unit budget for the worst-case number of tool invocations per generation. - Server scripts only. Client scripts, user-event scripts running client-side, and Suitelets with client-side entry points cannot use this API.
- Description quality matters. The LLM chooses tools based on
options.description. Vague descriptions lead to missed or incorrect invocations. Be specific about what data the tool returns and under what conditions it should be called.
What to do
- Review the full N/llm module documentation, especially
llm.generateText,llm.generateTextStreamed,llm.createToolParameter,llm.ToolCall, andllm.ToolParameterType— these form the complete tool-calling lifecycle. - Start with a single tool per generation call to validate the round-trip before adding multi-tool orchestration.
- Budget governance units for the SuiteScript operations inside your tool handlers, not just for the
createToolcall. If the LLM invokes a tool multiple times in one session, governance can add up quickly. - Write precise
descriptionstrings. Include what data the tool returns, what entity it operates on, and any constraints. Treat these like API docstrings, not marketing copy. - Gate sensitive operations. Because the LLM decides when to invoke tools, ensure your tool handlers validate inputs and enforce permissions before executing record writes, workflow triggers, or external API calls.
Source: Oracle NetSuite Release Notes