Langfuse JS/TS SDKs
    Preparing search index...

    Type Alias ExperimentResult<Input, ExpectedOutput, Metadata>

    Complete result of an experiment execution.

    Contains all results from processing the experiment data, including individual item results, run-level evaluations, and utilities for result visualization.

    const result = await langfuse.experiment.run(config);

    console.log(`Experiment ID: ${result.experimentId}`);

    // Access individual results
    console.log(`Processed ${result.itemResults.length} items`);

    // Check run-level evaluations
    const avgScore = result.runEvaluations.find(e => e.name === 'average_score');
    console.log(`Average score: ${avgScore?.value}`);

    // Print formatted results
    console.log(await result.format());

    // Print summary with individual item results
    console.log(await result.format({ includeItemResults: true }));

    // Link to the experiment (if the project could be resolved)
    if (result.experimentUrl) {
    console.log(`View in Langfuse: ${result.experimentUrl}`);
    }
    type ExperimentResult<
        Input = any,
        ExpectedOutput = any,
        Metadata extends Record<string, any> = Record<string, any>,
    > = {
        datasetRunId?: string;
        datasetRunUrl?: string;
        experimentId: string;
        experimentUrl?: string;
        format: (options?: { includeItemResults?: boolean }) => Promise<string>;
        itemResults: ExperimentItemResult<Input, ExpectedOutput, Metadata>[];
        runEvaluations: Evaluation[];
        runName: string;
    }

    Type Parameters

    • Input = any
    • ExpectedOutput = any
    • Metadata extends Record<string, any> = Record<string, any>
    Index

    Properties

    datasetRunId?: string

    ID of the dataset run in Langfuse (only for experiments on Langfuse datasets).

    Equal to experimentId. Use it with the experiments API (langfuse.api.experiments) to read the run back.

    datasetRunUrl?: string

    URL to the experiment in the Langfuse UI (only for experiments on Langfuse datasets).

    Use experimentUrl, which is also set for experiments on local data.

    experimentId: string

    Identifier of the experiment in Langfuse, shared by all items of the run.

    Equal to the experimentId parameter when one was passed. Otherwise, for Langfuse datasets, it is derived from the project, dataset and run name, so running again with the same runName continues the same experiment. For local data, it is a random ID.

    experimentUrl?: string

    URL to the experiment results in the Langfuse UI.

    Undefined if the project ID could not be fetched.

    format: (options?: { includeItemResults?: boolean }) => Promise<string>

    Function to format experiment results in a human-readable format.

    Generates a comprehensive, nicely formatted summary including individual results, aggregate statistics, evaluation scores, and links to traces and dataset runs.

    Type declaration

      • (options?: { includeItemResults?: boolean }): Promise<string>
      • Parameters

        • Optionaloptions: { includeItemResults?: boolean }

          Formatting options

          • OptionalincludeItemResults?: boolean

            Whether to include individual item details (default: false)

        Returns Promise<string>

        Promise resolving to formatted string representation

    Results from processing each individual data item.

    Contains the complete results for every item in your experiment data, including inputs, outputs, evaluations, and trace information. Use this for detailed analysis of individual item performance.

    runEvaluations: Evaluation[]

    Results from run-level evaluators that assessed the entire experiment.

    Contains aggregate evaluations that analyze the complete experiment, such as average scores, statistical measures, or overall quality assessments.

    runName: string

    The experiment run name.

    This is equal to the dataset run name if experiment was on Langfuse dataset. Either the provided runName parameter or generated name (experiment name + timestamp).