Skip to main content
v0 is considered deprecated and will be fully removed in a future release.

Table of Contents


Type Aliases

Messages

The primary message type. Either a plain string (completion mode) or a list of chat messages (chat mode).

ChatMessage

OpenAI’s chat message type with role, content, and optional tool_calls / tool_call_id fields.

SystemMessage

Provider-agnostic system message type. Use vf.SystemMessage.from_path(...) to load a system prompt from a UTF-8 text file while preserving the file contents verbatim.

Info

Arbitrary metadata dictionary from dataset rows.

SamplingArgs

Generation parameters passed to the inference server (e.g., temperature, top_p, max_tokens).

SystemPrompt

v1 system prompt type. Plain strings are prompt text. Use vf.SystemPromptConfig(path="system_prompt.txt") for file-backed prompts, or override load_system_prompt(config) when prompt construction belongs to the class. System prompt resolution is per task: task prompt overrides taskset prompt for the taskset side, then the harness applies system_prompt_strategy. The default strategy is HT.

RewardFunc

Individual reward functions operate on single rollouts. Group reward functions operate on all rollouts for an example together (useful for relative scoring).

ClientType

Selects which Client implementation to use. Set via ClientConfig.client_type.

Data Types

State

A dict subclass that tracks rollout information. Accessing keys in INPUT_FIELDS automatically forwards to the nested input object. Fields set during initialization: Fields set after scoring:

RolloutInput

RolloutOutput

Serialized output from a rollout. This is a dict subclass that provides typed access to known fields while supporting arbitrary additional fields from state_columns. All values must be JSON-serializable. Used in GenerateOutputs and for saving results to disk.

TrajectoryStep

A single turn in a multi-turn rollout.

RoutedExpertsPayload

TrajectoryStepTokens

Token-level data for training.

TimeSpan

TimeSpans

RolloutTiming

Derivations:
  • total = scoring.end - generation.start
  • overhead = total - setup.duration - model.duration - env.duration - scoring.duration
generation.start is stamped at the top of the rollout (before setup_state), so total covers the entire rollout including setup, generation loop, finalize, and scoring. overhead captures any time not attributed to the named phases.

TokenUsage

In a single-turn rollout, input_tokens == final_input_tokens and output_tokens == final_output_tokens. In a multi-turn rollout, input_tokens > final_input_tokens because earlier turns’ prompts are counted again. The final_* metrics assume a single, continuously extended trajectory. Non-linear trajectories (multi-agent, context summarization, history rewriting) are not accounted for.

GenerateOutputs

Output from Environment.generate(). Contains a list of RolloutOutput objects (one per rollout) and generation metadata. Each RolloutOutput is a serialized, JSON-compatible dict containing the rollout’s prompt, completion, answer, reward, metrics, timing, and other per-rollout data.

GenerateMetadata

base_url is always serialized as a string. For multi-endpoint runs (e.g., using ClientConfig.endpoint_configs), it is stored as a comma-separated list of URLs. shuffle records whether evaluation inputs were shuffled before selecting examples. shuffle_seed records the seed used for that shuffle; when shuffle is enabled without an explicit seed, the saved value is 0. version_info captures the verifiers framework version/commit and the environment package version/commit at generation time. Populated automatically by GenerateOutputsBuilder.

RolloutScore / RolloutScores


Classes

Environment Classes

Environment

Abstract base class for all environments. Generation methods: Dataset methods: Rollout methods (used internally or by subclasses): Calling generate_sync() from Jupyter or another active event loop requires uv add "verifiers[notebook]". Configuration methods:

SingleTurnEnv

Single-response Q&A tasks. Inherits from Environment.

MultiTurnEnv

Multi-turn interactions. Subclasses must implement env_response. Abstract method:
Built-in stop conditions: has_error, prompt_too_long, max_turns_reached, timeout_reached, max_total_completion_tokens_reached, has_final_env_response Hooks:

ToolEnv

Tool calling with stateless Python functions. Automatically converts functions to OpenAI tool format. Built-in stop condition: no_tools_called (ends when model responds without tool calls) Methods:

StatefulToolEnv

Tools requiring per-rollout state. Override setup_state and update_tool_args to inject state.

SandboxEnv

Sandboxed container execution using prime sandboxes. Key parameters:

PythonEnv

Persistent Python REPL in sandbox. Extends SandboxEnv.

OpenEnvEnv

OpenEnv integration that runs OpenEnv projects in Prime Sandboxes using a prebuilt image manifest (.build.json), supports both gym and MCP contracts, and requires a prompt_renderer to convert observations into chat messages.

SandboxDebugEnv

No-agent debugger for sandbox-backed SandboxTaskSet instances. It creates the task sandbox, optionally runs task setup, runs one debug step (none, gold_patch, command, or script), and optionally runs tests and scores the result. SWEDebugEnv remains as a deprecated wrapper for older callers.

EnvGroup

