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"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.
| Provider | Key | OPENAI_CHAT_ENDPOINT and OPENAI_CHAT_MODEL |
|---|---|---|
| Groq | Free, console.groq.com/keys | https://api.groq.com/openai/v1, openai/gpt-oss-120b |
| Gemini | Free, aistudio.google.com/apikey | https://generativelanguage.googleapis.com/v1beta/openai/, gemini-2.5-flash |
| OpenRouter | Free models end in :free, openrouter.ai/keys | https://openrouter.ai/api/v1, google/gemma-4-31b-it:free |
| OpenAI | Paid, platform.openai.com/api-keys | https://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-120bOn 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.
# ~/.pyrit/.env
OPENAI_CHAT_ENDPOINT=https://api.groq.com/openai/v1
OPENAI_CHAT_KEY=gsk_...
OPENAI_CHAT_MODEL=openai/gpt-oss-120b- Run
pip show pyritand find the database library in its dependency list.
Little by little, you're building something great.