Class: Maxim
Defined in: src/lib/maxim.ts:147 Main class for the Maxim SDK that provides access to all platform features. The Maxim class is the primary entry point for interacting with the Maxim observability platform. It provides methods for prompt management, logging, dataset operations, and test run execution. The class handles authentication, caching, and API communication. MaximExamples
Constructors
Constructor
new Maxim(Defined in: src/lib/maxim.ts:199 Creates a new Maxim SDK instance.config
):Maxim
Parameters
config
Config
Configuration object for the SDK
Returns
Maxim
Throws
When the API key is not providedImportant
CRITICAL: Always callcleanup()
before your application
exits. Failure to do so may result in memory leaks, unflushed data, or
hanging processes. This is especially important in production environments
and long-running applications.
Examples
Methods
addDatasetEntries()
addDatasetEntries(Defined in: src/lib/maxim.ts:1123 This method is used to add entries to a datasetdatasetId
,entries
):Promise
<void
>
Parameters
datasetId
string
Dataset id to add entries to
entries
DatasetEntry
[]
Entries to add to the dataset
Returns
Promise
<void
>
void
Async
Example
cleanup()
cleanup():Defined in: src/lib/maxim.ts:1260 Cleans up all SDK resources and prepares for application shutdown. This method performs essential cleanup operations including stopping sync intervals, flushing logger data, clearing caches, and destroying HTTP agents. It ensures proper resource deallocation and prevents memory leaks.Promise
<void
>
Returns
Promise
<void
>
Async
Important
CRITICAL: Always call this method before your application exits. Failure to do so may result in memory leaks, unflushed data, or hanging processes. This is especially important in production environments and long-running applications.Examples
createTestRun()
createTestRun(Defined in: src/lib/maxim.ts:1220 This method is used to create a test runname
,inWorkspaceId
):TestRunBuilder
<undefined
>
Parameters
name
string
Name of the test run
inWorkspaceId
string
Workspace Id to create the test run in
Returns
TestRunBuilder
<undefined
>
Test run instance
Example
getFolderById()
getFolderById(Defined in: src/lib/maxim.ts:1041 This method is used to get a folder by idfolderId
):Promise
<undefined
|Folder
>
Parameters
folderId
string
Folder id to fetch
Returns
Promise
<undefined
| Folder
>
a single folder
Async
Throws
If no folder found with idExample
getFolders()
getFolders(Defined in: src/lib/maxim.ts:1081 This method is used to get all folders that match the query rulerule
):Promise
<undefined
|Folder
[]>
Parameters
rule
QueryRule
Query rule to match
Returns
Promise
<undefined
| Folder
[]>
Array of folders
Async
Throws
If no folders found matching the query ruleExample
getPrompt()
getPrompt(Defined in: src/lib/maxim.ts:768 Retrieves a specific prompt by ID that matches the given query rule. This method fetches a prompt from the Maxim platform based on deployment rules and query criteria. It supports versioning and rule-based prompt selection.promptId
,rule
):Promise
<undefined
|Prompt
>
Parameters
promptId
string
The unique identifier of the prompt to fetch
rule
QueryRule
Query rule defining deployment variables, tags, and matching criteria
Returns
Promise
<undefined
| Prompt
>
The matching prompt with run capabilities, or undefined if not found
Async
Throws
When prompt management is not enabledThrows
When no active deployments found for the prompt matching the query ruleExamples
getPromptChain()
getPromptChain(Defined in: src/lib/maxim.ts:919 Retrieves a specific prompt chain by ID that matches the given query rule. This method fetches a prompt chain from the Maxim platform based on deployment rules and query criteria. It supports versioning and rule-based prompt chain selection. Prompt chains allow you to orchestrate multiple prompts in sequence with conditional logic.promptChainId
,rule
):Promise
<undefined
|PromptChain
>
Parameters
promptChainId
string
The unique identifier of the prompt chain to fetch
rule
QueryRule
Query rule defining deployment variables, tags, and matching criteria
Returns
Promise
<undefined
| PromptChain
>
The matching prompt chain with run capabilities, or undefined if not found
Async
Throws
When prompt management is not enabledThrows
When no active deployments found for the prompt chain matching the query ruleExamples
getPromptChains()
getPromptChains(Defined in: src/lib/maxim.ts:990 Retrieves all prompt chains that match the given query rule. This method fetches multiple prompt chains from the Maxim platform based on deployment rules and query criteria. Useful for getting all prompt chains within a specific folder or matching certain deployment variables.rule
):Promise
<undefined
|PromptChain
[]>
Parameters
rule
QueryRule
Query rule defining deployment variables, tags, and matching criteria
Returns
Promise
<undefined
| PromptChain
[]>
Array of matching prompt chains with run capabilities, or undefined if none found
Async
Throws
When prompt management is not enabledThrows
When no active deployments found for any prompt chain matching the query ruleExamples
getPrompts()
getPrompts(Defined in: src/lib/maxim.ts:839 Retrieves all prompts that match the given query rule. This method fetches multiple prompts from the Maxim platform based on deployment rules and query criteria. Useful for getting all prompts within a specific folder or matching certain deployment variables.rule
):Promise
<undefined
|Prompt
[]>
Parameters
rule
QueryRule
Query rule defining deployment variables, tags, and matching criteria
Returns
Promise
<undefined
| Prompt
[]>
Array of matching prompts with run capabilities, or undefined if none found
Async
Throws
When prompt management is not enabledThrows
When no active deployments found for any prompt matching the query ruleExamples
logger()
logger(Defined in: src/lib/maxim.ts:1173 Creates a logger instance for capturing observability data. The logger provides methods for tracking sessions, traces, generations, and other observability events. It handles buffering, batching, and sending data to the Maxim platform.config
):Promise
<undefined
|MaximLogger
>
Parameters
config
LoggerConfig
Configuration for the logger instance
Returns
Promise
<undefined
| MaximLogger
>
Logger instance for capturing observability data, or undefined if creation fails