Unlocking the Power of LLM Models in NetSuite with SuiteScript

Explore how to leverage LLM models in SuiteScript for enhanced AI-driven solutions in Oracle NetSuite.

·View Oracle Docs

With the evolution of artificial intelligence, integrating generative AI capabilities into business solutions like NetSuite has become essential for staying ahead in modern business environments. NetSuite developers can now utilize Large Language Models (LLMs) through SuiteScript 2.1 to enhance their applications’ responsiveness and intelligence.

Understanding Model Capabilities in SuiteScript

NetSuite's SuiteScript provides a robust framework for incorporating AI functionalities by supporting various LLM models. These models, accessed via methods like llm.generateText(options) and llm.generateTextStreamed(options), offer features that bring a new dimension to automation and intelligence. Here's a closer look at some key capabilities:

  • Retrieval-Augmented Generation (RAG): This feature enables the LLM to draw from a list of provided documents (llm.Document objects) when formulating responses. It's particularly useful for creating contextually aware applications that need to enhance their output with data from external sources. Note that RAG is currently supported only by specific models like cohere.command-a-03-2025.

  • Preambles: Developers can set the tone or provide a guiding narrative to the LLM using a preamble (options.preamble). This helps in shaping the kind of responses generated, creating consistency in communication and output style, and is supported across more model types.

Choosing the Right Model

When working with LLMs in NetSuite, selecting the appropriate model is crucial as it can impact the functionality and the accuracy of responses.

  • ModelFamily.COHERE_COMMAND: This is the default choice if no specific model is mentioned. It supports both RAG and preambles.
  • ModelFamily.GPT_OSS: Known for supporting preambles, this model is ideal if your use case does not rely on retrieval-augmented content.

Implementing LLM Responses

NetSuite's N/llm module offers seamless integration with different script types, primarily server scripts. As of version 2024.1, these methods are available in SuiteScript for advanced AI interaction.

Here's a brief overview of how you can start utilizing these features:

  • Basic Invocation: Use the llm.generateText or llm.generateTextStreamed methods to initiate an LLM response for a given prompt. The streamed version allows handling partial responses, ideal for scenarios requiring real-time updates.

    var response = llm.generateTextStreamed({ prompt: "Summarize quarterly sales data." });
    response.iterator().each(function(token) {
        log.debug("Token: " + token.value);
        return true;
    });
    
  • Using Additional Context: By specifying documents and preambles, you can significantly enrich the responses. For instance, adding a document parameter lets the LLM use precise business data to tailor its responses.

Best Practices

  • Governance Awareness: Utilization of LLM features in NetSuite follows a governance limit of 100 units. Plan your script execution accordingly to avoid exceeding limits.

  • Version Consideration: Be mindful of the version specifics, as some features and supported models may only be available in certain SuiteScript versions (like 2024.1 and onward).

Key Takeaways

  • Utilize Retrieval-Augmented Generation (RAG) to enhance AI responses with relevant document data.
  • Preambles help guide the LLM's output tone and style, suitable for maintaining consistent communication across systems.
  • Choose models aligned with your specific use case requirements, balancing between supported features and model capabilities.
  • Implement in SuiteScript 2.1, with a focus on balancing governance units to optimize performance.

Leveraging LLMs in NetSuite can revolutionize how businesses interact with their data and customers. By integrating intelligently designed AI responses, organizations are better equipped to handle complex datasets and provide insightful, context-driven communication.

Source: Values — Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.