Skip to main content
Safe Regeneration is a feedback loop: evaluate a response, and if it falls below your threshold, regenerate it with targeted improvement instructions and score it again, repeating until it passes. If the iteration limit is reached, the highest-scoring version produced is returned.
API endpoint: POST /railscore/v1/safe-regenerate | Python: client.safe_regenerate() | JavaScript: client.safeRegenerate()

How it works

Each iteration costs the same credits as a standalone evaluation. Up to 5 iterations per request.

Basic usage

The response

status tells you the outcome, and which other fields are populated:
  • "passed" — content met the thresholds; best_content is the passing version.
  • "max_iterations_reached" — never passed within the iteration limit; best_content is still the closest attempt, so you can decide whether to serve it, fall back, or route to a human.
  • "awaiting_regeneration" — only when you use client-orchestrated ("external") regeneration instead of the default managed mode; see the SDK pages for that flow.
best_scores and iteration_history show the score progression across attempts, and metadata.total_iterations is how many regenerate-and-score rounds ran.

Usage

Each iteration meters like a standalone evaluation, up to the iteration limit you set. If the first response already passes the threshold, only that evaluation is counted. See Credits for details.

What’s next

API Reference: Safe Regeneration

Full parameter reference.

Python SDK: Safe Regeneration

Python SDK examples and options.

Concepts: Middleware

Auto-regenerate via provider wrappers.

Policy Engine

Trigger regeneration automatically from your application policy.