Skip to main content

Overview

Bundle sampling, steering, constraints, and verification into a reusable configuration.

policy.run()

Runs generation with a policy configuration applied.
string
required
The input prompt.
dict
Inline policy configuration. Specify any combination of sampling, steering, constraints, and verification settings.
string
ID of a previously saved policy. Mutually exclusive with policy.
integer
default:"128"
Maximum tokens to generate.
boolean
default:"false"
If true, includes step-by-step trace data in the response.
Returns: A dict with output, accepted (bool), score, latency_ms, tokens, and optionally trace.

Save & Reuse

Compare & Evaluate

Test multiple policies against the same prompt to find the best configuration:

Policy Structure

A policy bundles five configuration sections:

Verifiers

Verifiers validate generated output and optionally repair failures by retrying. Enable them by name in the verifiers.enabled list:
For code generation with unit tests:

Optimization

Auto-Tune

Automatically search for the best policy parameters:

Presets

Use built-in preset builders for common configurations:
Presets can be published for sharing or cloned from public presets: