> ## 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 - Drop-in-Wrapper für Google Gemini und Vertex AI, der jede Antwort automatisch bewertet.

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

## Verwendung

<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="Erklären Sie die Risiken von algorithmischer Voreingenommenheit bei Einstellungen.",
      )

      print(f"Inhalt: {response.content}")
      print(f"RAIL Score: {response.rail_score}/10")
      print(f"Schwellenwert erreicht: {response.threshold_met}")
      print(f"Wurde regeneriert: {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: "Erklären Sie die Risiken von algorithmischer Voreingenommenheit bei Einstellungen.",
  });

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

## Vertex AI

Um Gemini über Vertex AI anstelle von Google AI Studio zu verwenden, übergeben Sie `use_vertex=True`:

```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 verwendet Anwendungsstandardanmeldeinformationen. Führen Sie `gcloud auth application-default login` aus oder setzen Sie `GOOGLE_APPLICATION_CREDENTIALS` auf Ihre Dienstkontoschlüsseldatei.
</Note>

## Konfigurationsoptionen

| Parameter        | Typ     | Standard        | Beschreibung                                                                |
| ---------------- | ------- | --------------- | --------------------------------------------------------------------------- |
| `google_api_key` | `str`   | —               | Google AI Studio API-Schlüssel (nicht erforderlich, wenn `use_vertex=True`) |
| `rail_api_key`   | `str`   | —               | Ihr RAIL API-Schlüssel                                                      |
| `rail_threshold` | `float` | `None`          | Blockieren oder regenerieren unterhalb dieses Scores                        |
| `rail_policy`    | `str`   | `"log_only"`    | `"log_only"` \| `"block"` \| `"regenerate"`                                 |
| `rail_mode`      | `str`   | `"basic"`       | `"basic"` \| `"deep"`                                                       |
| `use_vertex`     | `bool`  | `False`         | Über Vertex AI anstelle von Google AI Studio leiten                         |
| `gcp_project`    | `str`   | —               | GCP-Projekt-ID (erforderlich, wenn `use_vertex=True`)                       |
| `gcp_region`     | `str`   | `"us-central1"` | Vertex AI-Region                                                            |

<Tip>
  Übergeben Sie `rail_skip=True` an `generate_content()`, um die RAIL-Bewertung für einen einzelnen Aufruf zu umgehen.
</Tip>

## Was kommt als Nächstes

<CardGroup cols={2}>
  <Card title="OpenAI-Integration" icon="bolt" href="/integrations/openai">
    RAILOpenAI-Wrapper für Chat-Vervollständigungen.
  </Card>

  <Card title="Anthropic-Integration" icon="a" href="/integrations/anthropic">
    RAILAnthropic-Wrapper für Claude.
  </Card>

  <Card title="Konzepte: Middleware" icon="layer-group" href="/concepts/middleware">
    Wie Anbieter-Wrapper im Hintergrund funktionieren.
  </Card>

  <Card title="Python SDK-Übersicht" icon="python" href="/sdk/python/overview">
    Vollständige Installation und Referenz des Python SDK.
  </Card>
</CardGroup>
