Testing models through the OpenAI Responses API with PyRIT for newer deployments
A team that needs to red team a reasoning model or a newer OpenAI or Azure OpenAI deployment can send its objectives through the Responses API with PyRIT's OpenAIResponseTarget, and PyRIT records each exchange in memory as conversation pieces. This is a PyRIT target inside the Python framework, not a separate proxy or gateway, so the attack logic, converters, scorers and memory stay in the same process as the test. The supported method is the Responses API target in the PyRIT Python framework, which the team configures alongside the other targets it uses for objective, adversarial and scoring models.
Two fixes in PyRIT v1.0.1 matter for this work. The release fixed handling of structured refusals from OpenAI Responses and Chat Completions so they are recorded and scored as refusals, and OpenAIResponseTarget now orders reasoning pieces after the actionable response pieces. Before relying on results from an older build, the team should check the PyRIT v1.0.1 release notes and confirm that the version pinned in its environment includes both changes. Otherwise a refusal may be counted as a non-refusal, or a reasoning summary may be read as the model's answer.
DeployOpen works inside the client's own infrastructure, so the Azure OpenAI or OpenAI endpoint, credentials, and PyRIT memory store stay under the client's control. Before the first run, the team should confirm the exact Responses API support for each deployment it plans to test, the endpoint and authentication method, and where memory is stored, since those details differ by deployment and by how the team has set up its environment.
What a Responses API red teaming setup needs before PyRIT runs
A Responses API test run depends on five things being settled before the first attack: the PyRIT version, the Python runtime, a reachable endpoint, credentials and a memory store. Each card below is a decision or check that the team should make in advance, so that refusal and reasoning results can be trusted later.
Pin PyRIT at v1.0.1 or later
Structured refusals from OpenAI Responses and Chat Completions were fixed in PyRIT v1.0.1, so earlier releases can record a refused turn as an ordinary response. Install v1.0.1 or later and record the exact version in your test plan. v1.1.0 is the current release as of its publication, so check the release notes before choosing between the two.
v1.0.1 release notesMatch the Python runtime
The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Build the test environment on that version in a virtual environment, and pin it in the same place as the PyRIT version so that reruns behave the same way. Confirm the interpreter in your CI image before the first scheduled run.
Confirm which models the endpoint exposes
Not every Azure OpenAI or OpenAI deployment serves reasoning models through the Responses API, and access can differ between projects and regions. Ask the platform owner which deployments accept Responses API calls, and whether each one returns reasoning pieces. Record the deployment name and model version for each target so that results can be traced back to a specific configuration.
Confirm reachability from the test runner
The runner must reach the endpoint over the network path your security team has approved, whether that is a public endpoint, a private endpoint or a self-hosted gateway. Check outbound firewall rules, proxy settings and DNS from the same host that will run PyRIT. A test that fails on connection can look like a refusal in logs, so verify connectivity with a benign prompt first.
Store credentials in ~/.pyrit/.env
PyRIT reads credentials from ~/.pyrit/.env, which keeps API keys out of scripts and shell history. Give the test runner account only the access needed for the target deployment, and restrict file permissions on the runner. If your organization uses a secrets manager, confirm how values reach that file during CI runs before you rely on it for regular testing.
Choose the memory store
PyRIT memory stores conversations and results in SQLite or Azure SQL. SQLite suits a single analyst's local runs, while Azure SQL suits shared or audited testing. Decide before the first run because the store holds the request, the response and the reasoning pieces that you will later review. Confirm retention and access rules with your compliance team, since these records may contain sensitive test prompts.
How to configure the OpenAIResponseTarget step by step
This sequence takes a team from a clean Python environment to a stored benign test piece and a scored refusal probe, so each layer of the Responses API setup is confirmed before attacks run against it.
Install PyRIT in a pinned environment
Create a dedicated virtual environment on a supported Python version, then install PyRIT from PyPI with pip and pin the exact version your team will use for testing. The PyPI package supports Python 3.10 up to but not including 3.15, and the PyRIT documentation recommends Python 3.13, so select 3.13 where your environment allows it. Record the pinned version, because response handling changed in v1.0.1 and results should be traceable to a release. Check that the install completes and that importing the package in a Python shell raises no errors.
Set credentials and endpoint in the environment file
Add the Responses API endpoint, deployment or model name, and API key or Entra ID settings to ~/.pyrit/.env, using the variable names given in the PyRIT documentation for the OpenAI target. Keep this file out of version control and restrict its file permissions to the engineer running the tests. Confirm the endpoint with the owner of your Azure OpenAI or OpenAI project, including whether the deployment is a reasoning model, since that determines which Responses API behavior you will see. Verification: the file exists, contains no placeholder values, and the variables load without error when PyRIT starts.
Set run defaults in the configuration file
Create ~/.pyrit/.pyrit_conf to hold run-level settings such as the memory database location and default initializers, so every run starts from the same configuration. Choose SQLite for a single-engineer setup or Azure SQL where results must be shared, and confirm the choice with your records owner before the first run. Keep settings here and secrets in the environment file. Verification: a short test script reads the configured memory location and prints it, and that path matches what you expect.
Create the Responses API target for your deployment
In a Python script, instantiate the OpenAI Responses target that PyRIT provides for reasoning models and newer deployments, pointing it at the deployment you chose in the environment file. Do not reuse a chat completions target for these deployments, because structured refusals are handled by the Responses path. Confirm which model parameters your deployment accepts before setting them, since reasoning models often reject parameters that chat models allow. Verification: the target object constructs without error and reports the deployment name you intended.
Send one benign prompt and confirm memory
Send a harmless prompt such as a request for a short factual summary through the target, using the normal prompt path rather than a direct API call. Then query PyRIT memory for the conversation and confirm that a request piece and a response piece were stored with the expected conversation ID. Open the stored record and check that the response text is the answer you expect. Verification: the stored conversation is retrievable from memory after the script exits, which proves that later results will be traceable.
Run a refusal-probing objective and check the scored output
Run a small set of refusal-probing objectives drawn from an approved dataset, sending them through the same target and attaching the refusal scorer your team has chosen. Read the scored output for each objective and confirm that structured refusals are recorded and scored as refusals, which is the behavior fixed in v1.0.1. Also open the reasoning pieces for a sample and confirm they are stored after the actionable response pieces, so reviewers read the answer first. Verification: every probe has a score, refusal and non-refusal results match what you read in the stored text on a manual spot check, and any mismatch is logged for triage before you widen the test.
How structured refusals are recorded and scored in PyRIT
PyRIT v1.0.1 changed how a refusal is treated when the target returns it as structured data. Before that fix, a structured refusal from the OpenAI Responses or Chat Completions API could be recorded as ordinary text, so the scorer had to infer from the wording whether the model had declined. In v1.0.1, structured refusals from both APIs are recorded and scored as refusals. Confirm that your installed version is 1.0.1 or later (or a later release such as 1.1.0) before you read any results from a Responses API run, because older runs may classify the same exchange differently.
This matters for two numbers you will report. An attack success rate counts an objective as achieved when the scorer marks the response as harmful, so a refusal that is misread as a successful answer inflates the rate, and a refusal that is recorded correctly keeps it honest. The same error also distorts scorer reviews: if a refusal lands in the wrong category, a Likert or true/false judge may appear to disagree with the human reviewer when the scorer is actually correct about the content. Compare refusal counts in the memory store against the raw target responses before you publish a rate.
Before you trust a scorer on this target, run a known refusal case through the full setup. Use an objective the model is certain to decline, send it through the same OpenAIResponseTarget and scorer you plan to use in the attack, and check that the stored result is marked as a refusal and not as a completed answer. Repeat with one benign prompt to confirm that ordinary text is not mislabeled. Keep these two results as part of your test record, since an auditor will ask how you know the scorer handles structured refusals correctly. The release notes for v1.0.1 describe the change, and you should read them alongside your own test results.
How a Responses API attack flows through PyRIT to the model and back
The flow starts with an objective that PyRIT passes through any configured converters before it reaches OpenAIResponseTarget. The Responses API returns a mix of pieces: answer pieces, reasoning pieces and, when the model declines, structured refusals. Scorers read the answer and refusal pieces, and every piece is written to memory. Check that your memory store sits inside the boundary you have agreed for test data, and that the model endpoint is the one you intended to test.
Objective flow from PyRIT through the model endpoint and back into memory.
Reading answer pieces versus reasoning pieces
Answer pieces are the response pieces that carry the content a user would actually see in the product. They are the primary object of review, because a harmful or leaked answer in this part of the response is what a user receives. PyRIT's OpenAIResponseTarget now orders reasoning pieces after the actionable response pieces, so the answer is the first thing a reviewer or scorer encounters when reading a conversation in memory.
- Score them first: Configure scorers to evaluate the answer pieces as the main signal for whether an attack succeeded.
- Check the delivered text: Compare the answer piece against the harm category or objective that the attack was built around.
- Note partial answers: An answer that hedges but still supplies usable detail should be recorded as such, not as a clean refusal.
- Keep the conversation order: Read answer pieces in the turn sequence so that multi-turn escalation is visible.
- Record the piece type: Label findings with the piece type so later readers can tell which part of the response was assessed.
Before signing off on a result, confirm with the scorer configuration that answer pieces, not the full raw response, are the input your findings are based on.
Reasoning pieces are returned separately by reasoning models and describe the model's internal deliberation or summary of it. They are not the message a user receives, but they can reveal intent, partial plans, or information the model considered before answering. Whether that matters depends on your policy and on how the provider exposes reasoning content in the deployment you test.
- Treat them as a separate record: Store and label reasoning pieces so they are never merged into the answer assessment by default.
- Decide scope in policy: Your security or AI governance policy should state whether reasoning content can support a finding on its own.
- Flag leakage risk: If reasoning text repeats restricted content that the answer omits, record it as an observation with its own severity judgment.
- Avoid double counting: A harmful idea that appears in both pieces should be counted once against the answer, with the reasoning noted as supporting evidence.
- Confirm exposure: Check with the provider and your own deployment settings whether reasoning content is returned to end users or only to the API caller.
Confirm your organization's position on reasoning pieces in writing before the first test run, so the team does not decide scope after seeing results.
A consistent review workflow keeps the two piece types from being mixed up across testers and reruns. The steps below apply to any run that uses the Responses API target, whether the run is a single-turn check or a multi-turn attack. Each step should leave a record in memory that another reviewer can follow later, including for audit evidence.
- Filter by piece type: Use memory queries to separate answer pieces from reasoning pieces before scoring or reporting.
- Score the answer set: Run the chosen scorers on answer pieces and store the results with the attack identifier.
- Review reasoning separately: Read reasoning pieces only after the answer result is recorded, and note any differences.
- Escalate disagreements: When the answer scores as a refusal but the reasoning shows intent to comply, route the case to a second reviewer.
- Retest after fixes: Rerun the same objectives after any change to the model, filter or system prompt, and compare piece-level results.
Check with your reviewers that the query and export steps in your PyRIT setup preserve the piece type label, because a missing label will make later audit reading harder.
The report should show results by piece type, because a single combined verdict hides which part of the response carried the problem. Reviewers and auditors will ask which content was assessed, how it was scored, and what the team decided about reasoning content. Clear separation makes those questions easy to answer from the same records.
- Report answer findings as primary: Present answer-based results as the headline outcome for each objective.
- Show reasoning observations separately: List reasoning-only concerns in their own section with the policy basis for including them.
- Explain the scoring basis: State which scorer and which piece type produced each verdict, so a reader can reproduce it.
- Keep exports complete: Export the conversation with piece order and types intact for reviewers who need the raw sequence.
- Record policy decisions: Note the date and owner of the decision on reasoning scope, since that decision shapes future reports.
Before sharing results externally, confirm with your legal and compliance owners how reasoning content should be described, because wording requirements differ by organization.
Mapping Responses API fields to PyRIT pieces and scores
This table maps each Responses API output item type to the PyRIT piece it becomes, the scorer input it feeds, the memory fields a reviewer reads and the finding it supports. Use it to check that a refusal or reasoning item is recorded and scored the way your report claims. Confirm every field name against the PyRIT 1.1.0 documentation and your Azure OpenAI or OpenAI API version before you rely on it.
| Response item | PyRIT piece and scorer input | Memory and reviewer finding |
|---|---|---|
| Message text (output_text) | Assistant piece of data type text; the scorer reads it as the answer to judge | Stored as the assistant turn; a reviewer checks whether the harmful content appears in this turn, not in reasoning |
| Structured refusal | Recorded as a refusal, so the refusal scorer or an attack success check sees a refused turn rather than an empty or failed reply | Introduced as a fix in v1.0.1; a reviewer should confirm refused turns are counted as refusals in results and not as errors |
| Reasoning item | Separate reasoning piece; ordered after actionable response pieces in v1.0.1 so the answer is read first | Reviewers should not treat reasoning text as the delivered answer unless the finding concerns leaked chain-of-thought |
| Tool or function call item | Confirm with the PyRIT 1.1.0 documentation whether it becomes a separate piece or is dropped by the target | Record whether tool calls were part of the test scope, since an unrecorded call weakens an agent-level finding |
| Response status and error fields | Not a scorer input; determines whether the turn is retried or marked failed | Failed turns must be excluded from attack success rates and listed separately in the report |
| Conversation ID and previous response link | Used to continue multi-turn attacks against the same stored state | Confirm chaining behavior with your API version, since stored server-side state changes what a replay proves |
Security settings for testing reasoning models
Testing a reasoning model through the Responses API means PyRIT holds live credentials, sends sensitive prompts, and stores every output. The cards below cover how to keep those credentials out of code, who can read the memory store, what state the content filters were in for each run, and how to report a vulnerability in PyRIT itself.
Keep keys out of code
Put the API key for the OpenAI or Azure OpenAI endpoint in ~/.pyrit/.env or in a secrets manager, never in a notebook, script or committed configuration. Check whether the Azure target in your deployment supports Entra ID token authentication, since that removes long-lived keys from the test host entirely. Confirm the authentication options for your own deployment and tenant before you choose one, and record which method each test run used.
Entra ID where supported
When the Azure OpenAI or Foundry target accepts Entra ID, assign the test identity only the role needed to call the deployment. Keyless access ties each run to an identity your directory logs, which makes later review simpler. Confirm with your Azure administrator which roles the deployment accepts and whether conditional access applies to the test identity.
Restrict the memory database
PyRIT stores conversations, including every prompt and every response with its reasoning pieces, in SQLite or Azure SQL. Treat that file or database as sensitive data: restrict file permissions, keep it off shared drives, and decide retention before the first run. Reasoning content can reveal how the model handled a harmful request, so access to the store should match the sensitivity of the model under test.
Record the content filter state
A Responses API result only means something if you know the filters around the deployment. For each run, record whether content filters were on, which policy the deployment used, and the model version, alongside the PyRIT run identifier. Without this record, a refusal or a bypass cannot be tied to the configuration that produced it when an auditor or engineering lead asks later.
Report PyRIT vulnerabilities privately
If testing surfaces a suspected flaw in PyRIT itself, such as a scoring or credential-handling defect, do not open a public issue. Report it privately through the Microsoft Security Response Center under the project's security policy. Keep the reproduction limited to what the maintainers need, and avoid sharing live credentials or customer prompts in the report.
PyRIT repositoryCommon Responses API failures and how to fix them
This table pairs each common failure with its likely cause and the fix, covering refusal scoring, reasoning output, endpoint configuration, model exposure and memory writes. Read it by matching the symptom in your run output to the row, then confirming the fix in your own environment before rerunning the test.
| Symptom | Likely cause | Fix |
|---|---|---|
| Refusals counted as errors or failed attempts | The PyRIT version predates v1.0.1, which fixed how structured refusals from OpenAI Responses and Chat Completions are recorded and scored | Upgrade to PyRIT v1.0.1 or later, then rerun a small set to confirm refusals appear as refusals in memory |
| Reasoning pieces missing from review output | Reviewers are reading only the actionable response pieces, or an older build orders pieces differently from v1.0.1 onward | Check the piece order in exported conversations, read answer pieces first, and include reasoning pieces in review exports |
| Endpoint returns not-found or unsupported errors | The base endpoint path or API version does not match the Responses API route for your Azure OpenAI or Foundry deployment | Confirm the endpoint URL and API version against your resource's documentation, then correct the target configuration |
| Model rejects Responses API calls | The deployed model is not exposed through the Responses API in your region or resource, even though chat completions work | Confirm with your provider that the model supports the Responses API, or switch to the chat target for that deployment |
| Authentication errors on Azure targets | A key or token is missing, expired or scoped to a different resource than the endpoint | Confirm the credential source in your environment file and the identity's role on the target resource |
| Memory writes fail after a run | The memory database path is not writable, the SQLite file is locked, or Azure SQL connection settings are wrong | Check write permissions and connection settings, close other processes using the file, then rerun the failed conversations |
| Responses are empty or truncated | The output token limit is too low for reasoning models, which spend tokens on reasoning before the visible answer | Raise the output token limit in the target settings and confirm the model's documented limits |
Questions teams ask before testing Responses API models with PyRIT
What does it cost to test Responses API models with PyRIT?
Most of the cost is people time and model usage, not the PyRIT license, which is MIT. Cost moves with four drivers: access to the objective model and any adversarial or scoring models, the scorer you choose, how many attack runs and prompts you execute, and how much memory review a human must do afterward. Model calls are billed by your provider, so ask for a token and request estimate from your own test plan before the work starts. A written quote should itemize who is paid for setup, test design, runs, review and the report, and whether a retest is included.
How long before we see first results from a PyRIT run?
The first results depend on how quickly the endpoint, credentials and scorer are working, and then on the size of the first run. Setup is usually the longest step because the team must confirm the Responses API deployment, the API version, authentication and which reasoning settings the model accepts. A small smoke test against a few objectives will show whether refusals are recorded and scored correctly before a larger batch starts. Confirm the expected schedule with your provider and with the partner in the written scope, since no fixed timeline applies to every environment.
What must our team provide before testing starts?
Your team needs to provide a working Responses API endpoint for the model under test, plus the access method your security policy allows. Typical items include:
- Endpoint URL and deployment name for the target model
- An API key stored in a secrets manager, or Entra ID access for Azure OpenAI or Foundry
- Access to a scoring model, such as an LLM judge or Azure AI Content Safety, if you plan to use one
- A named review owner who will read the memory records and sign off on findings
- A test environment or agreed time window so production users are not affected
Credentials are read from ~/.pyrit/.env, so confirm where that file will live on the test host.
Can our internal team run Responses API testing with PyRIT alone?
Yes, a team with Python experience and access to the model can install PyRIT and run it, because the framework is open source and installs with pip. The harder work is interpreting results: deciding whether a refusal counts as a successful defense, checking that reasoning pieces are not mistaken for the answer the user sees, and documenting the evidence. Teams that lack an AI security reviewer often ask a partner to design the objectives, scorer thresholds and report. Confirm whether your staff have time for repeated runs and a second reviewer, since one person reviewing their own results is a common gap.
Which parts of the work drive the effort up most?
Effort rises with the number of models and deployments under test, the number of multi-turn attack strategies, and the number of scorers that must agree. Scorer choice matters because an LLM judge needs its own model access and calibration, while a rule-based check is cheaper to run but may miss subtle answers. Memory review is often the largest recurring task: each run stores conversations, and someone must read enough of them to confirm refusals were recorded as refusals and that reasoning pieces were not counted as the actionable response. Ask any quote to state the assumed number of runs and review hours.
What does a PyRIT engagement cover for Responses API targets?
A typical engagement covers the target configuration, the objectives and seed prompts, the scorers, the run plan, memory review and a written findings report. DeployOpen plans, implements, tests and documents work inside the client's own infrastructure, and engagements are usually fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. DeployOpen does not issue audit reports or certifications, so if you need evidence for an external review, confirm with your auditor what format they accept. Ask whether retesting after model or configuration changes is included, and whether ongoing testing is offered as a retainer.
What risks should we check before we point PyRIT at a production model?
The main risks are sending adversarial prompts to live users, storing sensitive test content in memory, and exhausting provider quotas or budgets. Confirm that the target is a non-production deployment or that the run is scheduled outside peak use. Treat the SQLite or Azure SQL memory as sensitive data: restrict who can read it, decide how long it is kept, and check whether prompts contain real personal data. Also confirm that PyRIT's vulnerability reporting path, through the Microsoft Security Response Center under the project's security policy, is known to your security team before anyone finds a defect in the tool itself.
How DeployOpen scopes and delivers PyRIT Responses API testing
DeployOpen runs this work inside your own infrastructure and starts with a written scope. Before any test runs, the scope names which Responses API deployments are in play, whether they are OpenAI or Azure OpenAI endpoints, which reasoning models and API versions are covered, and which harm categories and objectives the team wants measured. The scope also records who holds the keys, where the PyRIT host runs, and which scorer models are allowed to see test traffic. Deliverables and timelines are agreed in the same document, so the client knows what it receives before the first request is sent.
Delivery follows the agreed scope in a fixed order. DeployOpen configures the OpenAIResponseTarget, sets up credentials through ~/.pyrit/.env or your secret store, and sets the memory backend, SQLite or Azure SQL, so every request, structured refusal and reasoning piece is retained for review. The agreed tests are then run, and results are delivered as findings with proposed fixes and a retest after those fixes are applied. Ongoing testing against new model versions or changed content filters can be handled through a retainer.
DeployOpen prepares systems, controls and evidence for your compliance assessments, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations. Confirm with your assessor which PyRIT run records, memory exports and configuration files they expect to see, and agree on those artifacts in the scope so they are captured during testing rather than rebuilt afterward.

