Red teaming realtime voice models with PyRIT

Learn how PyRIT's Realtime target sends audio or text to speech-to-speech models over WebSocket, and which multi-turn attacks cannot run without editable history.

On this page

How to red team a realtime voice model with PyRIT

A team deploying or reviewing a speech-to-speech or realtime model needs to test it the way users reach it, which means sending audio and text over the live session and checking what comes back. PyRIT's Realtime target does this: it sends text or audio prompts over an active WebSocket connection and receives audio output along with a transcript. The target sits in PyRIT's targets layer as a connector, the same layer that holds the OpenAI, Azure, Hugging Face and custom HTTP or WebSocket targets, so attack logic, converters and scorers are reused rather than rebuilt for voice. Confirm against the Realtime Target documentation which model endpoints and session settings the connector supports in your PyRIT version before you commit to a test plan.

The most important design fact is that the Realtime target has no editable conversation history. Its state lives in the open connection, so PyRIT cannot rewrite earlier turns, insert a fabricated assistant reply or replay a branch of the dialogue. Multi-turn strategies that depend on that control, such as Crescendo, will not run against this target. Plan the test around single-turn prompts, or around multi-turn exchanges that build up within one live session where the model itself carries the context. Decide early which objectives you need to cover, then map each one to a single-turn attack or to a conversational flow that does not require history editing.

Before running anything, the test owner should record the session details that affect results: the audio format and sample rate the endpoint expects, whether prompts are sent as recorded audio files or as text converted to speech, how the transcript is produced, and which voice or language the model replies in. Keep the audio inputs, transcripts and scorer outputs in PyRIT memory so a reviewer can trace each finding back to the exact prompt. Ask the model provider and your platform team who holds the endpoint credentials, where the WebSocket traffic is logged, and whether the session is permitted to carry the test audio before the first run.

What you need before a realtime voice test

A realtime voice test depends on five things being in place before the first prompt is sent: a supported PyRIT install, a reachable endpoint with working credentials, network access over WebSocket, a prompt set, and a memory store. Each card below names one of these and the check to make before you start.

Supported Python and PyRIT install

Install PyRIT with pip into an isolated environment. The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Confirm the interpreter version on the test runner before installing, and pin the PyRIT version you tested so results can be repeated. The install must be the release your team has reviewed, since the Realtime target's options can change between releases.

PyPI package

Realtime endpoint and credentials

Confirm the exact WebSocket endpoint URL, the model or deployment name, and the authentication method with your model provider before writing any configuration. Store keys in ~/.pyrit/.env rather than in scripts, and check that the key has only the permissions the test needs. Ask the provider whether the realtime session has usage limits or rate caps that will interrupt a long run.

Network path to the WebSocket

The Realtime target holds an open WebSocket connection for the length of each exchange, so the test runner needs outbound access that allows persistent connections. Check proxies, firewall rules and TLS inspection, since some inspection products break WebSocket upgrades. If the model runs inside your network, confirm the route from the runner to the endpoint and that the endpoint's certificate chain is trusted by the runner.

Audio and text prompt set

Prepare the objectives as audio files, text prompts, or both, and record which form each prompt takes. Audio prompts test how the model handles spoken input, including accents, background noise and spoken instructions that a text filter would never see. Keep a fixed prompt set under version control so that a rerun after a model or configuration change tests the same inputs.

Memory store for transcripts

PyRIT stores conversations and results in SQLite or Azure SQL. Choose the store before the first run, because results written to one database are not moved automatically to another. For a shared team test, use a store that the reviewers can reach and that your retention rules cover, since audio transcripts and model outputs may contain sensitive content. Confirm where the database file sits and who can read it.

Scope and settings confirmation

Before the run, agree in writing which harms, prompts and endpoints are in scope, and confirm the PyRIT settings in ~/.pyrit/.pyrit_conf on the runner. Check the Realtime target documentation for the current options and supported audio formats, because the target behavior may differ from what your team has used with text targets. Record the versions and settings so the results can be explained to reviewers later.

Realtime Target docs

Configuring the Realtime target step by step

