Skip to main content

Installation

Basic Setup

Replace hardcoded prompt strings with ze.prompt(). Your existing text becomes the fallback content that’s used until an optimized version is available.
That’s it. Every call to ze.prompt() is tracked, versioned, and linked to the completions it produces. You’ll see production traces at ZeroEval → Prompts.
When you provide content, ZeroEval automatically uses the latest optimized version from your dashboard if one exists. The content parameter serves as a fallback for when no optimized versions are available yet.

Version Control

Auto-optimization (default)

Uses the latest optimized version if one exists, otherwise falls back to the provided content.

Explicit mode

Always uses the provided content. Useful for debugging or A/B testing a specific version.

Latest mode

Requires an optimized version to exist. Fails with PromptRequestError if none is found.

Pin to a specific version

Prompt Library

For more control, use ze.get_prompt() to fetch prompts from the Prompt Library with tag-based deployments and caching.

Parameters

Return value

Returns a Prompt object with:

Model Deployments

When you deploy a model to a prompt version in the dashboard, the SDK automatically patches the model parameter in your LLM calls:

Multi-Artifact Runs

When a single prompt-linked run produces multiple judged outputs (e.g. a final decision and a visual card), use ze.artifact_span to mark each output as a named artifact. The primary artifact becomes the default completion preview; secondary artifacts are accessible in the detail view.
See the full API and examples in Python Tracing Reference.

Manual Prompt-Linked Spans

When you want ze.prompt() to manage a specific LLM interaction but do not want global auto-instrumentation (e.g. your agent makes many LLM calls and only one should be tracked as a prompt generation), disable integrations and create the span yourself.

When to use this

  • Your codebase makes many LLM calls but only a subset should appear as prompt completions.
  • You use a provider that has no auto-integration (a custom HTTP endpoint, an internal model service, etc.).
  • You want full control over which codepath produces prompt-linked traces.

Setup

Disable all integrations, then initialize:

Create a prompt-linked span

Call ze.prompt() inside an active span so the SDK writes task / zeroeval metadata onto the trace. Then open a child span with kind="llm" (or use ze.artifact_span()) around your provider call. The SDK automatically propagates prompt linkage to child spans in the same trace.
The SDK automatically stamps prompt metadata (task, zeroeval.prompt_version_id, etc.) onto every span in the trace, so the inner llm span is linked to the prompt version without any extra wiring. Judge evaluations, feedback, and the prompt completions page all work as if an auto-integration created the span. You can also use ze.artifact_span() instead of ze.span(kind="llm") when you want the output to appear as a named completion artifact:

Sending Feedback

Attach feedback to completions to power prompt optimization: