> ## 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: 安全な再生成

> client.safe_regenerate() - 閾値以下のコンテンツを自動修正します。

<Info>
  **概念:** [安全な再生成](/concepts/safe-regeneration) | **API:** [安全な再生成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="この役割にはアイビーリーグの卒業生を優先します。",
      prompt="どの採用基準を使用すべきですか？",
      threshold=7.0,
      mode="basic",
      max_iterations=3,
  )

  print(f"最終スコア: {result.final_score}/10")
  print(f"合格: {result.passed_threshold}")
  print(f"イテレーション: {result.iterations_taken}")
  print(f"コンテンツ: {result.content}")
  ```

  ```python Specific dimensions theme={null}
  result = client.safe_regenerate(
      content="ここにあなたのテキスト",
      prompt="元のユーザープロンプト",
      threshold=8.0,
      mode="basic",
      dimensions=["safety", "fairness"],  # この2つのみを強制
      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>
