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

# Google Gemini

> RAILGemini - Google Gemini और Vertex AI के लिए drop-in wrapper जो हर response को automatically score करता है।

## Installation

<CodeGroup>
  ```bash Python theme={null}
  pip install "rail-score-sdk[google]"
  ```

  ```bash JavaScript theme={null}
  npm install @responsible-ai-labs/rail-score @google/generative-ai
  ```
</CodeGroup>

## Usage

<CodeGroup>
  ```python Python theme={null}
  import asyncio
  from rail_score_sdk.integrations import RAILGemini

  async def main():
      client = RAILGemini(
          google_api_key="AIza...",
          rail_api_key="YOUR_RAIL_API_KEY",
          rail_threshold=7.0,
          rail_policy="regenerate",
          rail_mode="basic",
      )

      response = await client.generate_content(
          model="gemini-1.5-pro",
          contents="Explain the risks of algorithmic bias in hiring.",
      )

      print(f"Content: {response.content}")
      print(f"RAIL Score: {response.rail_score}/10")
      print(f"Threshold met: {response.threshold_met}")
      print(f"Was regenerated: {response.was_regenerated}")

  asyncio.run(main())
  ```

  ```typescript JavaScript theme={null}
  import { RAILGemini } from "@responsible-ai-labs/rail-score";

  const client = new RAILGemini({
    googleApiKey: "AIza...",
    railApiKey: "YOUR_RAIL_API_KEY",
    railThreshold: 7.0,
    railPolicy: "regenerate",
  });

  const response = await client.generateContent({
    model: "gemini-1.5-pro",
    contents: "Explain the risks of algorithmic bias in hiring.",
  });

  console.log(`RAIL Score: ${response.railScore}/10`);
  ```
</CodeGroup>

## Vertex AI

Gemini को Google AI Studio की बजाय Vertex AI से use करने के लिए `use_vertex=True` pass करें:

```python theme={null}
from rail_score_sdk.integrations import RAILGemini

client = RAILGemini(
    use_vertex=True,
    gcp_project="your-gcp-project-id",
    gcp_region="us-central1",
    rail_api_key="YOUR_RAIL_API_KEY",
    rail_threshold=7.0,
)

response = await client.generate_content(
    model="gemini-1.5-pro",
    contents="...",
)
```

<Note>
  Vertex AI Application Default Credentials use करता है। `gcloud auth application-default login` run करें या `GOOGLE_APPLICATION_CREDENTIALS` को अपनी service account key file पर set करें।
</Note>

## Configuration options

| Parameter        | Type    | Default         | Description                                                      |
| ---------------- | ------- | --------------- | ---------------------------------------------------------------- |
| `google_api_key` | `str`   | —               | Google AI Studio API key (`use_vertex=True` होने पर ज़रूरी नहीं) |
| `rail_api_key`   | `str`   | —               | आपकी RAIL API key                                                |
| `rail_threshold` | `float` | `None`          | इस score से नीचे block या regenerate करें                        |
| `rail_policy`    | `str`   | `"log_only"`    | `"log_only"` \| `"block"` \| `"regenerate"`                      |
| `rail_mode`      | `str`   | `"basic"`       | `"basic"` \| `"deep"`                                            |
| `use_vertex`     | `bool`  | `False`         | Google AI Studio की बजाय Vertex AI use करें                      |
| `gcp_project`    | `str`   | —               | GCP project ID (`use_vertex=True` होने पर ज़रूरी)                |
| `gcp_region`     | `str`   | `"us-central1"` | Vertex AI region                                                 |

<Tip>
  किसी single call के लिए RAIL evaluation skip करना हो तो `generate_content()` में `rail_skip=True` pass करें।
</Tip>

## आगे क्या देखें

<CardGroup cols={2}>
  <Card title="OpenAI Integration" icon="bolt" href="/integrations/openai">
    Chat completions के लिए RAILOpenAI wrapper।
  </Card>

  <Card title="Anthropic Integration" icon="a" href="/integrations/anthropic">
    Claude के लिए RAILAnthropic wrapper।
  </Card>

  <Card title="Concepts: Middleware" icon="layer-group" href="/concepts/middleware">
    Provider wrappers internally कैसे काम करते हैं।
  </Card>

  <Card title="Python SDK Overview" icon="python" href="/sdk/python/overview">
    Full Python SDK installation और reference।
  </Card>
</CardGroup>
