llm.createDocument(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Creates a document with the specified ID and content.

A document represents source content that you can provide as additional context to the LLM when you call llm.generateText(options) or llm.generateText.promise(options). The LLM uses information in the provided documents to augment its response using retrieval-augmented generation (RAG). For more information about RAG, see What Is Retrieval-Augmented Generation (RAG)?

You do not need to use this method to create a document before providing the document to llm.generateText(options) or llm.generateText.promise(options). You can also provide a plain JavaScript object that uses the id and data properties, similar to the following example:

                    var response = llm.generateText({
    prompt: "My test prompt",
    documents: [{
        id: "doc1",
        data: "Content of doc1"
    },{
        id: "doc2",
        data: "Content of doc2"
    }]
}); 

                  

Returns

llm.Document

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/llm Module

Since

2025.1

Parameters

Parameter

Type

Required / Optional

Description

Since

options.data

string

required

The content of the document.

2025.1

options.id

string

required

The ID of the document.

2025.1

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/llm Module Script Samples.

            // Add additional code
...

const doc1 = llm.createDocument({
    id: "doc1",
    data: "My document data"
});

...
// Add additional code 

          

Related Topics

General Notices