N/llm Module — Full SuiteScript 2.1 Generative AI API Surface
The N/llm module exposes generative AI capabilities in server-side SuiteScript 2.1, including text generation, RAG with citations, vector embeddings, image analysis, streaming responses, Prompt Studio integration, and LLM tooling — all metered by AI Units.
This is a module reference page, not a point-in-time release note. It documents the full API surface of N/llm as currently published. No specific NetSuite release version is stated in the source; features described here have been added incrementally across multiple releases. Verify your account's version and region eligibility before adopting.
What the module provides
The N/llm module is server-script-only (no client-side support) and requires the Server SuiteScript feature. Every LLM call consumes AI Units — check remaining budget at runtime with llm.getRemainingUsage().
Core methods
llm.generateText(options)— send a prompt to an LLM, get aResponseobject back. Alias:llm.chat(options).llm.generateTextStreamed(options)— same, but returns aStreamedResponseso you can process tokens as they arrive. Alias:llm.chatStreamed(options).llm.evaluatePrompt(options)— evaluate a prompt stored in Prompt Studio by its internal ID, passing variable values at call time. Model and parameters come from the prompt definition. Alias:llm.executePrompt(options).llm.evaluatePromptStreamed(options)— streamed variant. Alias:llm.executePromptStreamed(options).llm.embed(options)— convert text to vector embeddings for semantic search, classification, recommender systems, etc.llm.createTool(options)/llm.createToolParameter(options)/llm.createToolResult(options)— define custom tools the LLM can invoke mid-conversation (e.g., run a SuiteQL query, call business logic). The LLM returnsToolCallobjects; your script executes them and feedsToolResultobjects back.llm.createChatMessage(options)— construct aChatMessagewith a role (llm.ChatRole) and text for multi-turn conversations.llm.createDocument(options)— create aDocument(id + data) for RAG; pass an array of these togenerateText. The response includesCitationobjects with start/end positions and source document IDs.
All non-streamed methods have .promise() async variants.
Enums
llm.ModelFamily— selects the LLM for text generation (set viaoptions.model).llm.EmbedModelFamily— selects the embedding model (set viaoptions.embedModelFamily).llm.ChatRole— role for chat messages (user, assistant, system, tool).llm.SafetyMode— controls content safety filtering ongenerateText/generateTextStreamed.llm.ToolParameterType— data type for tool parameters.llm.Truncate— truncation strategy when embedding input exceeds 512 tokens.
Image support
The Cohere Command A Vision model accepts images via llm.generateText(options) and llm.generateTextStreamed(options). Use cases include advanced captioning, chart/graph analysis, and visual Q&A.
Response objects
Response—text,chatHistory,citations,documents,model,toolCalls,usage(prompt/completion/total token counts).StreamedResponse— identical shape; tokens arrive incrementally.EmbedResponse—embeddings(number[]),inputs,model.
Deprecated methods — stop using these
llm.getRemainingFreeUsage()— now just proxies tollm.getRemainingUsage().llm.getRemainingFreeEmbedUsage()— same redirect; embed usage is no longer tracked separately from other AI Unit consumption.
If your code calls either deprecated method, replace it with llm.getRemainingUsage().
Prompt & Text Enhance management
You can CRUD prompts and Text Enhance actions programmatically via N/record. The source references a separate help topic (Managing Prompts and Text Enhance Actions Using the N/llm Module) but does not specify the record type IDs here. Check SuiteAnswers for the exact record.Type values.
Constraints
- Server scripts only — no client-script, Suitelet-client, or portlet-client usage.
- Regional availability — N/llm is only enabled for accounts in certain OCI regions. See Generative AI Feature Availability in NetSuite in SuiteAnswers.
- AI Unit metering — every
generateText,evaluatePrompt, andembedcall costs AI Units. Monitor withllm.getRemainingUsage(). - Embeddings contain semantic information — Oracle explicitly warns that embeddings must be handled with the same data-sensitivity policies as the source text (storage, sharing, retention, deletion).
- No accuracy guarantees — Oracle disclaims liability for AI-generated content. Validate outputs before acting on them.
What to do
- Check region eligibility — confirm your account's data center is in a supported OCI region before writing any
N/llmcode. - Enable the feature — ensure Server SuiteScript is enabled (Setup > Company > Enable Features). No additional feature flag is mentioned for N/llm itself.
- Audit AI Unit budget — call
llm.getRemainingUsage()and build guard logic so batch scripts don't exhaust your allocation mid-run. - Replace deprecated calls — search your codebase for
getRemainingFreeUsageandgetRemainingFreeEmbedUsage; replace both withgetRemainingUsage. - Handle tooling round-trips — if you use
llm.createTool, your script must inspectResponse.toolCalls, execute the requested logic, buildToolResultobjects, and call the LLM again with the results. This is a multi-turn loop; plan governance unit consumption accordingly. - Protect embeddings — treat stored embedding vectors with the same access controls, encryption, and retention policies as the original text data.
- Prefer aliases for readability —
llm.chat(),llm.chatStreamed(),llm.executePrompt(), andllm.executePromptStreamed()are official aliases and safe to use in production.
Source: Oracle NetSuite Release Notes