This sequence takes a team from a clean PyRIT install to a working Realtime target that sends text and audio prompts, stores audio and transcripts in memory, and completes a first single-turn test. Each step ends with a check so you know it worked before moving on.

  1. Install PyRIT in a supported Python environment

    Create a dedicated virtual environment and install PyRIT from PyPI with pip. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so confirm your interpreter version before installing. Keep this environment separate from application code so that dependency changes during testing do not affect the system under test. You know this step is done when the package imports cleanly from Python and the installed version matches the release your team has approved.

  2. Store endpoint credentials in the PyRIT env file

    Create the file ~/.pyrit/.env and place the credentials the Realtime endpoint requires there, so keys stay out of notebooks and scripts. The security team or platform owner should supply the values through an approved channel, and the file should be readable only by the user running tests. Confirm the exact variable names with the documentation for your endpoint before writing them. You know this step is done when a short test script can read the expected variable without printing its value to logs.

  3. Set run settings in the PyRIT configuration file

    Create ~/.pyrit/.pyrit_conf to hold non-secret settings such as the memory database location and default targets, so every run uses the same configuration. Decide with your security team where memory is stored, because conversations and audio captured during testing will be written there. Keep the file under version control only if it contains no secrets. You know this step is done when PyRIT starts and reports the memory location you specified, with no configuration errors.

  4. Build the RealtimeTarget against the WebSocket endpoint

    Instantiate PyRIT's RealtimeTarget and point it at the WebSocket endpoint of the speech-to-speech model you are testing. Because the target needs an active connection, the endpoint must be reachable from the machine running PyRIT, and any network path or proxy rules should be confirmed with the platform team beforehand. Use the target only for the session in which it connects, and close it cleanly at the end of the run. You know this step is done when the target object is created and a connection opens without an authentication or handshake error.

  5. Send one text prompt and one audio prompt

    Send a harmless test text prompt first, then a short audio file of the same request, so you can see how the model answers each input type. The audio file should be a neutral recording in a format the endpoint accepts, and you should confirm that format with the endpoint documentation. Keep these first prompts benign, because the goal is to verify plumbing, not to test harmful content. You know this step is done when both prompts return a response without a protocol error.

  6. Confirm audio output and transcript are stored in memory

    Query PyRIT memory after the two test prompts to confirm that the audio output and its transcript were saved as responses in the conversation record. The transcript is what scorers will read, so check that it matches what the model said in the audio. If the transcript is missing or empty, do not proceed, because scoring would then have nothing to evaluate. You know this step is done when memory shows both turns, with audio attached and a readable transcript for each response.

  7. Run a single-turn test and review the result

    Run one single-turn attack with an approved objective and confirm the run produces a stored conversation and a scored result. Multi-turn strategies such as Crescendo will not work with this target because it has no editable conversation history, so keep the test to one exchange and plan multi-turn testing against a different target. Review the transcript alongside the score, since automated scoring can misclassify spoken content. You know this step is done when the run completes, the result is recorded in memory, and a reviewer has read the transcript.

Sending text or audio prompts and reading transcripts

PyRIT's Realtime target accepts two kinds of input: text prompts and audio prompts. Both are sent over an active WebSocket connection to the speech-to-speech or realtime model, and the target returns audio output along with a transcript of that audio. The transcript is the text you will score and the main evidence you keep, so the first decision is which input type each objective needs. Text prompts are the simplest route and suit objectives that are harmful in written form. Audio prompts matter when the risk depends on how something is spoken, such as a voice-only instruction or an attack that only succeeds when heard.

Audio files are not always the right choice for an objective set. Many public harm datasets are written as text, and converting them to speech adds a second variable: the text-to-speech voice, speaking rate, background noise and any audio converter you apply. Converter choices change whether the model actually hears the adversarial content as you intended. Before a run, play a sample of each converted file and confirm the words are intelligible. Then compare the transcript the model produced against the text you sent. If the transcript shows the model heard something different, the result reflects a misheard prompt, not a model decision, and should be recorded that way.

Scoring should run on the transcript, and you should keep the audio alongside it. Confirm with your scorer configuration whether it reads the transcript of the model's output, the transcript of your input, or both, and record which one was used. Store the raw audio, the transcript and the scorer verdict together in memory so a reviewer can replay the exchange. Ask your team to spot-check a sample of transcripts by hand, since speech recognition can mishear words that change the meaning of a harmful answer. Plan this review before the run so that the evidence supports any finding you report.

