Skip to Content
SDK ReferenceRunning Evals

Running Evals

The run() method is the core of the SDK — it triggers an evaluation and returns the results.

run() never throws on transient network failures. After 3 automatic retries on network, 5xx, or 429 errors, the SDK returns a neutral { status: "skipped", passed: true } result so your application keeps running. You only need try/catch for AuthError (invalid key), PaymentError (usage limit reached), and ValidationError (bad request). See Error Handling for the full matrix.

Method signature

async run(suite: string, options: RunOptions): Promise<RunResult>

Parameters

ParameterTypeDescription
suitestringThe eval suite slug (e.g., "rag-faithfulness")
optionsRunOptionsRun configuration (see below)

RunOptions

PropertyTypeDefaultDescription
outputstringrequiredThe AI-generated output to evaluate
inputobject{}Input data passed to scorers (e.g., context, query)
triggerstring"sdk"Source identifier: "sdk", "cli", "github_action", "dashboard", "api"
triggerMetaobject{}Additional metadata (e.g., git SHA, PR number)
asyncbooleanfalseIf true, returns immediately with a pending run ID

RunResult

PropertyTypeDescription
idstringUnique run identifier
passedbooleantrue if status is "cleared"
statusstring"cleared", "aborted", "skipped", "error", or "pending"
scoresScore[]All individual case scores
failuresScore[]Only the failed case scores
passRatenumber0.0–1.0 ratio of passed cases
totalCasesnumberTotal active cases evaluated
passedCasesnumberNumber of passing cases
failedCasesnumberNumber of failing cases
durationMsnumberTotal evaluation time in milliseconds

Score

PropertyTypeDescription
casestringCase name
passedbooleanWhether the case passed its threshold
scorenumber0.0–1.0 score from the scorer
thresholdnumberThe case’s pass threshold
reasonstringHuman-readable explanation

Examples

Basic evaluation

const result = await lg.run("content-safety", { output: "The capital of France is Paris.", }); console.log(result.status); // "cleared" console.log(result.passRate); // 1.0

With input context

const result = await lg.run("rag-faithfulness", { input: { context: "The Eiffel Tower was completed in 1889 for the World's Fair.", query: "When was the Eiffel Tower built?", }, output: "The Eiffel Tower was completed in 1889.", });

With trigger metadata

const result = await lg.run("my-suite", { output: generatedText, trigger: "sdk", triggerMeta: { commitSha: process.env.GIT_SHA, branch: process.env.GIT_BRANCH, model: "gpt-4o", promptVersion: "v2.3", }, });

Async mode

const pending = await lg.run("large-suite", { output: "...", async: true, }); console.log(pending.id); // "run_abc123" console.log(pending.status); // "pending" // Poll for results const completed = await lg.getRun(pending.id);

Additional methods

getRun(runId)

Fetch the status and details of a run.

const run = await lg.getRun("run_abc123");

getRunResults(runId)

Fetch detailed per-case results for a run.

const results = await lg.getRunResults("run_abc123");

health()

Check the LaunchGate API health status.

const status = await lg.health(); // { status: "healthy", version: "0.1.0", timestamp: "...", services: {...} }
Last updated on