PyRITpyrit 1.1.0 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
36 small wins to finish your pathNext lesson

Installation and setup

One pip command installs PyRIT. Its chat target reads an endpoint, a key and a model name, and Groq's free OpenAI-compatible API fits all three.

pip install pyrit 1.1.0

PyRIT pulls in more than a red-team library: a SQLAlchemy stack for the database that records runs, azure-identity for signing in to Azure endpoints, and transformers for converters and scorers that run a local model. None of them need configuring for this course.

pip install "pyrit==1.1.0"
Example
import pyrit

print(pyrit.__version__)

Everything in this course was run against that version. PyRIT moves quickly and names have changed between releases, so if yours differs, expect at least one signature in the course to have moved.

An OpenAI-compatible targetOptional

The system under test in this course is the shop assistant you write in lesson 6, so none of this is needed to follow along. To attack a hosted model, OpenAIChatTarget reads OPENAI_CHAT_ENDPOINT, OPENAI_CHAT_KEY and OPENAI_CHAT_MODEL.

ProviderKeyOPENAI_CHAT_ENDPOINT and OPENAI_CHAT_MODEL
GroqFree, console.groq.com/keyshttps://api.groq.com/openai/v1, openai/gpt-oss-120b
GeminiFree, aistudio.google.com/apikeyhttps://generativelanguage.googleapis.com/v1beta/openai/, gemini-2.5-flash
OpenRouterFree models end in :free, openrouter.ai/keyshttps://openrouter.ai/api/v1, google/gemma-4-31b-it:free
OpenAIPaid, platform.openai.com/api-keyshttps://api.openai.com/v1, gpt-4o-mini
export OPENAI_CHAT_KEY=gsk_...
export OPENAI_CHAT_ENDPOINT=https://api.groq.com/openai/v1
export OPENAI_CHAT_MODEL=openai/gpt-oss-120b

On your own machine PyRIT also loads these from ~/.pyrit/.env when it is initialised, so they survive a new terminal. Keep that file outside any repository.

text
# ~/.pyrit/.env
OPENAI_CHAT_ENDPOINT=https://api.groq.com/openai/v1
OPENAI_CHAT_KEY=gsk_...
OPENAI_CHAT_MODEL=openai/gpt-oss-120b
Try it yourself
  • Run pip show pyrit and find the database library in its dependency list.

Little by little, you're building something great.