Skip to main content

giskard-scan

Agent vulnerability scanner — red teaming, prompt injection, adversarial scenario generation.

Telemetry: This package depends on giskard-core, which may send optional, aggregated scan lifecycle metrics (scan type, fixed execution modes, counts, durations, and outcomes). Descriptions, language values, generated scenarios, prompts, outputs, recommendations, and other user content are never included. See Telemetry for details and opt-outs.

Scan entrypoints

quality_scan and vulnerability_scan share the same explicit execution options. Pass shared settings by keyword on either entrypoint; each scan adds scan-specific options (knowledge_base for quality, commercial_use for vulnerability).

from giskard.scan import quality_scan, vulnerability_scan


async def echo(inputs: str) -> str:
    return inputs


vulnerability_result = await vulnerability_scan(
    target=echo,
    description="Customer support chatbot for an e-commerce store.",
    languages=["en"],
    max_scenarios=20,
    seed=42,
    group_by="threat-type",
    parallel=True,
    max_concurrency=8,
    return_exception=False,
    target_mode="multiturn",
    commercial_use=False,
)

quality_result = await quality_scan(
    target=echo,
    description="Customer support chatbot for an e-commerce store.",
    languages=["en"],
    knowledge_base=["Paris is the capital of France."],
    max_scenarios=20,
    seed=42,
    group_by="component",
    parallel=True,
    max_concurrency=8,
    return_exception=False,
    target_mode="multiturn",
)

Shared defaults

DEFAULT_TARGET_MODE ("multiturn") is shared by generate_suite, vulnerability_scan, quality_scan, and third_party_scan. Pass target_mode="singleturn" to skip multi-turn generators/attacks and cap turn budgets to 1.

Discover selectable items for any tool with list_scan_items:

from giskard.scan import list_scan_items

list_scan_items("giskard")  # scenario generator class names
list_scan_items("garak")  # active garak probe names
list_scan_items("deepteam")  # vulnerability + attack names

Third-party scanners (experimental)

third_party_scan runs an external security scanner against a Giskard target and returns a SuiteResult. Two scanners are supported, each shipping as an optional extra: garak and deepteam.

pip install giskard-scan[garak]
pip install giskard-scan[deepteam]

garak

import asyncio

from giskard.scan import list_scan_items, third_party_scan


def target(inputs: str) -> str:
    # Your agent / model call. Structured (BaseModel) inputs also work.
    return call_my_agent(inputs)


result = asyncio.run(
    third_party_scan(
        target,
        tool="garak",
        description="A helpful assistant",  # required by the API; garak ignores it
        # probes=None -> curated default set; probes="all" -> every active probe
        probes=["probes.goodside.ThreatenJSON"],
        # target_mode defaults to "multiturn"; pass "singleturn" to drop iterative probes
    )
)

print(result)
print(list_scan_items("garak")[:5])

Probes run in parallel; the target is invoked concurrently, so it must be safe to call from multiple threads (per-conversation state is tracked in the Trace, not on the target).

Omitting probes runs a small curated default set aligned with DeepTeam themes (Bias/Toxicity, PII, Misinformation, PromptLeakage, jailbreak/injection, data exfil) — not the full garak catalog. Pass probes="all" for every active probe, or an explicit name list.

Unknown, inactive, or unloadable probe names are logged and emitted as CheckResult.skip scenarios rather than raising.

deepteam

Deepteam generates adversarial attacks with an LLM and judges the responses with an LLM, so it needs a working Giskard default generator (see giskard.checks.get_default_generator()) — there is no keyless mode.

result = asyncio.run(
    third_party_scan(
        target,
        tool="deepteam",
        description="A helpful assistant",  # becomes deepteam's target_purpose
        vulnerabilities=["Bias", "Toxicity"],  # omit for a curated default set
        attacks=["PromptInjection", "LinearJailbreaking"],  # omit for defaults
        attacks_per_vulnerability_type=1,  # default; each vuln subtype × this many
        # target_mode defaults to "multiturn" (shared with native Giskard scans)
    )
)

vulnerabilities accepts Bias, Toxicity, PIILeakage, PromptLeakage, and Misinformation. Instantiating those classes without subtypes runs all of their types (for example Bias → race, gender, politics, religion), so cost scales with types × attacks_per_vulnerability_type × attacks.

attacks accepts the single-turn PromptInjection, Roleplay, Leetspeak, and ROT13, plus the multi-turn LinearJailbreaking, CrescendoJailbreaking, TreeJailbreaking, SequentialJailbreak, and BadLikertJudge. Unrecognized names are logged and emitted as skip scenarios (valid names in the same call still run).

target_mode defaults to the shared DEFAULT_TARGET_MODE ("multiturn"). Pass "singleturn" to drop multi-turn attacks (they surface as skip scenarios). Unknown names also skip — the suite is never an empty "everything passed" result when you asked for attacks that could not run.

API keys and LLM-judge detectors

Some garak detectors need an LLM or a third-party API to score a probe:

  • LLM-judge detectors (garak's judge.*, e.g. refusal detection) normally require their own OpenAI key. Instead, they are automatically backed by Giskard's default generator (giskard.checks.get_default_generator()), so they run with the same credentials as the rest of Giskard — no separate OpenAI key needed.
  • Detectors that need a third-party API key you have not set (for example perspective.*, which needs PERSPECTIVE_API_KEY) are skipped rather than silently dropping the whole probe. Each skipped detector surfaces as a skip result (CheckResult.skip) in the returned SuiteResult, with the missing key named in the message, so the rest of the probe's detectors still run.

Metadata

Release files for giskard-scan 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for giskard-scan 1.0.1
File Size Uploaded
giskard_scan-1.0.1.tar.gz 77.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for giskard-scan 1.0.1
File Interpreter ABI Platform
giskard_scan-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 195.2 kB

Release files / giskard_scan-1.0.1.tar.gz

Download URL giskard_scan-1.0.1.tar.gz
Size 77.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd95eeec3413a9a202cb3adaf0fe85eb46cdf59ff0d6b9cc5112f4c78edb7338
BLAKE2b-256 checksum
How to use checksums
4711155008776782225dfc30db5ba2ce39782326d2369090e234f307b2f2209c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / giskard_scan-1.0.1-py3-none-any.whl

Download URL giskard_scan-1.0.1-py3-none-any.whl
Size 117.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71dd26ae5352f8870a538b84a94b12bf5c72547bce0cddd494b737c4f671b4b0
BLAKE2b-256 checksum
How to use checksums
c69502bab6f0231def7d5c166a7b5dff092a622ab236ae46b5f339a30213a04b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page