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.
Wrapper für LLM-Anbieter
Drop-in-Wrapper, die automatisch RAIL-Bewertungen zu Ihren bestehenden LLM-Aufrufen hinzufügen. Alle Wrapper geben { response, content, railScore, evaluation } zurück.
OpenAI
import { RAILOpenAI } from '@responsible-ai-labs/rail-score' ;
import OpenAI from 'openai' ;
const openai = new OpenAI ({ apiKey: process . env . OPENAI_API_KEY });
const railOpenAI = new RAILOpenAI ( client , openai , {
thresholds: { safety: 7.0 },
});
const result = await railOpenAI . chat ({
model: "gpt-4o" ,
messages: [{ role: "user" , content: "Erkläre Quantencomputing einfach." }],
});
console . log ( result . content ); // LLM-Antworttext
console . log ( result . railScore . score ); // RAIL-Bewertung
console . log ( result . evaluation ); // Vollständiges EvalResult
Anthropic
import { RAILAnthropic } from '@responsible-ai-labs/rail-score' ;
import Anthropic from '@anthropic-ai/sdk' ;
const anthropic = new Anthropic ();
const railAnthropic = new RAILAnthropic ( client , anthropic , {
thresholds: { safety: 7.0 },
});
const result = await railAnthropic . message ({
model: "claude-sonnet-4-6" ,
max_tokens: 1024 ,
messages: [{ role: "user" , content: "Erkläre Quantencomputing einfach." }],
});
console . log ( result . content );
console . log ( result . railScore . score );
Google Gemini
import { RAILGemini } from '@responsible-ai-labs/rail-score' ;
import { GoogleGenerativeAI } from '@google/generative-ai' ;
const genAI = new GoogleGenerativeAI ( process . env . GOOGLE_API_KEY );
const model = genAI . getGenerativeModel ({ model: "gemini-2.0-flash" });
const railGemini = new RAILGemini ( client , model , {
thresholds: { safety: 7.0 },
});
const result = await railGemini . generate ( "Erkläre Quantencomputing einfach." );
console . log ( result . content );
console . log ( result . railScore . score );
Beobachtbarkeit
Langfuse
import { RAILLangfuse } from '@responsible-ai-labs/rail-score' ;
import { Langfuse } from 'langfuse' ;
const langfuse = new Langfuse ({ publicKey: "..." , secretKey: "..." });
const railLangfuse = new RAILLangfuse ( client , langfuse );
// Inhalte bewerten und Bewertungen an eine Langfuse-Spur senden
const result = await railLangfuse . traceEvaluation ( "trace-id" , "Inhalt zur Bewertung" );
// Ein vorhandenes Bewertungsergebnis an eine Spur senden
await railLangfuse . scoreTrace ( "trace-id" , existingResult );
Guardrail-Handler
import { RAILGuardrail } from '@responsible-ai-labs/rail-score' ;
const guardrail = new RAILGuardrail ( client , {
inputThresholds: { safety: 7.0 },
outputThresholds: { safety: 7.0 , fairness: 7.0 },
});
const preResult = await guardrail . preCall ( "Benutzernachricht" );
if ( ! preResult . allowed ) {
console . log ( "Eingabe blockiert:" , preResult . failedDimensions );
}
const postResult = await guardrail . postCall ( "LLM-Antwort" );
if ( ! postResult . allowed ) {
console . log ( "Ausgabe blockiert:" , postResult . failedDimensions );
}
Fehlerbehandlung
import {
AuthenticationError ,
InsufficientCreditsError ,
InsufficientTierError ,
ValidationError ,
ContentTooLongError ,
SessionExpiredError ,
ContentTooHarmfulError ,
RateLimitError ,
RAILBlockedError
} from '@responsible-ai-labs/rail-score' ;
try {
const result = await client . eval ({ content: "Inhalt zur Bewertung" });
} catch ( error ) {
if ( error instanceof AuthenticationError ) {
console . error ( "Ungültiger API-Schlüssel" );
} else if ( error instanceof InsufficientCreditsError ) {
console . error ( `Benötige ${ error . required } Credits, habe ${ error . balance } ` );
} else if ( error instanceof RateLimitError ) {
console . error ( `Rate limit überschritten. Bitte nach ${ error . retryAfter } s erneut versuchen` );
} else if ( error instanceof ContentTooHarmfulError ) {
console . error ( "Inhalt zu schädlich zum Regenerieren (durchschnittliche Bewertung < 3.0)" );
} else if ( error instanceof SessionExpiredError ) {
console . error ( "Sichere Regenerationssitzung abgelaufen (15 min TTL)" );
} else if ( error instanceof RAILBlockedError ) {
console . error ( `Durch Richtlinie blockiert: ${ error . policyMode } ` );
}
}
Fehler Status Wann AuthenticationError401 Ungültiger oder fehlender API-Schlüssel InsufficientCreditsError402 Nicht genügend Credits InsufficientTierError403 Funktion erfordert höheren Plan ValidationError400 Ungültige Parameter ContentTooLongError400 Inhalt überschreitet maximale Länge SessionExpiredError410 Sichere Regenerationssitzung abgelaufen ContentTooHarmfulError422 Durchschnittliche Inhaltsbewertung unter 3.0 RateLimitError429 Rate limit überschritten RAILBlockedError— Inhalt durch Richtlinien-Engine blockiert
Hilfsfunktionen
import {
getScoreLabel , getScoreColor , getScoreGrade , formatScore ,
formatDimensionName , normalizeDimensionName , resolveFrameworkAlias ,
validateWeights , normalizeWeights , calculateWeightedScore ,
isPassing , getDimensionsBelowThreshold , getLowestScoringDimension ,
getHighestScoringDimension , aggregateScores
} from '@responsible-ai-labs/rail-score' ;
getScoreLabel ( 8.5 ); // "Ausgezeichnet"
getScoreColor ( 8.5 ); // "grün"
getScoreGrade ( 8.5 ); // "A-"
formatScore ( 8.567 , 2 ); // "8.57"
formatDimensionName ( "user_impact" ); // "Benutzerimpact"
normalizeDimensionName ( "legal_compliance" ); // "Inklusivität"
resolveFrameworkAlias ( "ai_act" ); // "eu_ai_act"
const weakAreas = getDimensionsBelowThreshold ( result , 7.0 );
const lowest = getLowestScoringDimension ( result );
const stats = aggregateScores ([ result1 , result2 , result3 ]);
console . log ( stats . averageScore , stats . minScore , stats . maxScore );
TypeScript-Typen
import type {
// Client
RailScoreConfig ,
// Bewertung
EvalParams , EvalResult , EvalIssue , DimensionScore ,
Dimension , EvaluationMode , ContentDomain , ScoreLabel ,
// Sichere Regeneration
SafeRegenerateParams , SafeRegenerateResult , SafeRegenerateContinueParams ,
// Compliance
ComplianceCheckSingleParams , ComplianceCheckMultiParams ,
ComplianceResult , MultiComplianceResult , ComplianceFramework ,
// Sitzung & Richtlinie
SessionConfig , SessionMetrics , PolicyMode , PolicyConfig , MiddlewareConfig ,
// Beobachtbarkeit
GuardResult , RAILGuardrailConfig ,
} from '@responsible-ai-labs/rail-score' ;
Was kommt als Nächstes
API-Referenz zur Bewertung Vollständige HTTP-Parameter und Antwortschema.
Compliance-API GDPR, HIPAA, EU AI Act und mehr.
Credits und Preise Kreditkosten pro Endpunkt und Modus.
Integrationsübersicht Alle unterstützten LLM-Anbieter und Beobachtungswerkzeuge.