> ## 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.

# Python: Safe Regeneration

> client.safe_regenerate() - auto-fix content below threshold.

<Info>
  **Concept:** [Safe Regeneration](/concepts/safe-regeneration) | **API:** [Safe Regeneration API](/api-reference/safe-regeneration)
</Info>

<CodeGroup>
  ```python Basic theme={null}
  from rail_score_sdk import RailScoreClient

  client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")

  result = client.safe_regenerate(
      content="Prioritize Ivy League graduates for this role.",
      prompt="What hiring criteria should we use?",
      threshold=7.0,
      mode="basic",
      max_iterations=3,
  )

  print(f"Final score: {result.final_score}/10")
  print(f"Passed: {result.passed_threshold}")
  print(f"Iterations: {result.iterations_taken}")
  print(f"Content: {result.content}")
  ```

  ```python Specific dimensions theme={null}
  result = client.safe_regenerate(
      content="Your text here",
      prompt="Original user prompt",
      threshold=8.0,
      mode="basic",
      dimensions=["safety", "fairness"],  # Only enforce these two
      max_iterations=5,
  )
  ```

  ```python Async theme={null}
  import asyncio
  from rail_score_sdk import AsyncRAILClient

  async def main():
      client = AsyncRAILClient(api_key="YOUR_RAIL_API_KEY")
      result = await client.safe_regenerate(
          content="...",
          prompt="...",
          threshold=7.0,
      )
      print(result["final_score"])

  asyncio.run(main())
  ```
</CodeGroup>
