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

> Install and configure the RAIL Score Python SDK - sync and async clients.

## Installation

```bash theme={null}
pip install rail-score-sdk
```

Install with optional extras for provider integrations:

```bash theme={null}
pip install "rail-score-sdk[openai]"       # OpenAI wrapper
pip install "rail-score-sdk[anthropic]"    # Anthropic wrapper
pip install "rail-score-sdk[google]"       # Gemini wrapper
pip install "rail-score-sdk[litellm]"      # LiteLLM wrapper
pip install "rail-score-sdk[integrations]" # All LLM providers
pip install "rail-score-sdk[agents]"       # CrewAI, LangGraph, AutoGen
pip install "rail-score-sdk[telemetry]"    # OpenTelemetry support
pip install "rail-score-sdk[dev]"          # Development tools
```

## Sync client

```python theme={null}
from rail_score_sdk import RailScoreClient

client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")

result = client.eval(content="Your AI-generated text here", mode="basic")
print(f"RAIL Score: {result.rail_score.score}/10")
```

`RailScoreClient` returns typed dataclass objects. Access scores as `result.rail_score.score`, `result.dimension_scores["fairness"].score`, etc.

## Async client

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

async def main():
    client = AsyncRAILClient(api_key="YOUR_RAIL_API_KEY")
    result = await client.eval(content="Your text here", mode="basic")
    print(result["rail_score"]["score"])  # Returns raw dicts

asyncio.run(main())
```

`AsyncRAILClient` returns raw dictionaries rather than dataclasses.

## Key classes

| Class             | Purpose                                 |
| ----------------- | --------------------------------------- |
| `RailScoreClient` | Sync client - all core methods          |
| `AsyncRAILClient` | Async client - all core methods         |
| `RAILSession`     | Track quality across a conversation     |
| `Policy`          | Declarative rules for score enforcement |
| `Rule`            | Individual policy rule                  |
| `RAILMiddleware`  | Wrap any async LLM function             |

## Error handling

```python theme={null}
from rail_score_sdk import (
    RailScoreClient,
    AuthenticationError,
    InsufficientCreditsError,
    RateLimitError,
    ContentTooHarmfulError,
    DPDPHostedOnlyError,
)

client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")

try:
    result = client.eval(content="...", mode="deep")
except AuthenticationError:
    print("Check your API key")
except InsufficientCreditsError:
    print("Account limit reached")
except RateLimitError:
    print("Slow down requests")
except ContentTooHarmfulError:
    print("Content blocked at safety layer")
except DPDPHostedOnlyError:
    print("DPDP audit runs against the hosted API only")
```

<Note>
  `DPDPHostedOnlyError` (added in SDK 2.6.0) is raised when a hosted-only DPDP operation — such as `client.dpdp.dpdp_audit()` — is called against a self-hosted RAIL agent. See [Python: India DPDP](/sdk/python/dpdp).
</Note>

## What's next

<CardGroup cols={2}>
  <Card title="Evaluation" icon="magnifying-glass" href="/sdk/python/evaluation">
    Sync and async eval examples.
  </Card>

  <Card title="Safe Regeneration" icon="rotate" href="/sdk/python/safe-regeneration">
    Auto-fix below-threshold content.
  </Card>

  <Card title="Sessions & Policy" icon="gavel" href="/sdk/python/sessions">
    Track quality across conversations.
  </Card>

  <Card title="India DPDP" icon="shield-halved" href="/sdk/python/dpdp">
    Scan Indian PII, gate decisions, emit events, and generate evidence.
  </Card>

  <Card title="Configuration" icon="gear" href="/sdk/python/configuration">
    Inspect policy, plan capabilities, and dimensions at runtime.
  </Card>

  <Card title="Integrations" icon="plug" href="/integrations/overview">
    Provider wrappers for OpenAI, Gemini, Anthropic.
  </Card>
</CardGroup>
