For developers, NetSuite exposes generative AI programmatically through the N/llm module, so you can call a large language model from your own SuiteScript. This page is part of our AI in NetSuite series and is the technical companion to the feature-focused pages.
What N/llm Provides
The N/llm module lets a script send a prompt to NetSuite’s generative AI service and receive a text response, which you can then store on a record, show to a user, or feed into further logic. Because it runs inside SuiteScript, you can combine it with record and search operations, so the model works against your live NetSuite data rather than in isolation.
Example: Summarizing a Case in a User Event Script
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/llm', 'N/log'], (llm, log) => {
const afterSubmit = (context) => {
if (context.type !== context.UserEventType.CREATE) return;
const rec = context.newRecord;
const details = rec.getValue({ fieldId: 'incomingmessage' });
const response = llm.generateText({
prompt: 'Summarize this support case in one sentence: ' + details
});
log.audit('AI summary', response.text);
};
return { afterSubmit };
});
This is illustrative; confirm the exact method names, parameters, and governance costs in the current NetSuite documentation, as the module’s API surface evolves between releases.
A Real-World Scenario: Auto-Tagging Records
A services firm wanted every new project record tagged with a short theme for reporting. A User Event script sends the project description to N/llm, asks for a two-word category, and writes it to a custom field. Analysts then group projects by theme without anyone tagging manually. Because a human periodically audits the generated tags, drift is caught and the prompt is refined.
Good Practices
Mind governance usage, since AI calls are not free in units, and avoid calling the model in tight loops. Never send sensitive data you would not want processed by an external model, and always validate model output before acting on it automatically. For the definitive API, see the current NetSuite documentation for the N/llm module.