Insights

PyRIT red teaming: test AI systems safely

4 min read

PyRIT red teaming: free open-source Microsoft AI red teaming toolkit title card

PyRIT red teaming: test AI systems safely

PyRIT red teaming: free open-source Microsoft AI red teaming toolkit title card

PyRIT red teaming is a free, open-source toolkit from Microsoft that runs automated scans and adaptive multi-turn attacks against generative AI systems, so a security engineer can find weaknesses before an attacker does. It brings a command-line scanner, a browser GUI and an extensible Python framework into one package, and it is the most practical way I have seen to study the standing theme of fully automated, agentic AI-driven cyber attacks from the defender’s side.

That theme is not theoretical. Google’s threat group has warned that fully automated, AI-driven attacks are moving from experiment to real intrusions, and our earlier briefing on how ransomware groups use AI agents shows how ransomware groups have begun using AI agents to automate entire attacks. Before an attacker points an agent at a target, defenders need the same class of capability pointed at a system they control.

What PyRIT red teaming does

PyRIT stands for Python Risk Identification Tool for generative AI. It is built by the Microsoft AI Red Team and an open-source community of contributors, and it reached version 1.0.0 in 2026.

The scanner is the primary way to run assessments. You pick a scenario, point it at a target, and it runs. Scenarios bundle attack techniques, datasets and scoring into a reusable package. Built-in families include adaptive multi-turn attacks such as Crescendo and Tree of Attacks with Pruning, AIRT scenarios covering content harms, psychosocial risks, data leakage and jailbreaks, and Garak scenarios for encoding probes, FigStep, web injection and system-prompt extraction.

PyRIT connects to OpenAI, Azure OpenAI, Anthropic, Google Gemini, Google Vertex AI, AWS Bedrock, Hugging Face, Ollama, Groq, OpenRouter, Cohere and GitHub Copilot, or any OpenAI-compatible API. It can also test complete applications through HTTP endpoints, WebSockets and browser automation with Playwright, or you can build your own target with a simple interface.

CoPyRIT is the graphical interface for human-led red teaming. You interact with AI systems directly, track findings and review results in your browser. For custom workflows, the Python framework lets you compose targets, converters, scorers, executors, techniques and scenarios into your own assessment pipeline.

Everything is recorded in a built-in memory store, SQLite or Azure SQL, so conversations, scores and attack results are kept in one place and can be exported and shared with your team.

The licence

PyRIT is released under the MIT licence, which you can read in the licence file on the repository. MIT is permissive: it allows use, modification and distribution, including commercially, provided the copyright notice is retained. It provides no warranty and no support commitment.

Installing it on Linux

The official documentation covers installation in detail. You need Python 3.11, 3.12, 3.13 or 3.14.

Install with pip:

pip install pyrit

Or with uv:

uv pip install pyrit

Verify the install:

python -c "import pyrit; print(pyrit.__version__)"

There is also a Docker option with a pre-configured container and JupyterLab if you want to get started without managing a Python environment. After installing, configure your AI endpoint credentials through the provider configuration guide; available features depend on the target and model you choose.

A concrete authorised lab use case

Run this only against a target you own or have written permission to test. A sensible starting point is a lab AI service on an isolated network.

Point the scanner at your lab service with a built-in scenario such as the AIRT jailbreak family, and let it run. Watch which prompts succeed, how the target responds, and whether the scoring marks a finding as a hit. Then check each claimed finding against the raw responses yourself before it reaches a report.

You can also use CoPyRIT to walk through a prompt-injection path by hand, or extend the Python framework to test the specific content-harm or data-leakage behaviour your organisation cares about. Read our guide to building a lab with Parrot OS and Kali Linux if you need the network side of the setup sorted first.

Risks and limits

  • Data leakage. Anything you send to a target, including prompts that contain internal details, can reach the provider you choose. Keep customer data and production secrets out of the prompts you feed it, and use a test account rather than a production one.
  • Prompt injection. If a scenario or dataset feeds untrusted content into the target, that content can steer the model’s behaviour. Treat dataset contents as untrusted input.
  • Hallucinated findings. A reported hit may not match the real target state. Every finding should be checked against the raw output before it reaches a report.
  • Licence limits. MIT permits reuse and commercial use with notice retention, and provides no warranty. The project is actively developed, so check that your installed version matches your notebooks.
  • What not to send it. No production credentials, customer data, real domain contents, or systems you are not authorised to test.

Use PyRIT only against systems you own or have written permission to test. Using it against systems you do not have permission to test is unlawful.

Sources