In plain English
Before a company ships a generative-AI app, someone has to try to break it: coax it into giving harmful instructions, leak its hidden system prompt, or be tricked by a poisoned document. That deliberate adversarial testing is AI red-teaming. Done by hand it is slow, inconsistent, and impossible to repeat the same way twice.

PyRIT — the Python Risk Identification Tool — is Microsoft's open-source framework for automating that work. Instead of a human typing one clever attack prompt at a time, you write a small script that fires hundreds of attack variations at the model, automatically grades each response for whether the attack succeeded, and even carries on a back-and-forth conversation to wear the model's defenses down over several turns.
Think of it like an automated penetration-testing rig, but for language models instead of networks. A human red-teamer is the security expert who knows what to look for and which weaknesses are worth probing. PyRIT is the tireless robot that runs those probes thousands of times, in every variation, overnight, and hands back a scored report in the morning. The human still aims; PyRIT pulls the trigger over and over.
Why it matters
Generative-AI systems fail in ways traditional software does not. The same input can produce different outputs each time, a tiny rewording can slip past a filter that blocked the original, and risks like jailbreaks, prompt injection, data leakage, and toxic content all have to be checked. Manual testing simply cannot cover that surface area.
- Coverage. A person might try a handful of jailbreak techniques by hand. PyRIT runs every technique against every harm category, with dozens of phrasings each, so gaps are far less likely to slip through.
- Repeatability. Because the attacks live in code, you can re-run the exact same red-team suite after every model update or prompt change and see whether something that was safe yesterday regressed today. Manual tests are almost impossible to reproduce faithfully.
- Scale and speed. Automated probing explores hundreds of conversation paths in the time it takes a human to type one, and it can run unattended in a pipeline.
- Consistency of scoring. A human grader gets tired and rates the same response differently at 9am and 5pm. An automated scorer applies the same rubric to every single response.
The honest framing: automation does not make human red-teamers obsolete. People are still far better at inventing novel, creative attacks and at judging subtle, context-dependent harm. PyRIT's value is taking the attacks experts already know about and running them exhaustively — see automated vs manual red-teaming for the trade-off. The two work together: humans find the new attack, then encode it in PyRIT so it is tested forever after.
How it works
PyRIT breaks red-teaming into a few swappable building blocks. You assemble them like Lego: pick a target to attack, a converter to mutate your prompts, a scorer to judge the answers, and an orchestrator to run the whole loop. Because each piece is an interface, you can swap one without rewriting the rest.
The core building blocks
- Target — the thing under attack: an LLM API, a chatbot endpoint, or a whole RAG application. PyRIT talks to it through a uniform interface, so the same attack script can point at any model.
- Converter (attack/transform strategy) — a step that mutates a prompt to slip past defenses. Converters can translate text to another language, encode it (Base64, ROT13, leetspeak), rephrase it, or chain several transforms together. The idea is to test whether a filter that blocks the plain wording is fooled by a disguised version.
- Scorer — decides whether an attack succeeded. A scorer reads the model's response and labels it, for example "did this output contain disallowed content?" Scorers can be simple rules (keyword or regex checks) or, more powerfully, an LLM-as-a-judge that grades the response against a rubric.
- Orchestrator — the conductor that ties it all together: it takes your seed prompts, runs them through converters, sends them to the target, passes responses to the scorer, and decides what to send next. Single-turn orchestrators fire one prompt; multi-turn ones hold a conversation.
Multi-turn automation: the real power
The most interesting orchestrators run automated multi-turn attacks. Here PyRIT uses one model as an attacker whose job is to jailbreak a second model, the target. The attacker sends a probe, reads the target's refusal, then adapts and tries a softer or sneakier angle — turn after turn — while a scorer watches for the moment the target gives in. This mimics how a persistent human social-engineers a model over a long chat, but it runs automatically and at scale.
Everything is logged to a memory store so every prompt, response, and score is recorded. That memory is what makes the run auditable: you can replay exactly which conversation broke the model, and re-run the whole suite later to confirm a fix held.
A minimal PyRIT-style script
The pieces above map almost directly onto code. The exact class names evolve between releases, so treat this as the shape of a PyRIT script rather than copy-paste-ready syntax: you configure a target, optionally wrap prompts in converters, pick a scorer, and let an orchestrator drive the loop.
# 1) TARGET — the model you want to probe.
target = OpenAIChatTarget() # any LLM endpoint, behind a uniform interface
# 2) CONVERTERS — disguise the prompt to test filter robustness.
converters = [Base64Converter(), TranslationConverter(language="french")]
# 3) SCORER — an LLM-as-a-judge decides if an attack succeeded.
scorer = SelfAskRefusalScorer(chat_target=judge_model)
# 4) ORCHESTRATOR — runs seed prompts through converters -> target -> scorer.
orchestrator = PromptSendingOrchestrator(
objective_target=target,
prompt_converters=converters,
scorers=[scorer],
)
seed_prompts = ["<a disallowed request you want the model to refuse>"]
await orchestrator.run_attacks_async(objectives=seed_prompts)
# Every prompt, response, and score lands in PyRIT's memory store
# so you can audit exactly what happened and re-run it later.
Where PyRIT fits among red-team tools
PyRIT is a framework you script against, which is its strength and its cost. Other tools trade that flexibility for turnkey scanning. A quick orientation:
| Tool | Shape | Best when |
|---|---|---|
| PyRIT (Microsoft) | Scriptable Python framework with swappable parts | You want custom, adaptive, multi-turn attacks tailored to your app |
| Garak (NVIDIA) | Run-and-report scanner, like nmap for LLMs | You want a fast off-the-shelf vulnerability scan with little setup |
| Guardrails / classifiers | Runtime defenses that block bad I/O | You want to stop attacks in production, not find them in testing |
The key distinction: PyRIT and Garak are offensive testing tools used before you ship, to surface weaknesses. Guardrail and safety-classifier systems are defensive and run in production, blocking bad inputs and outputs at request time. You red-team with the first kind, then deploy the second kind to defend against what you found. They are complementary, not alternatives.
Common pitfalls
PyRIT automates the running of attacks, but the quality of the results still depends entirely on you. Most disappointing red-team runs trace back to these mistakes.
- Weak scorers give false confidence. If your scorer only checks for a few banned keywords, a model can produce genuinely harmful content that slips past it — and you will report a clean run that isn't. Invest in good scoring (often an LLM judge with a clear rubric) as much as in the attacks.
- Treating a clean run as proof of safety. PyRIT can only find the weaknesses you thought to test. A passing suite means "none of these attacks worked," never "this model is safe." Novel attacks you didn't encode go undetected.
- Forgetting the attacker and judge models drift. When you use one LLM to attack or to score another, those helper models change over time and behave differently. Pin and document them, or your results won't be reproducible.
- Ignoring cost and rate limits. Multi-turn automation can fire thousands of API calls in a run. Without batching and limits you can rack up a surprising bill or get throttled mid-suite.
- Running it where you shouldn't. PyRIT generates genuinely harmful prompts and adversarial content. Only point it at systems you are authorized to test, and keep the logged outputs secured.
Going deeper
Once the basic loop clicks, the depth of PyRIT is in how cleverly you combine the building blocks. A few directions worth exploring.
Chained and stacked converters. Real filters are tested hardest when transforms stack: translate to another language, then Base64-encode, then wrap in a role-play frame. Each layer probes a different assumption in the target's defenses, and the combinations grow fast — exactly the kind of search space automation is built for. This connects directly to the catalogue of common jailbreak techniques.
Adaptive attacker strategies. Beyond simple back-and-forth, advanced orchestrators implement published attack algorithms where the attacker model plans, branches, and backtracks to find a path through the target's guardrails. These turn red-teaming into an automated search problem, and they are where the field is most actively researched. They build on the broader study of adversarial prompts.
Testing whole applications, not just models. A target doesn't have to be a bare API — it can be your full RAG or agent pipeline. Pointing PyRIT at the complete system surfaces app-level risks like indirect prompt injection through retrieved documents, which a model-only test would miss entirely.
Wiring it into CI and governance. The repeatability that makes PyRIT useful also makes it a governance tool: run a fixed adversarial suite on every release, track whether the success rate of known attacks goes up or down over time, and gate deploys on the result. That turns ad-hoc red-teaming into a measurable, ongoing safety signal.
The durable lesson: PyRIT is a force multiplier for human expertise, not a substitute for it. It exhaustively runs the attacks people already understand and frees those people to do what automation can't — invent the next attack. A red-team program that pairs creative human probing with PyRIT's tireless, scored, repeatable execution covers far more ground than either approach alone.
FAQ
What does PyRIT stand for?
PyRIT stands for Python Risk Identification Tool. It is Microsoft's open-source Python framework for automating generative-AI red-teaming — scripting adversarial attacks against a model, scoring the responses, and running them at scale.
Is PyRIT free and open source?
Yes. PyRIT is released by Microsoft as an open-source project on GitHub, free to use. You do still pay for whatever model APIs you point it at, since attacking and scoring both consume model calls.
What is the difference between PyRIT and Garak?
Garak is a run-and-report scanner — point it at a model and it fires standard probes with little setup. PyRIT is a scriptable framework: you assemble targets, converters, scorers, and orchestrators to build custom, adaptive, multi-turn attacks. Garak is fastest off the shelf; PyRIT is more flexible when you need attacks it doesn't ship with.
Does PyRIT replace human red-teamers?
No. PyRIT automates running attacks that experts already know about, exhaustively and repeatably. Humans are still far better at inventing novel attacks and judging subtle, context-dependent harm. The two are complementary — people find the new attack, then encode it in PyRIT so it is tested forever after.
What are the main components of PyRIT?
Four core building blocks: a target (the model or app under attack), converters (mutate or disguise prompts to test filters), scorers (judge whether an attack succeeded, often via an LLM-as-a-judge), and orchestrators (drive the whole loop, including adaptive multi-turn conversations). A memory store logs every prompt, response, and score.
Can PyRIT test a full RAG or agent app, not just a model?
Yes. A PyRIT target can be your entire application, not just a bare model API. Pointing it at the full pipeline surfaces app-level risks like indirect prompt injection through retrieved documents that a model-only test would miss.