SuiteScript
NetSuite Unknown
2026-08-25

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.

Affects:SuiteScript 2.1N/llmN/recordPrompt StudioAI 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 a Response object back. Alias: llm.chat(options).
  • llm.generateTextStreamed(options) — same, but returns a StreamedResponse so 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 returns ToolCall objects; your script executes them and feeds ToolResult objects back.
  • llm.createChatMessage(options) — construct a ChatMessage with a role (llm.ChatRole) and text for multi-turn conversations.
  • llm.createDocument(options) — create a Document (id + data) for RAG; pass an array of these to generateText. The response includes Citation objects 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 via options.model).
  • llm.EmbedModelFamily — selects the embedding model (set via options.embedModelFamily).
  • llm.ChatRole — role for chat messages (user, assistant, system, tool).
  • llm.SafetyMode — controls content safety filtering on generateText / 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 to llm.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, and embed call costs AI Units. Monitor with llm.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

  1. Check region eligibility — confirm your account's data center is in a supported OCI region before writing any N/llm code.
  2. Enable the feature — ensure Server SuiteScript is enabled (Setup > Company > Enable Features). No additional feature flag is mentioned for N/llm itself.
  3. Audit AI Unit budget — call llm.getRemainingUsage() and build guard logic so batch scripts don't exhaust your allocation mid-run.
  4. Replace deprecated calls — search your codebase for getRemainingFreeUsage and getRemainingFreeEmbedUsage; replace both with getRemainingUsage.
  5. Handle tooling round-trips — if you use llm.createTool, your script must inspect Response.toolCalls, execute the requested logic, build ToolResult objects, and call the LLM again with the results. This is a multi-turn loop; plan governance unit consumption accordingly.
  6. Protect embeddings — treat stored embedding vectors with the same access controls, encryption, and retention policies as the original text data.
  7. Prefer aliases for readability — llm.chat(), llm.chatStreamed(), llm.executePrompt(), and llm.executePromptStreamed() are official aliases and safe to use in production.