@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.
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.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 anAuthorization: Bearer <apiKey> header. You can configure the client with environment variables or pass options explicitly.
- Environment variables
- Explicit config
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
ImportOpenApiClient 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.
AbortSignal through signal to cancel a request. For an operation that declares cursor, offset, or page pagination in OpenAPI, use the bounded async iterator:
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: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
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
Useclient.traces to create and manage traces and their spans.
create — create a trace
create — create a trace
list — list traces
list — list traces
get — get a single trace
get — get a single trace
delete — delete a trace
delete — delete a trace
createSpan — add a span to a trace
createSpan — add a span to a trace
EvaluationAPI
Useclient.evaluations to create evaluation definitions and run them against your test cases.
create — create an evaluation
create — create an evaluation
createRun — create an evaluation run
createRun — create an evaluation run
listRuns / getRun — inspect evaluation runs
listRuns / getRun — inspect evaluation runs
prompt versions — list, activate, and roll back
prompt versions — list, activate, and roll back
LLMJudgeAPI
Useclient.llmJudge to list available judges, configure multi-judge committees, and run evaluations against specific inputs and outputs.
listRegistry — list available judges
listRegistry — list available judges
listPresets — list judge presets
listPresets — list judge presets
testConfig — configure and run a judge
testConfig — configure and run a judge
Create a multi-judge committee and evaluate a specific input/output pair:
createTestSuite
UsecreateTestSuite 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
UseimportPromptfooResults 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.
inputs, outputs, optional referenceOutputs, context, attachments, and metadata. Scalar, tuple, keyed, and multi-result returns normalize to keyed boolean-or-number feedback.
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:{ 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: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
startWorkflow
startWorkflow
WorkflowDefinition shape:endWorkflow
endWorkflow
startAgentSpan / endAgentSpan
startAgentSpan / endAgentSpan
traceWorkflowStep — inline helper
traceWorkflowStep — inline helper
Wrap any async function as a named workflow step without manual start/end calls:
Full example
OpenAI integration
ImporttraceOpenAI 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.