Combines multiple environments for mixed-task training. Combined datasets use info["env_id"] as internal routing metadata; it is not a top-level input, state, or output field.

Parser Classes

Parser

Base parser. Default behavior returns text as-is.

XMLParser

Extracts structured fields from XML-tagged output.
Methods:

ThinkParser

Extracts content after </think> tag. For models that always include <think> tags but don’t parse them automatically.

MaybeThinkParser

Handles optional <think> tags (for models that may or may not think).

Rubric Classes

Rubric

Combines multiple reward functions with weights. Default weight is 1.0. Functions with weight=0.0 are tracked as metrics only. Methods: Reward function signature:
Group reward function signature:

JudgeRubric

LLM-as-judge evaluation.

MathRubric

Math-specific evaluation using math-verify.

RubricGroup

Combines rubrics for EnvGroup.

Client Classes

Client

Abstract base class for all model clients. Wraps a provider-specific SDK client and translates between provider-agnostic vf types (Messages, Tool, Response) and provider-native formats. The client property exposes the underlying SDK client (e.g., AsyncOpenAI, AsyncAnthropic). get_response() is the main public method — it converts the prompt and tools to the native format, calls the provider API, validates the response, and converts it back to a vf.Response. Errors are wrapped in vf.ModelError unless they are already vf.Error or authentication errors. Abstract methods (for subclass implementors):

Built-in Client Implementations

All built-in clients are available as vf.OpenAIChatCompletionsClient, vf.AnthropicMessagesClient, etc.

Response

Provider-agnostic model response. All Client implementations return Response from get_response().

Tool

Provider-agnostic tool definition. Environments define tools using this type; each Client converts them to its native format via to_native_tool().

Configuration Types

ClientConfig

extra_headers_from_state maps HTTP header names to state field names. For each inference request, the header value is dynamically read from the rollout state dict. For example, {"X-Session-ID": "trajectory_id"} adds a X-Session-ID header with the value of state["trajectory_id"], enabling sticky routing at the inference router level. client_type selects which Client implementation to instantiate (see Client Classes). Use endpoint_configs for multi-endpoint round-robin. In grouped scoring mode, groups are distributed round-robin across endpoint configs. preserve_all_thinking and preserve_thinking_between_tool_calls are forwarded to the underlying renderer when client_type == "renderer". They control whether past-assistant reasoning_content is re-emitted on subsequent renders — preserve_all_thinking keeps every past-assistant turn’s thinking, and preserve_thinking_between_tool_calls keeps thinking only inside the in-flight assistant→tool→…→assistant block after the most recent user turn (when that block contains at least one tool response). Both default to False (template default applies). When api_key_var is "PRIME_API_KEY" (the default), credentials are loaded with the following precedence:
  • API key: PRIME_API_KEY env var > ~/.prime/config.json > "EMPTY"
  • Team ID: PRIME_TEAM_ID env var > ~/.prime/config.json > not set
This allows seamless use after running prime login.

EndpointClientConfig

Leaf endpoint configuration used inside ClientConfig.endpoint_configs. Has the same fields as ClientConfig except endpoint_configs itself, preventing recursive nesting.

EvalConfig

EndpointConfig

api_key_var is a credential reference. Endpoint configs never serialize the materialized API key. Endpoints maps an endpoint id to one or more endpoint variants. A single variant is represented as a one-item list.

Prime CLI Plugin

Verifiers exposes a plugin contract consumed by prime for command execution.

PRIME_PLUGIN_API_VERSION

API version for compatibility checks between prime and verifiers.

PrimeCLIPlugin

build_module_command returns a subprocess command list for python -m <module> ....

get_plugin

Returns the plugin instance consumed by prime.

Decorators

@vf.stop

Mark a method as a stop condition. All stop conditions are checked by is_completed().

@vf.cleanup

Mark a method as a rollout cleanup handler. Cleanup methods should be idempotent—safe to call multiple times—and handle errors gracefully to ensure cleanup completes even when resources are in unexpected states.

@vf.teardown

Mark a method as an environment teardown handler.

Utility Functions

Data Utilities

Load a built-in example dataset.
Extract answer from LaTeX \boxed{} format. When strict=True, returns "" if no \boxed{} is found (used by MathRubric to avoid scoring unformatted responses). When strict=False (default), returns the original text as a passthrough.
Extract answer after #### marker (GSM8K format).

Environment Utilities

Load an environment by ID (e.g., "primeintellect/gsm8k").

Configuration Utilities

Validate that required environment variables are set. Raises MissingKeyError (a ValueError subclass) with a clear message listing all missing keys and instructions for setting them.
Example:

Logging Utilities

Pretty-print sample rollouts.
Configure verifiers logging. Set VF_LOG_LEVEL env var to change default.
Context manager to temporarily set the verifiers logger to a new log level. Useful for temporarily adjusting verbosity during specific operations.
Context manager to temporarily silence verifiers logging by setting WARNING level. Shorthand for vf.log_level("WARNING").