LeveredDocs
Manual Setup

4. Create an optimization

Define design factors, optionally add context factors, and link a reward metric to create an optimization.

An optimization defines what is tested (design factors and their levels), how the outcome is measured (a reward metric) and, optionally, which user attributes the model uses to select a variant (context factors).

Key concepts

  • Design factor. A design factor is a variable to optimize. Examples are headline, cta_text and hero_image.
  • Level. A level is one possible value of a design factor. For example, the headline factor can have the levels "Ship faster", "Save time" and "Build better".
  • Variant. A variant is one combination of levels, with one level for each design factor. 3 headlines and 2 CTA texts give 6 variants.

Levered explores these variants and shifts traffic toward the variants that produce the most reward.

Context factors

Context factors are attributes of the user or the session, for example device, location or user segment. If the optimization has context factors, Levered learns which variant performs best for each type of user. If it has none, Levered learns which variant performs best across all users.

If you are new to Levered, start without context factors. To select variants based on user attributes, add context factors with --context-factors.

What users outside the optimization see

The holdout is a share of the traffic that stays outside the optimization. Levered uses it to measure the gain. The default holdout is 10%. Set it with --holdout. The control type defines what holdout users see. Decide on the control type before creating the optimization.

Control typeUse whenFlag
variant (default)One of the variants is what users see today. This variant is the baseline, and Levered serves it to the holdout. Name it with --baseline: Levered never picks one for you.--control variant
externalThe holdout keeps today's version, and that version is not one of the variants (for example a legacy component). Holdout users train the model as the current version, never as a variant. external requires a holdout.--control external
noneAll variants are new. The optimization has no holdout and no guardrails. Lift is measured against an even split of traffic.--control none

Create an optimization

Create an optimization with the Levered CLI or the Levered plugin for Claude Code. The dashboard cannot create optimizations.

With the Levered plugin installed, describe what to test. Claude builds the factor JSON and runs the CLI:

Prompt for Claude Code
Using Levered, create an optimization for my landing page hero: test the headline (Ship faster, Save time, Build better) and the CTA text (Start free, Try it now), optimizing for my "Signup Conversion" metric.
levered optimizations create \
  --name "Landing Page Hero" \
  --design-factors '[
    {"name": "headline", "dtype": "str", "levels": ["Ship faster", "Save time", "Build better"]},
    {"name": "cta_text", "dtype": "str", "levels": ["Start free", "Try it now"]}
  ]' \
  --reward-metric-id <metric-uuid> \
  --baseline '{"headline": "Ship faster", "cta_text": "Start free"}'
  • --reward-metric-id is the id of the metric created in the previous step. Run levered metrics list to get the id.
  • To personalize variant selection, add --context-factors (JSON). Without context factors, Levered learns one best variant across all users.
  • --control and --holdout set the control type and the holdout percentage (see above). Without them, the control type is variant and the holdout is 10%. With the control type variant, --baseline is required and names the variant that is today's experience. If every variant is new, use --control none --holdout 0 instead of --baseline.

The optimization is created as a draft. A draft does not serve real users. Integrate the SDK, test the setup, and then set the optimization live with levered optimizations update <id> --status live. Levered sets the optimization live only after at least one /serve call, live or dry run, has been made for it.

What happens after creation

After the SDK is integrated and the optimization is live, the following happens:

  1. Levered serves variants to users based on the current allocation of the model. A share of the users, the holdout, keeps today's experience, so that Levered can measure the gain.
  2. Exposure and reward events arrive in the warehouse.
  3. Levered trains on a recurring schedule. Each training run reads the new data from the warehouse and updates the model.
  4. Traffic shifts toward variants with higher reward rates.

No manual step is needed after the optimization is live.

Next step

Next, integrate the SDK to serve variants and log exposures.