Running PyRIT scans from the command line with pyrit_scan: when teams need it
pyrit_scan runs a named PyRIT scenario against a registered target from a single command. It fits a team that must test the same AI system again and again, after each model change, prompt update or release, and wants the same objectives, techniques and scoring every time instead of a hand-written script that drifts. If your assessment is a packaged set of scenarios, the scanner is the right tool. If a security tester needs to probe a system interactively, reviewing each response and changing course, a different entry point fits better.
PyRIT can be used in three ways. The scanner, pyrit_scan, runs packaged assessments from the command line. CoPyRIT, the web GUI for human-led red teaming and team collaboration, suits testers working together on live findings. The Python framework suits custom attacks where you write the logic yourself. Choosing the scanner means accepting its packaged shape: the scenario, target and dataset are fixed in configuration, which gives repeatability and makes results easy to compare across runs. Confirm with your security lead that the scenarios you need exist in the release you plan to use, since custom objectives or scorers require a different build step.
Before the first run, confirm three things with your own environment. Find the target and scenario names your installed version lists, confirm which credentials and settings the run reads from ~/.pyrit/.env and ~/.pyrit/.pyrit_conf, and check that your Python version falls within the range the PyPI package supports. The PyRIT documentation is the place to verify command options against your version. Agree in advance who owns the target registration, where memory is stored, and who may read the results, because a repeatable scanner run will generate attack content that must be handled like any other security test output.
How a pyrit_scan run moves from scenario to memory
This sequence shows how a single pyrit_scan command turns a registered target and a chosen scenario into attack conversations, scored results and records in PyRIT memory. Each step ends with a check so you can stop a misconfigured run before it sends any prompts.
Install PyRIT in a supported Python environment
Your engineers install PyRIT with pip into a dedicated virtual environment on the machine or runner that will drive the assessment. The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13, so confirm the interpreter version before installing. The step is done when the pyrit_scan command runs and reports its help text from that environment.
Load credentials and settings from the home directory
PyRIT reads credentials from ~/.pyrit/.env and general settings from ~/.pyrit/.pyrit_conf when the command starts. Keep API keys in the .env file or in a secret store your team controls, and keep the .pyrit_conf file free of secrets. The check is that the run starts without a missing-credential error for the target you plan to test, which you can confirm before any prompts are sent.
Confirm the target is registered
The target you want to test must already be registered with PyRIT, whether it is a hosted model endpoint, a custom HTTP or WebSocket application, or a web app driven through Playwright. Ask the scan to list the registered targets and confirm that the exact name you intend to use appears in the output. If it does not appear, stop here, because an unregistered target will cause the run to fail before scoring begins.
Select the scenario and its datasets
Choose the scenario that matches the assessment, then pass the techniques and dataset options you intend to use. Listing the available scenarios first lets you confirm the exact scenario name and the datasets it draws on. For a first run, a limited dataset size keeps the request count small. The check is that the scan prints the scenario, target and dataset selection back before it starts, so you can compare them with your plan.
Run attacks against the target
PyRIT takes each objective in the dataset, applies the selected attack techniques (single-turn or multi-turn, depending on the scenario), and sends prompts to the target. Each conversation is recorded as it happens. The run is in progress while the console shows objectives being attacked. Watch the first few objectives to confirm the target is responding as expected before letting the full dataset run.
Score each response
After the target replies, the configured scorers evaluate each response. Scorers may be LLM-based judges, Azure AI Content Safety, or custom logic, depending on the scenario configuration. Scoring is what turns a raw conversation into a success or failure signal. Check that scored outcomes appear for the attacks you ran; responses that are not scored cannot be counted in results.
Store results in memory and review the output
PyRIT writes conversations, scores and run metadata to its memory store, which is SQLite by default or Azure SQL where configured. The run is complete when the command prints a summary and the scenario record can be found in memory with its target and labels. Confirm the record exists before you rely on it, because the stored history is what you will query, export or cite later.
Which pyrit_scan options fit which first run
This table compares the main choices a team makes before a first pyrit_scan run: which scenario to use, which techniques and datasets to include, and how far to limit dataset size. Read each row as a trade-off between breadth of coverage and the request cost and run time it adds. For a first run, the usual takeaway is to start narrow and widen only after the results and the target's behavior are understood.
| Option | Fits a first run when | Trade-off | Confirm before running |
|---|---|---|---|
| Foundry scenario | You want a broad baseline across encoding, obfuscation and multi-turn techniques grouped by difficulty | Wide coverage with correspondingly higher request volume and longer runs | Which techniques and default dataset your installed version uses |
| AIRT scenarios | Your concern is a specific harm category, such as hate or leakage, and you want a focused assessment | Deep on one harm area, blind to others until separate scenarios run | Which harm datasets the scenario loads and whether it is single-turn or multi-turn |
| TextAdaptive scenario | You want technique selection to adapt to which approaches succeed on each objective | Fewer requests on some objectives, but results depend on early successes and are harder to compare across runs | How the direct prompt baseline is included and how selection is seeded |
| AdversarialBenchmark | You are comparing which adversarial model should drive multi-turn attacks against the same target | Answers a model-selection question, not a general target assessment; cost rises with the technique set | Which adversarial models are registered and which technique set is default |
| Custom scenario | Your application has its own objectives, data or harm definitions that no packaged scenario covers | Repeatable and specific, but you must author and maintain the objectives, techniques and scorers | Scorer logic and that the scenario is discoverable by pyrit_scan list commands |
| Technique selection | Start with one single-turn technique to confirm the target responds and scoring works | Fewer techniques lower cost but can miss weaknesses that only multi-turn or encoded prompts expose | Whether a technique can be limited from the command line in your version |
| Dataset selection | Choose the smallest dataset that matches the harm you are checking for the first pass | Relevant content gives meaningful results; a large or mixed dataset raises request cost | Dataset licenses and content warnings before loading harmful-content sets |
| Dataset size limit | Set a small cap on objectives for the first run to confirm configuration, targets and output | A small sample can under-report success rates, so treat early numbers as a smoke test | The option name for limiting objectives in your installed pyrit_scan version |
How the scanner, target, scorers and memory connect
The run starts on the operator's machine, where pyrit_scan loads a registered scenario and its objectives. Each objective passes through converters and an attack strategy before it reaches the registered target endpoint, which sits outside the operator's trust boundary. Responses return to the scorers, which may call an LLM judge or Azure AI Content Safety, and every conversation and score is written to SQLite or Azure SQL memory. Check which scoring service receives response text, and confirm where the memory database lives before running against production systems.
Data flow from the operator's machine to the target and scoring services, with results stored in memory.
Reading pyrit_scan output without overstating results
A first pyrit_scan run gives you a sample of how the target behaved on the prompts you chose, not a measure of how the system behaves. Read the output with that limit in mind before anyone quotes a number. Start by identifying, for each stored result, the objective that was attempted, the technique and converters applied, the prompt actually sent to the target, the response that came back, the scorer's verdict and the overall outcome the scenario assigned. Those fields tell you what was tried and what was judged. They do not tell you how often a harmful answer would appear across the full range of real users or inputs.
Confirm the output format for your installed version before you build any tooling on it. Field names, the console summary layout, and where results are written can change between releases, and the PyRIT documentation for the version you run (see the PyRIT documentation 1.1.0) is the authoritative reference. Check the stored memory records as well as the console summary, because the summary may round or aggregate in ways you need to understand. Write down the exact version, scenario name, target configuration and dataset size alongside every result so a later reader can reproduce the run.
When you report results, state the sample size, the datasets and techniques used, and the scorer's known limits. A low success count from a small first run does not show the target is safe, and a high count does not prove it is unsafe, because scorers can misclassify responses and a single run is subject to randomness in the attacks. Treat the first run as a way to find out whether the setup works and where the failures cluster, then plan a larger, repeatable run and a human review of a sample of scored responses before drawing conclusions.
Security considerations for scanner credentials and attack content
A pyrit_scan run touches three kinds of sensitive material: the credentials that reach your targets, the memory that records every prompt and response, and the logs and artifacts that leave the machine that ran the scan. The cards below cover one risk each, with the control to apply and the check to run before the scanner goes into shared use.
Plaintext keys in ~/.pyrit/.env
PyRIT reads credentials for model providers and target endpoints from ~/.pyrit/.env, so any user or process that can read that file can call your targets with your keys. Restrict the file to the account that runs scans, keep it out of repositories and container images, and confirm which keys it holds before you copy it to another machine. Rotate any key that has been stored in a shared home directory.
Settings in .pyrit_conf
The ~/.pyrit/.pyrit_conf file holds settings that change how scans behave, including which memory backend is used and where it lives. Review it alongside the credentials file, because a changed setting can send results to a different database than the one your team reviews. Record its contents in your change process so a scan run can be traced to the configuration that produced it.
Who can read scan memory
PyRIT memory stores conversations and scores in SQLite or Azure SQL, and anyone who can open that database can read every attack prompt and model response in it. Set file permissions on the SQLite file or database role membership on Azure SQL to the people who review results, and confirm that the scanner account is the only writer. Treat the memory database as sensitive data, not as a scan cache.
PyRIT documentationWhere attack content is stored
Attack prompts, converted variants and model responses can include harmful text that your organization does not want on a laptop or in a general-purpose share. Decide the storage location before the first run, keep it on an encrypted volume with a retention rule you can state, and delete or archive memory files at the end of an assessment. Ask your security team which classification applies to this content.
Attack content in shared logs
Console output, CI job logs and ticket attachments can copy attack prompts and responses outside the protected memory store. Keep scanner output at a summary level in shared channels, send full conversations only to the restricted review location, and avoid echoing prompt text in pipeline scripts. Check your CI system's log retention and who can download job logs before you connect a scan to a build.
Shared runner access
A scanner on a shared build runner can expose target credentials to other jobs and leave memory behind for the next user. Run scans on dedicated runners or ephemeral containers, inject keys from a secrets manager at job start, and clear the memory location when the job ends. Confirm with your platform team how runner workspaces are isolated before you grant the scanner access to production targets.
Questions teams ask before running pyrit_scan themselves
Can an internal team run pyrit_scan on its own?
Yes, a team with Python experience and access to its own AI system can install PyRIT and run pyrit_scan without outside help, because the package installs with pip and the documentation recommends Python 3.13. The PyPI package supports Python 3.10 up to but not including 3.15, so confirm your interpreter version before you start. The harder part is not the install. Someone has to choose the scenario, decide which objectives count as failures, configure the target and read results that may include sensitive model output. Teams with a named test owner and at least one engineer comfortable with Python and API credentials usually manage a first run without a partner. Confirm that your security team approves running adversarial prompts against the system.
How much effort does a first pyrit_scan run take?
Effort depends mostly on how many moving parts you must connect, not on the scan command itself. A first run against a single registered target with a packaged scenario is a small job, and PyRIT lets you limit dataset size so the first pass stays short. Effort grows when the target needs custom authentication, when scoring depends on an external judge model, or when results must be reviewed and written up for auditors. Work with your team to list each target, credential, scorer and output destination before estimating. No public effort figure for PyRIT setup was supplied, so ask any partner for a written estimate tied to that list.
What access does the work need from our team?
Four kinds of access matter most, and each should be named before the run:
What changes the timeline for setup and first results?
The timeline moves with access approvals, target readiness and the review cycle, more than with PyRIT itself. Installing the package and listing scenarios can happen the same day, but waiting for model credentials, network allow-listing for a custom endpoint or sign-off on test content can take longer. Scorer choice also matters, since an LLM judge requires its own model access and adds requests to each run. Ask for a dated plan that separates the access step, the first scan and the result review, and confirm which of those steps your organization controls.
How do we read pyrit_scan output without missing failures?
Read the output as a set of attack results tied to objectives, not as a single pass or fail count. Each objective records the prompt sent, the response received and the score assigned by the scorer, so a reviewer should check both the score and the underlying conversation. Store runs in PyRIT memory, which uses SQLite or Azure SQL, so results can be queried and compared later. Treat scorer decisions as judgments that need spot checks, especially for borderline responses. Confirm with your test owner how results will be labeled and retained, because the transcripts can contain harmful content.
Does running pyrit_scan create compliance evidence?
A scan produces records of what was tested and what happened, but it does not on its own satisfy a compliance assessment. Auditors and certification bodies decide whether evidence is sufficient, and DeployOpen does not issue audit reports or certifications. Keep the scenario name, target configuration, dataset, scorer and memory records together so a reviewer can trace each result. Ask your compliance lead which framework applies and what format they expect before the first run.
When should we bring in a partner for pyrit_scan?
Bring in a partner when the work outgrows your internal capacity or your accountability needs an outside test team. Common triggers include a target behind complex authentication, a need for a repeatable CI run, a regulated release that requires documented methodology, or no internal engineer with time to own the test. DeployOpen runs security testing of AI systems and agents and prepares evidence for compliance assessments, and most engagements are fixed-scope with scope and deliverables agreed in writing before work starts. A quote follows from that written scope, and DeployOpen does not publish a price list. Ask any provider to name the target, scorers, datasets and deliverables in the proposal.
What does a partner cost, and what recurs after the first run?
Costs fall into three groups: the one-time setup and first assessment, the model and scorer usage during each run, and any ongoing testing or retesting. The scope document should show who pays for model tokens and API calls, whether your own cloud accounts are used, and what happens when you rerun the scenario after a model change. Ongoing support, upgrades and continuous testing are available as retainers, so ask whether a recurring plan fits your release frequency. No specific figure for these components was supplied here, so request an itemized quote tied to the written scope.
Official PyRIT sources for scanner setup
Start with the official PyRIT documentation for command usage, and treat the repository as the record of what each release actually changed. Scenario names, flags and output formats for pyrit_scan can differ between versions, so check the documentation version that matches the release you install rather than copying examples from older blog posts or forum answers. The documentation is published for version 1.1.0 at PyRIT documentation 1.1.0, and the version you pin in your environment is the one that governs your commands.
Confirm three things before you write any pipeline or runbook around the scanner. First, which Python version the package supports for your release, since the PyPI package and the documentation recommend different interpreters. Second, whether the scenario, target and dataset names you plan to use still exist in that release, using the command that lists them. Third, whether the release notes mention changes to scanner flags or memory handling. The microsoft/PyRIT releases page lists these changes per version, and the pyrit package on PyPI shows the supported Python range for the version you install.
Use the repository at microsoft/PyRIT for source-level questions and issue history. The original Azure/PyRIT repository was archived on 27 March 2026 and is read-only, so older links, tutorials and copied configuration may point there and be out of date. If a source you found describes a flag or scenario that does not exist in your installed version, record the version mismatch and resolve it against the documentation for that release before the scanner runs in shared infrastructure.
Setting up a first pyrit_scan run on a registered target
This sequence takes a workstation from a bare Python install to a small, verified pyrit_scan run against one target you own. It ends with stored results you can open, check and reuse as a baseline before you widen the scope.
Confirm a supported Python version
The engineer running the assessment creates an isolated virtual environment on a Python version the PyPI package supports, which is 3.10 up to but not including 3.15. The PyRIT documentation recommends Python 3.13, so use that if your platform team can provide it. Verification: run the Python version command inside the new environment and confirm the reported version falls in the supported range before installing anything.
Install PyRIT from PyPI
With the environment active, the engineer installs the PyRIT package with pip from the Python Package Index. Record the exact version installed, because command names, configuration keys and scenario lists can change between releases. Verification: run pip to show the installed package and confirm the pyrit_scan command is available on the path. If the command is missing, the environment is probably not the one your shell is using. See the pyrit package page for the current install details.
Create the credentials file
Create ~/.pyrit/.env to hold the credentials the target needs, such as an API key or endpoint for a model service. Set file permissions so only the test engineer can read it, and keep the file out of any repository. Confirm the exact variable names in the PyRIT documentation for your target type. Verification: confirm the file exists and is readable only by your account. Do not print its contents into a terminal log or a shared ticket.
Create the settings file
Create ~/.pyrit/.pyrit_conf for PyRIT settings such as the memory location and default options. Start with the smallest file that works and confirm each key against the documentation for the release you installed. Verification: run a read-only pyrit_scan help or list command. If the settings file is malformed, the command should fail here with a message that names the problem, so fix it before you register a target.
Register one target
Register a single target in the configuration, using a model deployment or application endpoint that your organization owns or has written permission to test. Use a non-production system where possible, since the assessment sends adversarial prompts. Give the target a clear name so results can be traced later. Verification: list the registered targets and confirm your target appears with the name you chose and no credential values are shown.
List scenarios and targets
Run the list commands for scenarios and targets to confirm what this installation can see. Compare the scenario names with the ones in your test plan, and confirm the scenario you intend to run is available. Use the help output for the exact list syntax, since flags vary by release. Verification: the output shows your registered target and the chosen scenario, and the command returns without errors.
Run the scenario with a small limit
Run one scenario against the registered target with a dataset limit set to a small number of objectives, so the first run finishes quickly and costs little. Choose one technique or the smallest technique set the scenario offers. Keep the limit in your run notes so the next run can be compared. Verification: the command completes and reports a run identifier. If it fails on the first objective, check the target credentials and endpoint before raising the limit.
Check the stored results
Open the stored results for the run identifier and confirm that each objective produced a conversation and a score. The number of records should match the limit you set. Check where PyRIT stores memory in your configuration, since results are kept in SQLite by default or in Azure SQL. Verification: the record count matches the limit, the scores are present, and the run identifier is saved in your run notes for the next step.
How DeployOpen scopes and delivers PyRIT scanner work
DeployOpen scopes a PyRIT scanner setup in writing before any work starts, and the written scope is what the quote follows from. For a pyrit_scan engagement, the scope names each registered target and the access it needs, the scenarios to run against each one, the datasets and dataset size for the first run, and how credentials are supplied. It also states where the ~/.pyrit/.env and ~/.pyrit/.pyrit_conf files will live, which SQLite or Azure SQL memory store will hold results, and who in your organization receives the output. Each of these decisions changes the effort, so ask for them to be listed explicitly in any proposal you receive, including which items are one-time setup and which recur on each run.
Delivery ends with a first verified run rather than a configuration file handed over. DeployOpen confirms that the target responds to the scenario, that scorer output lands in memory where your team can query it, and that a small dataset run completes and produces the output format your reviewers expect. Your team should check that the target endpoint and credentials are the ones you intended, that the scan does not send test content to a production system without approval, and that the people reading the results know how to interpret them. Before the handover, ask for a short runbook covering the commands used, the expected output and the steps to repeat the run.
DeployOpen runs security testing and prepares evidence. It does not issue audit reports, attestations or certifications, and PyRIT output is not an audit opinion on your system. Independent auditors and certification bodies make those determinations, and you should confirm with them which records they will accept. Ongoing testing as models, prompts or targets change is available through retainers, which DeployOpen scopes against your release cadence. Ask for the retainer terms, the testing frequency and the retest process in writing, since those define the recurring effort.

