Python SDK
rail-score-sdkv2.4.0 on PyPI
The official Python client for the RAIL Score API. Evaluate AI outputs across 8 responsibility dimensions with sync/async clients, agent evaluation, provider integrations, session tracking, middleware, and policy enforcement.
Quick Start — 30 seconds
pip install rail-score-sdk
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(result.rail_score.score) # 8.4
print(result.dimension_scores) # {fairness: 9.0, safety: 8.5, ...}Migration note: This package replaces the deprecated rail-score package. Import path changed from rail_score.RailScore to rail_score_sdk.RailScoreClient.
Installation
Base package
pip install rail-score-sdkWith provider integrations
pip install "rail-score-sdk[openai]" # OpenAI wrapper
pip install "rail-score-sdk[anthropic]" # Anthropic wrapper
pip install "rail-score-sdk[google]" # Google Gemini wrapper
pip install "rail-score-sdk[langfuse]" # Langfuse observability
pip install "rail-score-sdk[litellm]" # LiteLLM guardrail
pip install "rail-score-sdk[integrations]" # All LLM provider wrappers
pip install "rail-score-sdk[agents]" # CrewAI, LangGraph, AutoGen
pip install "rail-score-sdk[telemetry]" # OpenTelemetry instrumentationRequires: Python 3.8+
Core dependencies: httpx, requests
Client Initialization
from rail_score_sdk import RailScoreClient
client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")
# Optional parameters
client = RailScoreClient(
api_key="YOUR_RAIL_API_KEY",
base_url="https://api.responsibleailabs.ai", # default
timeout=30,
)from rail_score_sdk import AsyncRAILClient
import asyncio
async def evaluate_batch():
async with AsyncRAILClient(api_key="YOUR_RAIL_API_KEY") as client:
results = await asyncio.gather(
client.eval(content="First response...", mode="basic"),
client.eval(content="Second response...", mode="deep"),
)
for r in results:
print(f"Score: {r['rail_score']['score']}") # AsyncRAILClient returns raw dicts
asyncio.run(evaluate_batch())Tip: AsyncRAILClient returns raw dicts — use result["rail_score"]["score"]. The sync RailScoreClient returns typed dataclasses.
In this SDK
Evaluation
client.eval() — basic, deep, selective dimensions, custom weights
Safe Regeneration
client.safe_regenerate() — iterate until quality thresholds are met
Compliance
client.compliance_check() — GDPR, HIPAA, EU AI Act, and more
Sessions & Policy
RAILSession, Policy enum, RAILMiddleware, PolicyEngine, error handling
Integrations
RAILOpenAI, RAILAnthropic, RAILGemini, RAILLangfuse, CrewAI, LangGraph, AutoGen
Agent Evaluation
client.agent — evaluate tool calls, scan results, detect injection, track session risk
Each dimension scores 0–10. Privacy scores exactly 5.0 when not applicable. See the RAIL Framework page for full anchor descriptions.