How a PyRIT attack reaches a realtime model

The attack starts in the PyRIT runner, where an objective is turned into a text or audio prompt by optional converters. The RealtimeTarget sends that prompt over an active WebSocket connection, and the voice model returns audio along with a transcript. Scorers judge the transcript, and memory records the exchange. The trust boundary sits at the WebSocket, so check what leaves the runner and what the endpoint stores.

Data path from a PyRIT attack to a realtime voice model across the test boundary.

Which PyRIT attacks run against a realtime target

This table compares attack families against a realtime target that has no editable conversation history. Read each row as a planning question: whether the attack can run at all, and what you must confirm in the current PyRIT documentation before relying on it.

Attack familyNeeds editable historyRuns against realtime targetWhat to confirm
Single-turn prompts (text or audio)NoYesConfirm the audio input format and transcript output your model returns in the Realtime Target documentation.
Converted text promptsNoYesConfirm which converters apply to the audio or text path your realtime session accepts.
Crescendo (multi-turn escalation)YesNoRelies on rewriting earlier turns, which the target cannot do because it needs an active WebSocket connection.
TAP (tree of attacks with pruning)YesNot applicableBranches over stored conversation state. Confirm in current documentation whether any branch can resume a live session.
Skeleton Key (multi-turn priming)YesNot applicableDepends on sending a priming turn and then follow-ups in one conversation. Confirm how the realtime session keeps context.
Attacks that restore or replay prior turnsYesNoReplay requires a stored history that the realtime target does not expose. Plan manual or single-turn alternatives.
Scoring of transcriptsNot applicableYesScorers work on the returned transcript. Confirm that audio output is transcribed before scoring.

Securing the test environment for voice data

Realtime voice tests produce audio recordings, transcripts and stored conversations that can contain sensitive speech or system details. The cards below cover where that data lives during a run, who can start tests against live endpoints, and how to report a defect in PyRIT itself.

Audio and transcripts in memory

Each realtime session returns audio output along with a transcript, and both can carry customer details or internal prompts. Decide up front which of these artifacts you keep, which you discard after scoring, and whether the source audio files you feed in are copies of recordings that already have their own retention rules. Confirm with your privacy team that test prompts built from production call samples are approved for this use, and remove them from working folders once the run is complete.

Memory inside the test boundary

PyRIT stores conversations and results in SQLite or Azure SQL, so every voice run leaves a database behind. Place that database on storage inside your test network or Azure subscription, not on a laptop or a shared drive. Confirm who can read it, how backups are handled and when it is deleted, because the stored transcripts are the same sensitive material as the live calls.

PyRIT documentation

Provider keys in the environment file

PyRIT reads credentials from ~/.pyrit/.env, and a realtime target usually needs a key or token for the voice provider. Restrict that file to the account that runs the tests, using owner-only read and write permissions, and keep it out of source control and container images. Rotate the key after any engineer leaves the test group, and ask whether Entra ID or a managed identity can replace a static key for Azure-hosted endpoints.

Who can test production voice endpoints

A voice attack against a live endpoint can trigger real calls, billing, and customer-facing responses, and it can flood monitoring with artificial sessions. Limit production runs to a named group, require a written change ticket that states the objectives and time window, and use a non-production deployment with the same model version wherever it exists. Confirm with the provider whether test traffic is distinguishable in its logs.

Reporting PyRIT vulnerabilities

If your testing exposes a flaw in PyRIT itself, such as a way its configuration or memory leaks credentials, report it privately rather than in a public issue. The project's security policy directs reports to the Microsoft Security Response Center. Check the current policy in the repository before a test cycle begins, and record who on your team is the contact for that channel.

PyRIT repository

Common failures when testing realtime voice targets

This table lists the failures teams most often hit when pointing PyRIT's Realtime target at a speech-to-speech model, with the likely cause and the fix or the item to confirm with the provider. Read each row as a checklist to work through before a test run, and treat the last row as the main design constraint for the attack plan.

