PyRIT (Python Risk Identification Tool) is an open-source framework for automated red teaming of generative AI systems. In AI security, it helps security professionals and machine learning engineers probe large language models and AI applications for risks such as jailbreaks, prompt injection, harmful content generation and data leakage, by sending large numbers of crafted prompts, transforming them and scoring the responses.
PyRIT was developed by the Microsoft AI Red Team and released publicly in 2024 under the MIT license. It does not replace human red teamers; it automates the repetitive parts of an assessment so that experts can concentrate on creative attack design and on judging ambiguous results.
How PyRIT automates red teaming
PyRIT works as a composable pipeline: seed prompts are loaded, optionally transformed by converters, sent to a target system, and the responses are evaluated by scorers. An orchestration layer coordinates these steps, from single-turn bulk sending to multi-turn attacks in which an attacker model adapts its next message to the target’s last reply.
Every prompt and response is written to a memory store, so assessments are reproducible and results can be queried later. This record is essential when a finding must be reported to developers, retested after a fix or compared across model versions.
The table below lists the main components and the role each one plays.
| Component | Role | Examples |
|---|---|---|
| Datasets | Supply seed prompts and objectives | Harm categories, jailbreak templates |
| Targets | Represent the system under test | Hosted model endpoints, HTTP applications, local models |
| Converters | Transform prompts to evade filters | Base64, character swaps, translation, text to image |
| Orchestrators | Coordinate attack strategies | Bulk sending, Crescendo, tree of attacks |
| Scorers | Judge whether an attack succeeded | LLM-as-judge, keyword match, content classifiers |
| Memory | Persist conversations and scores | Local database or cloud SQL store |
Newer releases reorganize orchestration under the name attacks and executors, but the underlying concepts remain the same.
Attack strategies supported by PyRIT
PyRIT implements several published attack strategies so that teams can run them consistently against their own systems. Single-turn strategies test how a model reacts to an isolated harmful request, while multi-turn strategies test whether guardrails erode over a conversation.
| Strategy | Turns | What it tests |
|---|---|---|
| Prompt sending | Single | Baseline refusal behavior across many prompts |
| Converter chains | Single | Robustness of filters to encoding and obfuscation |
| Red teaming orchestration | Multi | Whether an attacker model can reach an objective |
| Crescendo | Multi | Gradual escalation from benign to harmful requests |
| PAIR and tree of attacks | Multi | Iterative prompt refinement guided by a judge |
| Cross-domain prompt injection | Single or multi | Instructions hidden in documents or web content |
The multi-turn strategies are particularly valuable because multi-turn jailbreaks often succeed where single prompts fail. An attacker model, typically another LLM with a red teaming system prompt, generates each message and stops when the scorer reports success or a turn limit is reached.
PyRIT compared with other AI security tools
PyRIT belongs to a small group of open-source LLM security tools, but each tool emphasizes a different workflow. The comparison helps teams choose or combine them.
| Tool | Main focus | Typical use |
|---|---|---|
| PyRIT | Programmable red teaming framework | Custom multi-turn campaigns against specific applications |
| garak | LLM vulnerability scanner | Broad automated probe sweeps with reports |
| Adversarial Robustness Toolbox | Classical adversarial ML | Evasion and poisoning tests on vision and tabular models |
| Promptfoo | Evaluation and red teaming configuration | Regression tests in continuous integration |
PyRIT is code-first: assessments are written as Python scripts or notebooks, which offers flexibility but requires programming skill. Scanners such as garak are better for quick, broad coverage, while PyRIT suits targeted, scenario-driven testing of a particular product, including its retrieval pipeline and plugins.
Using PyRIT in a security assessment
An effective assessment starts with AI threat modeling: the team defines harm categories, attacker goals and the system boundary before writing any code. PyRIT is then configured with a target, a set of objectives and scorers matched to each harm category.
- Define objectives, such as extracting the system prompt or producing disallowed instructions.
- Configure targets, including authentication and rate limits for the system under test.
- Select strategies and converters appropriate to the threat model.
- Calibrate scorers against a small set of human-labeled responses.
- Run campaigns and review results, sending ambiguous cases to human experts.
- Retest after mitigation using the stored prompts from memory.
Findings are commonly mapped to frameworks such as MITRE ATLAS or the OWASP risk lists for language model applications, which makes them easier to prioritize and communicate.
Limitations and common mistakes
PyRIT measures attack success under specific conditions, not overall safety. A clean result means only that the chosen strategies failed against that model version. Several pitfalls recur:
- Uncalibrated LLM scorers produce false positives and false negatives; their verdicts must be spot-checked.
- Cost and rate limits: multi-turn campaigns can consume many thousands of model calls.
- Testing the model instead of the application, which misses risks in tools, retrieval and output handling.
- Running against systems without authorization, which is unethical and may breach terms of service.
- Treating a one-time assessment as sufficient, although model updates can reintroduce fixed weaknesses.
Explained without jargon
PyRIT is a testing kit for AI chatbots. Security teams use it to try many tricky questions on a chatbot. They want to see if it can be fooled into saying or doing something harmful.
Doing this by hand takes a long time. PyRIT sends thousands of attempts, rewrites them in clever ways and checks every answer. People still look at the hard cases. The goal is to find weak spots before attackers do.
A typical use case
A bank prepares to launch a customer support assistant built on a large language model with access to account summaries. Before release, its security team runs a two-week assessment with PyRIT. They define four objectives: revealing the system prompt, disclosing another customer’s data, giving unlicensed investment advice and producing abusive language.
The team sends about 2,000 seed prompts through Base64 and translation converters and runs 150 Crescendo conversations limited to ten turns each. An LLM scorer, calibrated against 100 human-labeled answers, flags candidate failures for analyst review.
Single-turn attacks succeed in under 1 percent of cases, but Crescendo extracts parts of the system prompt in 9 conversations. Developers add an instruction hierarchy and an output filter, and the team reruns the stored campaigns from memory. The leak no longer occurs, and the assessment becomes part of the release checklist for every model update.