Installation¶
Patronus Ark ships as a Rust crate (patronus-ark) and a Python package (patronus-ark,
imported as patronus_ark). Both are built from the same Rust core, so you install whichever
fits your stack — no repository checkout required.
Requirements¶
| Minimum | Notes | |
|---|---|---|
| Python | 3.11+ | wheels target the stable ABI (abi3-py311), so one wheel covers 3.11+ |
| Rust | stable toolchain | for the patronus-ark crate |
| Disk | ~100–250 MB per model bundle | native L1 needs none; L2/L3 assets download on demand |
Model assets are downloaded from Hugging Face on first use. Set HF_TOKEN if you need
authenticated or rate-limited access (see Manage model assets).
Python¶
Verify the install:
from patronus_ark import SecurityGateway
scanner = SecurityGateway(categories=["injection"], max_level="l1", download_files=False)
scanner.warmup()
print(scanner.runtime_readiness())
The wheel bundles the compiled Rust extension, so no Rust toolchain is needed to use the Python package.
Rust¶
Add the crate with Cargo:
Or in Cargo.toml:
Verify:
use patronus_ark::{SecurityCategory, SecurityGateway, SecurityLevel};
fn main() {
let mut scanner = SecurityGateway::with_max_level(
vec![SecurityCategory::Injection],
SecurityLevel::L1,
None, // model dir; None uses the platform cache directory
false, // download_files
);
scanner.warmup().expect("warmup");
println!("{:?}", scanner.runtime_readiness());
}
Optional ONNX execution providers¶
The Rust crate exposes feature flags for hardware-accelerated ONNX Runtime backends. Enable the one matching your target (CPU is the default and needs no feature):
patronus-ark = { version = "0.1", features = ["onnx-coreml"] } # macOS
# other options: onnx-cuda, onnx-directml, onnx-tensorrt
See Tune performance & memory for when each backend helps.
Logging¶
The library logs through the log facade (warmup progress,
asset downloads). Messages are silent by default — install a logger such as env_logger in
your application to see them:
Next steps¶
- Quickstart — your first scan, in Python and Rust.
- Choose categories & levels — pick what to scan.
- Architecture — how the pieces fit together.