Raxe
The main synchronous client for threat detection.Constructor
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | None | API key. If None, reads from config or env |
use_ml | bool | True | Enable L2 ML detection |
timeout | float | 30.0 | Scan timeout in seconds |
config_path | str | None | None | Custom config file path |
scan()
Scan a single prompt for threats.| Parameter | Type | Default | Description |
|---|---|---|---|
prompt | str | required | Text to scan |
use_ml | bool | None | None | Override ML setting for this scan |
timeout | float | None | None | Override timeout for this scan |
ScanResult
Raises:
ValidationError: If prompt is empty or invalidRaxeBlockedError: If policy blocks the request
scan_batch()
Scan multiple prompts efficiently.| Parameter | Type | Default | Description |
|---|---|---|---|
prompts | list[str] | required | List of texts to scan |
use_ml | bool | None | None | Override ML setting |
timeout | float | None | None | Override timeout (per prompt) |
list[ScanResult]
Example:
Context Manager
Use as context manager for proper resource cleanup:AsyncRaxe
Async client for high-throughput scenarios.Constructor
Raxe.
scan()
Async scan of a single prompt.scan_batch()
Async batch scanning with concurrency control.| Parameter | Type | Default | Description |
|---|---|---|---|
prompts | list[str] | required | List of texts to scan |
concurrency | int | 10 | Max concurrent scans |
use_ml | bool | None | None | Override ML setting |
timeout | float | None | None | Override timeout |
close()
Explicitly close the client and flush telemetry.Context Manager
Recommended usage:Properties
BothRaxe and AsyncRaxe expose these properties:
| Property | Type | Description |
|---|---|---|
api_key | str | Current API key |
use_ml | bool | ML detection enabled |
timeout | float | Default timeout |
version | str | RAXE version |
Thread Safety
Raxeis thread-safe for concurrent scansAsyncRaxeis safe for concurrent async tasks- Both clients maintain internal connection pools