FailureLikely causeFix or item to confirm
Dropped WebSocket connectionThe Realtime target needs an active WebSocket session, and the session can close on idle time, network interruption or provider-side limits.Confirm the provider's session lifetime and reconnect behavior, then run shorter test batches and log each session separately.
Missing or stale credentialsThe API key or token in the environment file has expired, was rotated, or points at a different deployment than the one under test.Confirm the key and endpoint pair for the exact realtime deployment, and check credential files in the PyRIT configuration before each run.
Unsupported audio format or sample rateThe audio prompt is encoded in a format or sample rate the model's realtime endpoint does not accept, so the session rejects input or returns no audio.Confirm the accepted codec, channel count and sample rate with the provider, then convert test audio files to that format before sending.
Transcript missing from responsesThe model returns audio without a transcript, or the transcript is disabled in the session configuration, so scorers have no text to evaluate.Confirm whether transcripts are returned for the chosen model and settings, and enable them in the session setup before scoring results.
Multi-turn attack fails with no historyThe Realtime target has no editable conversation history, so attacks that rebuild context each turn, such as Crescendo, cannot run against it.Choose single-turn attacks or a design that keeps the whole exchange inside one live session, and document this limit in the test scope.
Scores inconsistent across audio and text runsSpeech recognition errors or converted text changes the wording of the objective, so the same request is judged differently.Keep the text version of each objective alongside the audio file, and review a sample of transcripts by hand before trusting scorer results.

Questions teams ask before testing realtime voice models

How much effort does a first realtime voice red team test take?

The effort depends mostly on how much of the voice pipeline is in scope, not on PyRIT itself. A first test takes longer when the team must build audio test sets, agree on how spoken and transcribed output will be judged, and confirm how the realtime session behaves under the application's own protocol. The main drivers are the number of endpoints and languages, whether the speech-to-speech model is tested alone or inside a product with its own prompts and tools, how many audio attack variants are needed, and how much human listening review the team requires. Ask the provider for a written breakdown of those drivers and the test categories included, rather than a single figure.

Can an internal team run realtime voice testing on its own?

Yes, a team with Python experience and access to the target can run the Realtime target itself, because PyRIT is an open-source framework installed with pip. The harder part is the surrounding work: understanding WebSocket session handling, producing or sourcing audio prompts, interpreting transcripts and audio responses, and deciding which attacks make sense without conversation history. Teams without prior red teaming experience usually benefit from a partner for scoping and scoring design. Confirm with your engineers whether they have time for both the build and the review, since a first run often exposes setup issues that take several iterations to resolve.

What does the work need from our side before testing starts?

Testing needs a defined set of things from the client before any prompt is sent. The standard list includes:

  • Endpoint access for the realtime model, including the WebSocket address and the network path from the test host
  • Test credentials with limits set by your security team, stored outside source control
  • A scope agreement that names the models, application layers, languages, audio formats and attack classes in bounds
  • Named contacts for escalation if a test triggers a production alert or degrades service
  • Permission to store audio and transcripts in the PyRIT memory and a retention rule for them

Request these items in the written scope so the start date does not depend on informal approvals.

Which attacks cannot run against a realtime voice model?

Multi-turn attacks that depend on editing conversation history cannot run against the Realtime target. PyRIT's documentation states that RealtimeTarget needs an active WebSocket connection and therefore has no editable conversation history, so attacks such as Crescendo will not work with it. The reason is structural: a multi-turn attack rewrites or replays earlier turns to steer the next prompt, and a live session does not expose that history for editing. Single-turn prompts, audio or text variants of the same objective, and checks on the transcribed reply remain possible. Confirm the attack list against the current PyRIT documentation for your release before finalizing scope.

Should we test with audio files or with converted text?

Test both, because they answer different questions. The Realtime target sends text or audio prompts and receives audio output with a transcript, so audio input tests how the model handles speech, accents, background noise and spoken encodings that a text-only test would miss. Text prompts converted to speech give a cheaper, repeatable baseline and make results comparable across runs. A practical plan keeps a fixed set of source objectives, creates matching text and audio versions, and records which form produced each finding. Ask the provider how audio prompts will be generated and whether human reviewers will check the audio output directly, not only the transcript.

How should realtime voice results be recorded for review?

