Skip to main content

SDK Components

RAXE provides a comprehensive Python SDK with the following components:

Quick Import Reference

# Core clients
from raxe import Raxe, AsyncRaxe

# LLM wrappers
from raxe.sdk.wrappers import RaxeOpenAI, RaxeAnthropic

# Types and models
from raxe.domain.rules.models import Detection, Severity
from raxe.application.scan_result import ScanResult

# Exceptions
from raxe.exceptions import (
    RaxeException,
    RaxeBlockedError,
    ValidationError,
    AuthenticationError,
    ConfigurationError,
)

# LangChain integration
from raxe.sdk.integrations.langchain import RaxeCallbackHandler

Basic Usage Pattern

from raxe import Raxe

# Initialize client
raxe = Raxe()

# Scan a prompt
result = raxe.scan("user input here")

# Check result
if result.is_safe:
    # Proceed with LLM call
    pass
else:
    # Handle threat
    print(f"Threat: {result.highest_severity}")
    for detection in result.detections:
        print(f"  - {detection.rule_id}: {detection.severity}")

Type Annotations

RAXE is fully typed for IDE support:
from raxe import Raxe
from raxe.application.scan_result import ScanResult
from raxe.domain.rules.models import Detection

def process_input(user_input: str) -> bool:
    raxe: Raxe = Raxe()
    result: ScanResult = raxe.scan(user_input)
    detections: list[Detection] = result.detections
    return result.is_safe

API Stability

ComponentStabilityNotes
RaxeStableCore API
AsyncRaxeStableAsync API
ScanResultStableResult model
DetectionStableDetection model
RaxeOpenAIStableOpenAI wrapper
RaxeAnthropicStableAnthropic wrapper
RaxeCallbackHandlerBetaLangChain integration