SDK Reference

Python SDK for ZeroShot AI systems security scanning.

Installation

# Install with pip
pip install zeroshot-sdk

Initialize the Client

from zeroshot import ZeroShot

# Using API key directly
client = ZeroShot(api_key="zsk_live_...")

# Using environment variable (recommended)
# Set ZEROSHOT_API_KEY in your environment
client = ZeroShot()

Create a Scan

scan = client.scans.create(
    target="https://api.example.com/chat",
    categories=["jailbreak", "prompt_injection"],
    max_attacks=100,
)

print(f"Scan ID: {scan.id}")
print(f"Status: {scan.status}")

Wait for Completion

scan = client.scans.create(target="https://api.example.com/chat")

# Poll until complete
scan = client.scans.wait(scan.id, timeout=300)

print(f"Found {scan.vulnerabilities_found} vulnerabilities")

Retrieve Results

scan = client.scans.retrieve("scan_abc123")

for result in scan.results:
    if result.success:
        print(f"[{result.severity}] {result.attack_category}")
        print(f"  Prompt: {result.prompt[:50]}...")
        print(f"  Response: {result.response[:50]}...")

On this page