Record each attempt with enough detail that a reviewer can reproduce it and an auditor can follow it. Keep the prompt as sent, whether it was text or audio, the converter or audio source used, the session settings, the transcript of the reply, a reference to the stored audio output, the scorer result and the human review decision. PyRIT memory can store conversations and results in SQLite or Azure SQL, which gives a queryable record. Store audio under the same retention rule as transcripts, and note the PyRIT version and model version so later reruns can be compared. Ask the provider for the reporting format in writing before testing begins.

What risks should we plan for when testing a live voice endpoint?

Live voice endpoints carry operational and data risks that offline text tests do not. A test session can consume capacity or trigger rate limits, so agree on concurrency and timing with the service owner. Test audio may contain synthetic or real personal data, so limit what is captured and who can access it. Failed or hanging WebSocket sessions can leave partial state, so plan reconnection and cleanup. Ask for a written list of stop conditions, a named contact for each environment, and confirmation that testing targets a non-production or approved environment unless production testing is explicitly agreed.

What does a fixed-scope realtime voice engagement from DeployOpen cover?

DeployOpen runs security testing as fixed-scope engagements, with scope, deliverables and timelines agreed in writing before work starts. For realtime voice models, the written scope would normally name the endpoints, the attack classes, the audio and text test sets, the scoring approach, the evidence format and the retest arrangement, if any. DeployOpen does not publish a price list, so the quote follows from that written scope. Ask for the scope document to list which PyRIT attacks are excluded and why, so the boundary is visible to your security team before any test is run.

What a realtime voice test should prove

A realtime voice test should prove one specific claim about the deployed system, and that claim must be written down before the first prompt is sent. Define the harms in scope (for example, the model producing disallowed instructions when a request is spoken rather than typed, or disclosing system prompt content through audio), the prompts or audio files that exercise each harm, and the pass criteria that decide whether an attempt counts as a failure. Without those three items fixed in advance, a team can run many sessions, read the results generously and still have no finding it can defend. Record the owner of each harm, the dataset version and the target configuration alongside the plan, so a later rerun can be compared against the same baseline.

Evidence for a voice test has two layers that must be kept together. The audio that the target returned is the primary record, because speech output can carry tone, interruption and content that a transcript flattens. The transcript that PyRIT attaches to the response is the text the scorers read, so it is the record that explains why a result was scored as it was. Store the input audio or converted text, the returned audio, the transcript and the scorer output for each attempt, and confirm with your own environment that PyRIT's memory keeps these pieces linked. Note any transcription errors you find by listening to samples, since a wrong transcript can hide a failure from the scorer.

The voice results then enter the same workflow as every other PyRIT run. Scorers decide whether each attempt succeeded, memory holds the conversations, and reporting turns those records into findings with attack success rates and reproducible runs. Choose scorers that can read the transcript and that match the harm definition you wrote, and check their accuracy on a labeled sample before trusting the totals. Because a realtime session is a single live connection rather than an editable conversation, the team should decide in advance which single-turn prompts or spoken variants it will compare, and treat the results as the evidence for that defined scope, not for every voice interaction the product allows.

How DeployOpen scopes and delivers voice model red teaming

DeployOpen plans red teaming for realtime voice models as a fixed-scope engagement agreed in writing before work starts. The work covers PyRIT setup against your voice endpoint, the attack and scoring plan, test execution, findings and a retest of the fixes.

How we scope

  • Confirm which voice endpoints, audio formats and session types are in scope for PyRIT testing.
  • Agree which harms, objectives and prompt sources the audio and converted-text tests will cover.
  • Record which single-turn and workflow attacks apply, and which multi-turn attacks are excluded because no editable history exists.

How we build

  • Configure the PyRIT Realtime target against your WebSocket endpoint with credentials kept in local settings.
  • Prepare audio prompt files and text-to-speech conversion steps, then check transcripts return as expected.
  • Set up scorers for transcripts and audio output, and confirm memory storage captures each session for review.

How we hand over

  • Deliver a findings report listing each successful prompt, its transcript, audio output and affected control.
  • Document the test configuration, scope exclusions and the reasons multi-turn attacks were not run.
  • Provide the scripts, configuration files and memory records so your team can rerun the tests itself.

How we support

  • Retest the voice model after your fixes and report which findings are closed or still open.
  • Offer ongoing support, upgrades and continuous testing as a retainer after the initial engagement.
  • Ask for the PyRIT version, model version and endpoint details before each retest so results stay comparable.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.