How PyRIT red teams image and video generation models
PyRIT's OpenAI image, video and text-to-speech targets send your test prompts to the generation endpoint and collect the media that comes back, so your team can score what the model actually produced. The supported way to do this is through the Python framework, where you construct the target, attach your objectives and scorers, and run the attack yourself. The OpenAIImageTarget generates images and does not manage conversation history, so each request stands alone. That makes this work single-turn: one prompt in, one generated output out, with no earlier exchange for the model to build on. Multi-turn strategies such as Crescendo or TAP do not apply here, and you should plan the evidence around independent prompts instead of escalating conversations.
The practical decisions start before any run. Confirm which deployments your product calls, because image, video and speech endpoints may have different request fields, output formats and content filter behavior, and each one needs its own target configuration. Decide how credentials will be supplied, since keys set in ~/.pyrit/.env are common for local work but shared test environments often need a different approach. Also agree on what counts as a finding: a generated image that depicts a prohibited subject, a video that carries harmful content across frames, or speech that reproduces restricted text each call for a different scorer. Check the current target behavior and supported parameters in the PyRIT documentation for prompt targets before you write the harness, because the target types and their options should be confirmed against the version you install.
Scoring is where media testing differs most from text testing. Text can be read directly by an LLM judge, but a generated image or clip must first be converted into something a scorer can evaluate, and the scorer choice determines what your report can claim. Plan for human review of a sample, because automated judges can miss visual context and misread intent. Keep the generated files alongside the prompts, scores and run identifiers in PyRIT memory, so a reviewer can trace each output to the exact request that produced it. Ask your vendor or internal platform owner to confirm how the endpoint stores generated media, how long it is retained, and whether it is used for training, since those answers affect where the test artifacts may safely live.
What a PyRIT media test needs before it starts
A media test depends on a handful of prerequisites that are easy to overlook until a run fails. The cards below cover the runtime, the endpoint and its credentials, network paths, the memory store and a review location for generated media.
Python runtime and PyPI install
PyRIT installs from PyPI, and the package supports Python 3.10 up to but not including 3.15. The PyRIT documentation recommends Python 3.13, so pin that version on the test host or build image rather than inheriting whatever interpreter the host ships with. Confirm that your security team has approved the package source and version before the test team installs it into a shared environment, since the test host will hold credentials for a paid generation service.
PyPI packageMedia endpoint and API version
Image, video and text-to-speech targets each call a specific OpenAI-family endpoint, so the team must confirm which media deployments the endpoint exposes and which API version each one accepts. Ask the platform owner for the deployment names, base URL and supported versions in writing. Do not assume a deployment that exists for chat also serves image or audio generation, because the test will fail or, worse, test a different model than the one in production.
Credentials in the PyRIT environment file
PyRIT reads credentials from ~/.pyrit/.env and settings from ~/.pyrit/.pyrit_conf. Keep the API key for the media endpoint in the environment file on the test host only, with file permissions limited to the test operator's account, and keep it out of shared notebooks and source control. Use a key scoped to the test deployment and rotate it after the engagement. Ask who issues the key and who can revoke it.
Network path from the test host
The test host must reach the media endpoint over a network path your organization has approved, whether that is a public API address, a private endpoint or a gateway inside your network. Check egress rules, proxy settings and certificate trust before the first run, because a blocked call often looks like a model error. Record which path was used, since the route affects both the data exposure review and the reproducibility of results.
Memory store for run records
PyRIT memory records prompts, responses and scores, and it stores them in SQLite or Azure SQL. For a single operator, a local SQLite file is often enough, but generated media and prompts may be sensitive, so decide where the database file lives, who can read it and how long it is kept. If several testers share results, choose Azure SQL or another shared store deliberately and confirm access controls before the run begins.
Review location for generated media
Generated images, video and audio are the evidence a reviewer will inspect, and they are not always stored by the provider long enough for review. Designate a restricted folder or bucket on your side for media files, with naming that ties each file to its memory record and prompt. Agree in advance who may view harmful outputs, how they are labeled, and how files are deleted after review, because the material may include content that staff should not see casually.
How to configure the image, video and TTS targets in sequence
This sequence takes a team from a clean Python environment to a single benign generation request that returns a media file and a memory record. Each step ends with a check, so a failure is caught before the next target is configured. The result is a verified baseline for the image, video and text-to-speech targets.
Install PyRIT from PyPI
Create a dedicated virtual environment and install the package with pip from PyPI. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so use that version where your platform allows. Confirm the install by starting a Python session and importing the package without errors. Pin the installed version in your team's records so later test results can be traced to the exact release.
Store endpoint and key values in .env
Create the file ~/.pyrit/.env and place the endpoint and key values for your OpenAI-compatible image, video and speech deployments in it. Restrict the file to your operating system account and keep it out of source control and shared drives. Confirm the exact variable names for each target in the PyRIT documentation, since they differ by target and provider. The check is simple: when you load PyRIT in step 4, the target should read its endpoint without you typing a key into code.
Set defaults in .pyrit_conf
Create ~/.pyrit/.pyrit_conf to hold settings that should apply to every run, such as the memory backend and default options. Use SQLite for a single-analyst workstation or Azure SQL where results must be shared, and record the choice with the test plan. Keep secrets in .env and settings in .pyrit_conf so the two files can be reviewed separately. The check is that a new Python session reports the memory backend you configured, which confirms PyRIT read the file.
Create the OpenAI image target
Instantiate OpenAIImageTarget with the image deployment you intend to test and confirm it points at that deployment, not a default model. This target is used for image generation and does not manage conversation history, so every request stands alone and no prior turn is sent with it. Send nothing yet. The check is that the target object is created without errors and its endpoint matches the deployment name written in your test plan.
Create the video or text-to-speech target
Create the OpenAI video target or text-to-speech target in the same way, using the deployment and parameters named in the PyRIT Prompt Targets documentation for your PyRIT version. Confirm the class names and required parameters there rather than relying on this page, because targets change between releases. Also confirm whether each target keeps conversation history, and plan every request as single-turn if it does not. The check is that each target instantiates against its own deployment and that you have written down its history behavior.
Send one benign prompt and verify memory
Send one harmless prompt to the image target, such as a neutral scene description, and then repeat with the video or speech target using an equally harmless input. Open the returned image, video or audio file in a standard viewer to confirm it is complete and playable. Then query PyRIT memory, whether SQLite or Azure SQL, and confirm a record exists with your prompt and a reference to the generated file. Only proceed to scored or adversarial testing when both checks pass for every target.
Why these targets suit single-turn attacks rather than conversation
The image and video targets in PyRIT are built for single requests, and that shapes the attack plan more than any other choice. The OpenAIImageTarget does not manage conversation history, so each request arrives without the replies that came before it. Multi-turn strategies such as Crescendo, TAP or Skeleton Key depend on the target's prior answers to steer the next prompt, so they do not carry over to these endpoints in the same way. Before you schedule a run, confirm for each target type (image, video and text-to-speech) which attack patterns that target class supports in the PyRIT version you have installed, and record that answer in your test plan.
Without conversational steering, the variation has to come from the prompts themselves. Plan a set of objectives and seed prompts, then vary them across independent requests, for example by rewording the same harmful goal, changing the framing of the scene or subject, or mixing in different instructions. Use converters placed before the target to transform each prompt in a controlled way, such as encoding, translation or rewording, so that each transformation is a separate, recorded variable. Keep the converter chain fixed for a given run so that differences in results can be traced to the prompt change rather than to a moving setup.
Record every attempt as its own entry in PyRIT memory, including the original objective, the converted prompt, the generated output and the scorer result. Because each request stands alone, the memory record is the only trail of what the model produced and why it was judged as it was, so an attempt with no stored output or score should be treated as incomplete. Store the generated media alongside the record and confirm with your team where that media is kept and how long it is retained, since generated images and audio may contain sensitive content.
How a generated-media test flows from prompt to scored output
The test starts with a seed prompt or dataset entry, optionally rewritten by a converter, and is sent by PyRIT's OpenAI image, video or text-to-speech target to the generation endpoint inside your cloud account. The boundary marks where your credentials and data stay. The returned media is written to PyRIT memory, then a scorer (an LLM judge, Azure AI Content Safety or custom logic) produces a result for human review. Check at the boundary that keys are scoped to your endpoint and that stored media is handled under your retention rules.
Generated media moves from seed prompt through the client's endpoint into memory and scoring.
Choosing between image, video and text-to-speech targets
PyRIT's OpenAI image target sends a text prompt to an image generation endpoint and returns generated images. The input is a text prompt, often converted or rewritten from a seed objective. The output is one or more image files, which PyRIT stores in memory with their references. Because the target does not manage conversation history, each request is effectively single-turn, so an image test is a set of independent prompts rather than a dialogue that builds pressure over time.
- Input: a text prompt describing the image, with optional size and quality settings your endpoint accepts.
- Output: image files returned by the endpoint, stored for later review.
- Scoring: visual content review by a multimodal scorer or a human reviewer, checking whether the image shows the harmful content the objective targeted.
- Single-turn limit: no editable history means multi-turn strategies that rely on prior replies do not apply.
- Refusals: a refusal may arrive as an error or as a blank response, so confirm how your endpoint reports blocked requests.
Before testing, confirm the endpoint's image sizes, content filter behavior, and whether it returns images as URLs or base64 data, since that changes how files are retrieved.
Video targets send a text prompt, and in some deployments a reference image, to a generation service that returns a clip. The output is a longer media file, so the scoring question changes from whether one image is harmful to whether any part of the clip is harmful. Generation is usually slower and more expensive per request than image generation, which affects how many prompts a team can run in one session. As with images, the target is single-turn, so each test is an independent generation request.
- Input: a text prompt and, where supported, a reference image or other media.
- Output: a video file, which may be returned after an asynchronous job completes.
- Scoring: frame-level review of sampled frames, plus a check of audio tracks if the endpoint produces them.
- Cost driver: generation time and per-clip charges recur on every test, so sample size directly sets the bill.
- Job handling: confirm whether the endpoint is synchronous or asynchronous and how long a failed job takes to surface.
Confirm the maximum clip length, supported formats, whether audio is generated, and the retention period for generated files with the provider, because these decide your scoring design and data handling.
PyRIT's text-to-speech target takes text and returns synthesized audio. The harm in speech output is usually in the words being spoken, such as instructions, threats, impersonation or leaked data, along with tone and voice choice. For that reason, scoring typically starts with a transcript of the generated audio, which is then scored as text. A speech test therefore depends on the transcription step as much as the attack itself, and a transcription error can hide or invent a finding.
- Input: a text string to be spoken, plus voice and format settings your endpoint supports.
- Output: an audio file in the format the endpoint returns.
- Scoring: transcribe the audio, then apply a text scorer to the transcript, and spot-check transcripts against the audio.
- Voice risk: a request for a specific real person's voice may be a separate policy question that your endpoint enforces differently.
- Language coverage: transcription quality varies by language and accent, so test the languages you serve.
Confirm which voices the endpoint offers, whether it blocks voice cloning requests, and which transcription service your team will use, since the transcript is the evidence your report relies on.
Each output type calls for a different scorer, and mixing them without a plan produces results that are hard to compare. Image and video outputs are visual, so the scorer must be able to interpret pixels or frames. Speech outputs are converted to text before scoring, so the reliability of the transcription pipeline becomes part of the result. A single run may combine several modalities, so label every result with its output type so that attack success rates are not averaged across unlike media.
- Visual scoring: use a scorer that accepts images, and record which model or reviewer made each judgment.
- Frame sampling: for video, define how many frames are reviewed and how the sample is chosen.
- Transcript scoring: keep the transcription method and version with each speech result.
- Labeling: tag every result by output type so reports can separate image, video and speech findings.
- Human review: plan for a person to check a sample of flagged and unflagged media.
Before committing to a scorer, ask the vendor or your internal reviewers to show how it handles borderline cases in your chosen media type.
How to score generated images, video and speech
A PyRIT run against an image, video or speech endpoint produces media, not text, so the scorer has to be chosen for the media type it can read. The four approaches below are complementary, and each one has its own blind spots that the team should test before relying on results.
LLM-based scoring of media
A multimodal LLM judge can look at a generated image or listen to a transcript of speech and decide whether the output meets a harm rubric. Check that the judge model accepts the media type you generate, because a text-only judge given a video will score silence or metadata and report a clean result. For speech, decide whether the judge hears audio or reads a transcript, since a transcript can miss tone and non-verbal cues.
Azure AI Content Safety scoring
Azure AI Content Safety scoring applies a managed harm classifier to outputs, which gives a repeatable baseline that does not depend on another LLM. Confirm which media types the service classifies in your configuration before you rely on it for images, and treat its categories as a starting point that may not match your organization's definition of harm. Record the service version and region in your run notes so results can be reproduced.
Custom logic for organization rules
Some rules are specific to your business: a brand logo must not appear in a generated image, a voice must not impersonate a named employee, or a video must not show a restricted product. Custom scoring code can check for these with image hashing, text matching on transcripts, or a lookup against an approved asset list. Write the rule as a testable condition and keep the reference assets under access control, since they are sensitive too.
Human review of flagged outputs
Automated scorers both miss harms and flag harmless outputs, so a reviewer should inspect the media behind every flag and a sample of unflagged results. Give reviewers the original objective, the converted prompt and the generated file together, so they can judge intent. Record each reviewer decision in memory with a label so that the human verdict, not the scorer output alone, drives the reported finding.
Measuring scorer accuracy first
Before trusting any scorer, label a sample of generated outputs yourself, run the scorer over the same set, and compare the results. Look at false negatives first, because a missed harmful image is the failure that produces a false pass. Repeat the check when you change the scorer model, the media type or the harm rubric, since accuracy measured on one kind of output does not carry over to another.
Mapping prompts, outputs and evidence between PyRIT and your review process
This table maps each PyRIT element for image and video generation runs to what a reviewer needs to see. Use it to decide which fields PyRIT memory already holds and which your team must store in its own evidence system. Confirm field-level details against your PyRIT version before you design the evidence store.
| Reviewer need | What PyRIT provides | What your team should add |
|---|---|---|
| Seed prompt and source | The prompt text sent to the target, stored in memory with its conversation record | Dataset name, version, licence and the reason each objective was chosen |
| Target type and deployment | The target class used (for example, the OpenAI image target) and the endpoint it was configured to call | Deployment name, model version, region, content filter settings and the date the deployment was last changed |
| Generated file | A stored reference to the output piece when the target saves media locally | A content hash, immutable storage path, file size and retention period for each generated image or video |
| Scorer and result | Scorer identity and the score or verdict recorded against the response piece | Scorer version, the rubric used, the human reviewer's verdict on sampled items and any disagreement |
| Operator and run label | Run or operation labels that group memory entries when they are set by the operator | Named owner for each run, approval reference, environment and the change ticket that authorised testing |
| Multi-run comparison | Memory records that let you query conversations by label after the run | A fixed run manifest that lists PyRIT version, configuration file hash and dataset version for each run |
| Retention and access | Memory is stored in SQLite or Azure SQL, so access depends on where that database sits | Access controls on generated media, a deletion policy for harmful outputs and a log of who viewed them |
Securing the test environment and the generated content
Image and video generation endpoints produce artifacts that can carry harmful content, and the test setup holds the credentials and stored outputs that give access to them. The cards below cover how to keep keys out of the code, confine the endpoint to the test network, limit who can read generated media, handle harmful outputs, and set retention for memory databases.
Keep credentials out of scripts
PyRIT reads credentials from a .env file in the user's ~/.pyrit/ directory, so the generation endpoint key does not need to appear in notebooks or scan configs. Confirm that the file is readable only by the account running the tests, and that it is excluded from source control. Decide whether your organization requires a secret store such as a managed vault for the key, and confirm how the team will load it into the runner at test time.
Restrict the endpoint to the test network
An image or video generation deployment that accepts requests from anywhere expands the attack surface beyond the red team. Place the generation endpoint behind private networking or an allowlist that admits only the test runners, and confirm that the endpoint's own access controls match that policy. Record the network path in the test plan so reviewers can see which hosts could send prompts and receive output.
Control who reads generated media
Generated images and videos are stored in the test runner's output location and may also be saved in memory with their conversations. Set file system permissions so only the named testers can open them, and avoid copying media into shared chat or ticket systems. Confirm with your storage team which encryption at rest and access logging options apply to the directory or bucket you use.
Handle harmful outputs under policy
Some outputs from image and video red teaming will show content that is illegal or sensitive to view, such as material involving minors or graphic violence. Agree in writing who may review flagged media, how it is viewed, and when it is reported or deleted, and align this with your legal and trust and safety teams before the first run. Scorers can help triage, but they do not replace a human decision on what is retained.
Set retention for memory databases
PyRIT memory stores conversations and results in SQLite or Azure SQL, and those records can include prompts, scores and references to generated files. Define how long each test database is kept, who may query it, and when it is deleted after a report is delivered. Confirm the retention rules with your records and compliance owners, since the framework does not set a retention period for you.
Review the setup before each run
Credential location, network rules, media permissions and memory retention drift over time as runners are rebuilt and staff change. Put these four checks on a short checklist that a second person signs off before each test window. Keep the signed checklist with the test records so an assessor can see the controls were in place when the outputs were produced.
Common failures when testing image and video endpoints
This table lists the failures teams most often hit when pointing PyRIT at image, video and speech generation endpoints, with the likely cause and fix for each. Read it as a checklist to run through before a first attack run and again when a run returns empty or unexpected results.
| Failure | Likely cause | Fix |
|---|---|---|
| Requests fail with not found errors | Wrong endpoint URL or deployment name for the image, video or TTS model | Copy the deployment name exactly from your Azure OpenAI or Foundry resource and confirm the endpoint matches that resource before running attacks. |
| Calls rejected for the media type | API version does not support the chosen media type or model | Confirm in the provider documentation which API version serves image, video or speech generation, then set that version in the target configuration. |
| Scorer cannot read the output | Generated media is returned in a format or encoding the scorer does not handle | Check the response format the endpoint returns, then choose a scorer that accepts that media type or convert the output before scoring. |
| Multi-turn attack breaks after the first turn | OpenAIImageTarget does not manage conversation history, so follow-up prompts lack context | Restrict these targets to single-turn attacks, or move conversational testing to a chat target that keeps history. |
| Every prompt returns a refusal or blank result | Content filter blocks the request before it reaches the model | Record the filter response as a result, review filter settings with the resource owner, and test with filters on so findings reflect production behavior. |
| Generated files missing from memory | Memory configuration or output handling does not persist media references | Verify memory settings and the output location, then run one test prompt and confirm the file path and record appear before a full run. |
Questions buyers ask before testing image and video models
What drives the cost of red teaming image and video generation models?
The cost is driven by how much testing is agreed in writing: the number of generation endpoints, the media types in scope (image, video, text-to-speech, or a mix), the scoring method, and how deep the evidence must go. Each endpoint and media type adds objectives to build, runs to execute and generated output to review. Scoring is a major factor: automated scoring with an agreed classifier costs less to run than human review of every output, and an evidence pack with full memory exports and reproducible runs takes more preparation than a summary report. The team's existing PyRIT experience also matters, because a team new to the framework needs more setup and review time. Ask any provider for a quote that lists each endpoint, media type, scoring method and deliverable separately, so you can see which line items change if the scope changes.
How long does a scoped image or video model test take?
Duration follows the agreed scope rather than a fixed number of days. The same drivers that set cost also set the schedule: the number of endpoints, the media types, the size of the objective dataset, the scoring approach and whether a retest is included. Scheduling also depends on access. Approval for harmful-content testing, provisioning of test accounts and the availability of storage can take longer than the test itself, so start those steps early. Ask for a timeline that separates setup, test runs, review of generated media, reporting and any retest, with a named owner for each step.
What must our team supply before a media model test starts?
Four things need to be in place before work begins. First, endpoint access: the generation URLs, the model or deployment names and the authentication method, along with a clear description of any content filters that will stay on. Second, test accounts with the permissions the endpoints require, ideally separate from production users. Third, written approval from the internal owner for generating and reviewing harmful-content test prompts and outputs, including who may view generated media and how long it may be kept. Fourth, storage for generated images, video and audio, and for PyRIT memory, sized and access-controlled to match your data handling rules. Confirm retention and deletion requirements for generated media with your legal and privacy teams before the first run.
Can our own team run image and video model red teaming internally?
Yes, if your team has the Python skills to configure PyRIT targets, the security skills to design objectives and review harmful output, and the capacity to handle generated media safely. PyRIT's image, video and text-to-speech targets are documented in the PyRIT documentation, and the framework is open source under the MIT license. Internal teams often need time to learn the framework and to build a repeatable process for scoring and evidence. A partner is typically chosen for a fixed-scope first assessment, for team enablement, or to build the pipeline and handover documentation so that your staff can run later rounds. Decide which of these you need before you request a quote.
Does a PyRIT test report satisfy an auditor on its own?
No. PyRIT produces test results, memory records and scoring output, and those are useful evidence, but an auditor or certification body decides whether evidence meets a given framework or control. PyRIT results do not themselves constitute an audit report, attestation or certification. What you can ask for is evidence that is traceable: the test objectives, the target configuration, the scorer used, the run records, the reviewed outputs and a clear explanation of limitations. Confirm with your auditor which of these artifacts they expect before the test is designed, so the run records and reports are built to match.
Why do image and video targets matter for single-turn testing only?
Image, video and text-to-speech generation endpoints usually take one prompt and return one piece of media, without managing a conversation. PyRIT's OpenAIImageTarget, for example, is used for image generation and does not manage conversation history, so multi-turn strategies that depend on editing earlier replies do not apply in the same way. Ask your provider to confirm which attack types run against each endpoint in your environment, and to document any attack that is excluded and why, so that gaps are visible in the findings rather than discovered later.
What should we check in the generated media before scoring it?
Check that the output is attributable to the exact prompt, model version and parameters used, and that the file is stored with its metadata. Confirm that scoring covers the media type actually produced, since an image scorer does not evaluate a video or audio file. Review how the scorer handles failures, timeouts and blocked outputs, and record whether a refusal or a filter block counts as a pass. Finally, set access controls on generated files, because harmful output must not spread beyond the reviewers who need it.
How DeployOpen scopes and delivers PyRIT media red teaming
DeployOpen plans PyRIT media red teaming as a written, fixed-scope engagement that covers the image, video or speech endpoints you run, the prompts and scorers used, and the evidence you receive. The work runs in your own environment, so the generation endpoints, credentials and stored outputs stay under your control.
How we scope
- Inventory each image, video and text-to-speech endpoint in scope, with its provider, model version and access method.
- Agree the harm categories, prompt sets and generated-media types to test before any test run starts.
- Confirm where generated media is stored, who may review it, and how long outputs are retained.
How we build
- Configure PyRIT's OpenAI image, video or text-to-speech target against your endpoint using credentials from your secrets store.
- Set up scorers that judge generated images, video frames or audio against the agreed harm criteria.
- Run single-turn test batches with fixed settings, and record each prompt, output and score in PyRIT memory.
How we hand over
- Deliver a findings report that links each finding to its prompt, generated output, score and reproduction steps.
- Document the target configuration, scorer choices and run settings so your team can repeat the tests.
- Walk your security and AI teams through the results and agree remediation steps with owners and a retest.
How we support
- Retest fixed findings on the same endpoints and report what changed in the outputs and scores.
- Update prompt sets and scorers when your image, video or speech model versions change.
- Continuous testing and upgrades are available as a retainer, with the scope agreed in writing.

