Skip to main content

@evalgate/sdk TypeScript reference

Practical reference for @evalgate/sdk — generated OpenAPI access, purpose-built helpers, traces, evaluations, judges, WorkflowTracer, and integrations.
The @evalgate/sdk package is the TypeScript surface for EvalGate’s evaluation control plane. Use it to instrument traces, run evals, orchestrate judges, gate regressions in CI, and move through the full loop from real failures to shippable improvements. PRODUCT_CAPABILITY_CONTRACT exposes the same versioned workflow-navigation map as evalgate capabilities --format json. Agents can discover the web route, native TypeScript/Python commands, public operations, artifacts, and next step for each governed core workflow without scraping help text. From contract schema 3, capabilities that span operations with different permissions also declare those operations, and selectCapabilityOperation() (evalgate capabilities select --intent <intent>) resolves a stated intent plus already-demonstrated context to one supported operation, or to a typed missing-precondition reason. Selection is ordered by the contract’s explicit precedence, so it does not depend on the order of the capability array. The context you pass is informational: it states what has been demonstrated and never itself grants authority, unrecognised values are ignored rather than honoured, and the named command still authorizes for itself when it runs.
Operation selection landed after the published @evalgate/sdk@3.10.0 package was cut, so it is available from source and not yet from npm. Do not assume selectCapabilityOperation() or capabilities select from an installed 3.10.0 package until a later release is verified. See feature status.

Package info

The table follows the published @evalgate/sdk@3.10.0 package.

Install

Export traces over OTLP / OpenInference

EvalGate can export the same normalized workflow trace used by local promotion to an existing OpenTelemetry collector. This is a trace-only integration: it does not replace the offline gate or require a provider key.
The mapping preserves agent/tool/LLM/retrieval span types, timestamps, errors, token metrics, and OpenInference-compatible input.value and output.value attributes. Completed traces can be exported after endWorkflow(); payload content requires the explicit capturePayloads: true opt-in.

Initialize the client

Every request sends an Authorization: Bearer <apiKey> header. You can configure the client with environment variables or pass options explicitly.
Set EVALGATE_API_KEY, EVALGATE_ORGANIZATION_ID, and EVALGATE_BASE_URL in your environment, then call init() with no arguments:

Call any public OpenAPI operation

Import OpenApiClient from @evalgate/sdk/openapi when you need a public operation that does not have a purpose-built helper. Operation IDs, paths, methods, parameter names, body requirements, and request/response types are generated from the same OpenAPI document used by the API reference.
Pass an AbortSignal through signal to cancel a request. For an operation that declares cursor, offset, or page pagination in OpenAPI, use the bounded async iterator:
The client rejects unknown operation IDs, undeclared parameters, missing required parameters or bodies, repeated cursors, and pagination beyond maxPages. API errors retain their status, code, request ID, and structured details.

Client modules

The client exposes the following API modules:

Prompt Hub and Dataset Hub

The Hub clients expose the governed lifecycle directly, including idempotency keys and expected revisions for mutations:
Use evalgate datasets for the same create/import/version/publish/bind workflow from automation, or evalgate api <operation-id> for every other mapped Hub operation.

Evaluation packs, Playground, and repository intelligence

The matching native CLI workflow is evalgate repo followed by evalgate packs after reviewing its evidence; evalgate playground turns selected traces into governed cases. Repository scanning reads protected source at one exact commit and never executes repository code; source detection is not represented as runtime confirmation.

TraceAPI

Use client.traces to create and manage traces and their spans.

EvaluationAPI

Use client.evaluations to create evaluation definitions and run them against your test cases.

LLMJudgeAPI

Use client.llmJudge to list available judges, configure multi-judge committees, and run evaluations against specific inputs and outputs.
Create a multi-judge committee and evaluate a specific input/output pair:

createTestSuite

Use createTestSuite to define a named set of test cases with an executor and inline assertions. The runner handles execution, parallelism, and reporting.
repetitions runs every case independently more than once. minimumPassRate controls how many trials must pass; it defaults to 1, so a single failed trial fails the case. Retries remain recovery attempts within one trial and are reported as flaky evidence when they recover. A case is also flaky when trial outcomes or serialized outputs differ.

Portable evaluators, trajectories, and backfills

Promptfoo and DeepEval result imports

Use importPromptfooResults or importDeepEvalResults to normalize existing result artifacts into one content-addressed case shape. The adapters preserve inputs, actual and expected output, pass state, score, named metrics, source, and source hash without loading either third-party runtime.
This is a portable import boundary. Unsupported provider/plugin execution and third-party-specific red-team orchestration remain in their owning runtimes. Evaluators accept inputs, outputs, optional referenceOutputs, context, attachments, and metadata. Scalar, tuple, keyed, and multi-result returns normalize to keyed boolean-or-number feedback.
Backfills never call the target model or alter captured observations. Their checkpoints are pinned to the evaluator version and the hashed observation set. createDatasetSnapshot, selectDatasetSplits, and runSummaryEvaluators provide content-hashed dataset versions, explicit split membership, and dataset-level metrics. Vitest and Jest can emit the same deterministic evidence artifact through createVitestEvidenceReporter and createJestEvidenceReporter from @evalgate/sdk/test-evidence. Both adapters are opt-in and perform no network calls.

Import LangSmith run exports

Use the pure converter to inspect a LangSmith export before writing anything, then send the same data through the collector-backed importer:
The converter accepts a run array or { runs: [...] }, groups runs by trace_id, orders spans by dotted_order, and preserves parent links, inputs and outputs, timing, errors, token usage, cost, tags, feedback summaries, and source IDs. Invalid and duplicate run IDs are reported instead of replaced with invented identities. Uploads use the shared trace collector in bounded batches and preserve partial failure details. This is an explicit import boundary; normal evaluation does not require the hosted LangSmith runtime.

Import external judge behaviors and env-run trajectories

EvalGate can consume companion open-source signals without taking a Judgment Labs, Orchard, or Frontis runtime dependency:
OTLP/OpenInference remains the primary trace-only path. External judge scores and gym trajectories are explicit import boundaries: they must carry content hashes before binding to evalgate gate / baselines, and EvalGate does not host Orchard or OpenMLE training runtimes.

WorkflowTracer

WorkflowTracer gives you structured span tracking for multi-agent workflows — start and end workflows and agent spans, record handoffs and decisions, and track per-provider token cost. To compare delegation strategies using bounded local metadata, follow Evaluate your subagents. Workflow spans alone do not prove inherited context or complete task-tree cost.

Instantiate

Method signatures

WorkflowDefinition shape:
Wrap any async function as a named workflow step without manual start/end calls:

Full example

OpenAI integration

Import traceOpenAI from the ./integrations/openai export and pass an AIEvalClient to record calls. WorkflowTracer is for workflow instrumentation and is not the wrapper’s collector client:
The ./integrations/anthropic export provides an equivalent traceAnthropic wrapper for Anthropic clients. Both require the respective peer dependency to be installed.