evalgate-sdk Python reference
Practical reference for evalgate-sdk — generated OpenAPI access, purpose-built helpers, async usage, tracing, evaluations, judges, test suites, and CLI commands.The
evalgate-sdk package is the Python surface for EvalGate’s evaluation control plane. Purpose-built helpers use snake_case names. The generated OpenAPI client provides structural access to every public REST operation by stable operation ID; it does not imply that every operation has a dedicated convenience method.
PRODUCT_CAPABILITY_CONTRACT exposes the same versioned workflow-navigation
map as evalgate capabilities --format json. Agents can discover the web route,
native Python/TypeScript 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 select_capability_operation()
resolves a stated intent plus already-demonstrated context to one supported
operation, or to a typed missing-precondition reason. Both SDKs run the same
selection vectors, so the two surfaces cannot drift apart on what a caller may
do. 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.
Install
- Core SDK
- SDK + CLI
- With integrations
evalgate login completes a
human-approved device flow and stores the session outside the repository in the operating-system user
configuration directory. Windows uses %APPDATA%\evalgate\config.json, macOS
uses ~/Library/Application Support/evalgate/config.json, and Linux uses
${XDG_CONFIG_HOME:-~/.config}/evalgate/config.json; managed environments may
set an absolute EVALGATE_CONFIG_HOME. Repository configuration cannot provide
a bearer key or redirect a saved/environment key to another API origin.
Alternate origins require HTTPS except localhost and loopback development.
The source candidate also exposes evalgate init --local for a cloud coding
agent that needs a deterministic gate before any hosted setup. That command
requires no account, browser, organization, GitHub remote, API key, or network
request and creates no hosted identity. This is a source-parity statement, not a
claim about the older package currently published on PyPI.
The canonical PyPI package name is
evalgate-sdk. Import it as evalgate_sdk. If you have the legacy pauly4010-evalgate-sdk package installed, migrate to evalgate-sdk.The CrewAI and AutoGen tracing adapters are lightweight wrappers and do not install those frameworks. Install the CrewAI or AutoGen package used by your application separately.
Import and initialize
- Environment variables
- Explicit config
Set
EVALGATE_API_KEY and EVALGATE_ORGANIZATION_ID in your environment, then call init() with no arguments:Async usage
The Python SDK is async-first. Useasyncio.run() for top-level scripts, or await inside an async function:
Call any public OpenAPI operation
OpenApiClient consumes the generated operation registry shared with the public OpenAPI contract. Its operation_id type is a generated Literal union, and the runtime validates paths, query names, headers, body requirements, pagination, and cancellation.
CANCELLED SDK error.
Client methods
The purpose-built modules below use Pythonic snake_case names. They are convenience surfaces, not the public-operation inventory; useOpenApiClient for contract-generated access to operations not listed here.
Prompt Hub and Dataset Hub
evalgate datasets for the common governed
lifecycle and evalgate api <operation-id> for the complete generated public
operation registry.
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.
Traces
Evaluations
Prompt versions
Prompt-version operations use the generated OpenAPI contract in Python. This keeps path encoding, required parameters, and body validation on the same generated surface as the other public operations without adding a duplicate convenience layer.LLM judge
create_test_suite
Usecreate_test_suite to define named test cases with inline assertions. Import TestSuiteConfig and TestSuiteCase from evalgate_sdk.types to get full type hints:
repetitions runs every case independently more than once. minimum_pass_rate 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
Evaluators acceptinputs, outputs, optional reference_outputs, context, attachments, and metadata. Scalar, tuple, keyed, and multi-result returns normalize to keyed boolean-or-number feedback.
create_dataset_snapshot, select_dataset_splits, and run_summary_evaluators provide content-hashed dataset versions, explicit split membership, and dataset-level metrics.
The installed pytest plugin remains inert unless --evalgate-evidence or EVALGATE_EVIDENCE_PATH is set. Attach normalized inputs, outputs, references, and feedback from a running test with record_test_evidence(...):
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 uploader:{"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.
Companion open-source judge and gym/env exports follow the same import-boundary rule. Use the TypeScript SDK helpers importExternalJudgeBehaviors and importEnvRunToGoldenCase for Judgeval-shaped behavior scores and Orchard Env / OpenMLE-Gym shaped trajectories; EvalGate does not depend on those hosted runtimes.
WorkflowTracer
WorkflowTracer works the same way as in TypeScript — start and end workflows and agent spans, and record handoffs:
For bounded local delegation comparisons, see
Evaluate your subagents. Keep root outcomes,
child diagnostics, and actual context attribution distinct.
OpenAI integration
Use thetrace_openai helper to wrap an OpenAI client and automatically capture LLM spans:
CLI commands
Install the CLI withpip install evalgate-sdk and then run evalgate <command>.
Setup and initialization
Setup and initialization
--json is an alias for --format json on login, logout, whoami,
link, status, and open. JSON and non-TTY mutation remains
preview-only unless --apply is explicit. A saved human session is used
only after an explicit credential and EVALGATE_API_KEY; link itself
always requires the saved human session. An environment API key authorizes
automation against an already established hosted context; it cannot
bootstrap link and is unnecessary for init --local or gate.Repository linkage is durable across branch and commit movement. Each
cloud intake is separately pinned to
targetSha. For example, a checkout
two commits behind main remains linked and locally gate-ready; cloud
evidence may target that older commit when GitHub proves it is reachable
from main.Product understanding is Experimental in the current source tree. It is
local-only and is not a published-package, REST, or mounted-web
availability claim. See Feature status.
Running evaluations
Running evaluations
Gate and CI
Gate and CI
Repository intelligence and evaluation packs
Repository intelligence and evaluation packs
Run these authenticated commands after the local gate is working:
Analysis and labeling
Analysis and labeling
Autonomous loop
Autonomous loop
GitHub Actions example
The Python CLI spells the one-shot command
evalgate auto run; the TypeScript CLI uses npx @evalgate/sdk auto. Both CLIs expose bounded daemon cycles.