Skip to main content
Represents the API client for interacting with the Literal service. This class handles API requests, authentication, and provides methods for various operations supported by the Literal API. To use this API, you need to initialize a LiteralClient and access the API through it:
Then you can use the api object to make calls to the Literal service.

Methods

getProjectId()

Get the project id associated with the API key. Returns Promise<string> the project id

sendSteps()

Sends a collection of steps to the GraphQL endpoint. This method constructs a GraphQL query using the provided steps, then executes the query. Parameters Returns

getSteps()

Retrieves a paginated list of steps (runs) based on the provided criteria. Parameters Returns

getStep()

Retrieves a step by its ID. This method constructs a GraphQL query to fetch a step by its unique identifier. It then executes the query and returns the step if found. Parameters Returns

deleteStep()

Deletes a Step from the platform by its unique identifier. This method constructs a GraphQL mutation to delete a step by its unique identifier. It then executes the mutation and returns the ID of the deleted step. Parameters Returns

uploadFile()

uploadFile(params)
Uploads a file to a specified thread. This method supports uploading either through direct content or via a file path. It first signs the upload through a pre-configured endpoint and then proceeds to upload the file using the signed URL. Parameters Returns Throws Throws an error if neither content nor path is provided, or if the server response is invalid. uploadFile(params)
Parameters Returns Promise<object>

createAttachment()

createAttachment(params)
Uploads a file to a specified thread and creates an attachment object. If called inside a context, the attachment will be added to the current step and thread. Parameters Returns Throws Throws an error if neither content nor path is provided, or if the server response is invalid. createAttachment(params)
Parameters Returns Promise<Attachment>

getGenerations()

Retrieves a paginated list of Generations based on the provided filters and sorting order. Parameters Returns

createGeneration()

Creates a new generation entity and sends it to the platform. Parameters Returns

upsertThread()

upsertThread(options)
Upserts a Thread with new information. Parameters Returns upsertThread(threadId, name, metadata, participantId, tags)
Upserts a Thread with new information. Parameters Returns Deprecated Use one single object attribute instead of multiple parameters.

getThreads()

Retrieves a paginated list of threads (conversations) based on the provided criteria. Parameters Returns

getThread()

Retrieves information from a single Thread. Parameters Returns

deleteThread()

Deletes a single Thread by its unique identifier. Parameters Returns

getUsers()

Retrieves a list of users with optional filters. Parameters Returns

createUser()

Creates a new user and sends it to the platform. Parameters Returns

updateUser()

Updates an existing user’s details in the platform. Parameters Returns

getOrCreateUser()

Retrieves an existing user by their identifier or creates a new one if they do not exist. Parameters Returns

getUser()

Retrieves a user by their unique identifier. Parameters Returns

deleteUser()

Deletes a single user by their unique identifier. Parameters Returns

getScores()

Get all scores connected to the platform. Parameters Returns

createScores()

Creates multiple scores in the database using the provided array of scores. Each score in the array is transformed into a GraphQL mutation call. Parameters Returns

createScore()

Creates a new score in the database using the provided parameters. Parameters Returns

updateScore()

Updates an existing score in the database. Parameters Returns

deleteScore()

Deletes a single score from the database. Parameters Returns

getDatasets()

List all datasets in the platform. Returns

createDataset()

Creates a new dataset in the database. Parameters Returns

getDataset()

Retrieves a dataset based on provided ID or name. Parameters Returns

updateDataset()

Updates a dataset with new information. Parameters Returns

deleteDataset()

Deletes a single dataset by its unique identifier. Parameters Returns

createDatasetItem()

Creates a new item in a dataset. Parameters Returns

getDatasetItem()

Retrieves a single item from a dataset by its unique identifier. Parameters Returns

deleteDatasetItem()

Deletes a single item from a dataset by its unique identifier. Parameters Returns

addStepToDataset()

Adds a single step item to a dataset. Parameters Returns

addGenerationToDataset()

Adds a generation item to a dataset. Parameters Returns

addGenerationsToDataset()

Adds multiple generation items to a dataset. Parameters Returns Promise<DatasetItem[]> An array of DatasetItem instances populated with the data of the newly added generations

createExperiment()

Creates a new dataset experiment. Parameters Returns

createExperimentItem()

Creates a new dataset experiment item. Parameters Returns

createPromptLineage()

Create a new prompt lineage. Parameters Returns

createPrompt()

Parameters Returns Promise<Prompt> Deprecated Please use getOrCreatePrompt instead.

getOrCreatePrompt()

A Prompt is fully defined by its name, template_messages, settings and tools. If a prompt already exists for the given arguments, it is returned. Otherwise, a new prompt is created. Parameters Returns

getPromptById()

Retrieves a prompt by its id. Parameters Returns

getPrompt()

Retrieves a prompt by its name and optionally by its version. Parameters Returns

getPromptAbTesting()

Retrieves a prompt A/B testing rollout by its name. Parameters Returns

updatePromptAbTesting()

Update a prompt A/B testing rollout by its name. Parameters Returns