Skip to main content
The ZeroEval Python SDK provides seamless integration with your Python applications through automatic instrumentation and a simple decorator-based API.

Installation

Basic Setup

Run zeroeval setup once to save your API key securely to ~/.config/zeroeval/config.json
Need source-side PII redaction? Pass redaction={"enabled": True} to ze.init(...) or set ZEROEVAL_REDACT_PII=true. See PII redaction.

Patterns

Decorators

The @span decorator is the easiest way to add tracing:

Context Manager

For more control over span lifecycles:

Artifact Spans

When a single prompt run produces multiple judged outputs (e.g. a final decision and a customer card), use ze.artifact_span to mark each output as a named artifact. The prompt completions page surfaces the primary artifact as the row preview and lets you switch between artifacts in the detail view.
artifact_span defaults to kind="llm" and writes the completion_artifact_* attributes automatically. All other ze.span features (tags, sessions, prompt metadata inheritance) work the same way.
ze.artifact_span is available in the Python SDK only for now.

Advanced Configuration

Fine-tune the tracer behavior:

Context

Access current context information:

Sessions

Sessions group related spans together, making it easier to track complex workflows, user interactions, or multi-step processes.

Basic Session

Provide a session ID to associate spans with a session:

Named Sessions

For better organization in the dashboard, provide both an ID and a name:

Session Inheritance

Child spans automatically inherit the session from their parent:

Context Manager Sessions

Tags

Tags are key-value pairs attached to spans, traces, or sessions. They power the facet filters in the console so you can slice your telemetry by user, plan, model, tenant, or anything else.

Tag Once, Inherit Everywhere

Tags on the first span automatically flow down to all child spans:

Tag a Single Span

Tags provided on a specific span stay only on that span — they are not copied to siblings or parents:

Granular Tagging

Add tags at the span, trace, or session level after creation:

Feedback

To attach human or programmatic feedback to completions, see Human Feedback and the Feedback SDK docs. For automated quality evaluations, see Judges.

CLI Tooling

The Python SDK includes helpful CLI commands: