Skip to main content

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. Maxim

Examples

Constructors

Constructor

new Maxim(config): Maxim
Defined in: src/lib/maxim.ts:199 Creates a new Maxim SDK instance.

Parameters

config
Config Configuration object for the SDK

Returns

Maxim

Throws

When the API key is not provided

Important

CRITICAL: Always call cleanup() 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(datasetId, entries): Promise<void>
Defined in: src/lib/maxim.ts:1123 This method is used to add entries to a dataset

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(): Promise<void>
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.

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(name, inWorkspaceId): TestRunBuilder<undefined>
Defined in: src/lib/maxim.ts:1220 This method is used to create a test run

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(folderId): Promise<undefined | Folder>
Defined in: src/lib/maxim.ts:1041 This method is used to get a folder by id

Parameters

folderId
string Folder id to fetch

Returns

Promise<undefined | Folder> a single folder

Async

Throws

If no folder found with id

Example


getFolders()

getFolders(rule): Promise<undefined | Folder[]>
Defined in: src/lib/maxim.ts:1081 This method is used to get all folders that match the query rule

Parameters

rule
QueryRule Query rule to match

Returns

Promise<undefined | Folder[]> Array of folders

Async

Throws

If no folders found matching the query rule

Example


getPrompt()

getPrompt(promptId, rule): Promise<undefined | Prompt>
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.

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 enabled

Throws

When no active deployments found for the prompt matching the query rule

Examples


getPromptChain()

getPromptChain(promptChainId, rule): Promise<undefined | PromptChain>
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.

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 enabled

Throws

When no active deployments found for the prompt chain matching the query rule

Examples


getPromptChains()

getPromptChains(rule): Promise<undefined | PromptChain[]>
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.

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 enabled

Throws

When no active deployments found for any prompt chain matching the query rule

Examples


getPrompts()

getPrompts(rule): Promise<undefined | Prompt[]>
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.

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 enabled

Throws

When no active deployments found for any prompt matching the query rule

Examples


logger()

logger(config): Promise<undefined | MaximLogger>
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.

Parameters

config
LoggerConfig Configuration for the logger instance

Returns

Promise<undefined | MaximLogger> Logger instance for capturing observability data, or undefined if creation fails

Async

Throws

When the specified log repository is not found

Example