> ## Documentation Index
> Fetch the complete documentation index at: https://docs.responsibleailabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Safe Regeneration

> POST /railscore/v1/safe-regenerate - Evaluate and regenerate until content passes threshold.

<Info>
  **Concept:** [Safe Regeneration](/concepts/safe-regeneration) | **Python:** [`client.safe_regenerate()`](/sdk/python/safe-regeneration)
</Info>

## Parameters

<ParamField body="content" type="string" required>
  The initial AI-generated text to evaluate and potentially regenerate.
</ParamField>

<ParamField body="prompt" type="string" required>
  The original user prompt that produced the content. Used to guide regeneration.
</ParamField>

<ParamField body="threshold" type="number" required>
  Minimum acceptable RAIL score (0–10). Content below this score is regenerated.
</ParamField>

<ParamField body="mode" type="string" default="basic">
  Evaluation depth used for each iteration: `"basic"` for fast scoring or `"deep"` for a more detailed analysis.
</ParamField>

<ParamField body="max_iterations" type="integer" default="3">
  Maximum regeneration attempts (1–5).
</ParamField>

<ParamField body="dimensions" type="string[]">
  Specific dimensions to enforce the threshold on. Omit to apply across all 8.
</ParamField>

## Request

```bash theme={null}
curl -X POST https://api.responsibleailabs.ai/railscore/v1/safe-regenerate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_RAIL_API_KEY" \
  -d '{
    "content": "Prioritize candidates from Ivy League universities for this role.",
    "prompt": "What hiring criteria should we use?",
    "threshold": 7.0,
    "mode": "basic",
    "max_iterations": 3
  }'
```

## Response

```json theme={null}
{
  "result": {
    "content": "Evaluate candidates based on demonstrated skills, relevant experience, and problem-solving ability.",
    "final_score": 8.4,
    "passed_threshold": true,
    "iterations_taken": 2,
    "iteration_scores": [4.2, 8.4],
    "from_cache": false
  },
  "credits_consumed": 2.0
}
```

<ResponseField name="result.content" type="string">
  The final content - either the original (if it passed) or the best regenerated version.
</ResponseField>

<ResponseField name="result.final_score" type="number">
  RAIL score of the returned content.
</ResponseField>

<ResponseField name="result.passed_threshold" type="boolean">
  `true` if the final content meets the threshold.
</ResponseField>

<ResponseField name="result.iterations_taken" type="integer">
  Number of evaluation+regeneration cycles performed.
</ResponseField>

<ResponseField name="credits_consumed" type="number">
  Usage for the request. Each iteration meters like a standalone evaluation; if the first response already passes, only one is charged.
</ResponseField>
