Rate limiting PyRIT requests to protect targets

Set requests-per-minute limits on PyRIT targets so red team scans stay within provider quotas and do not degrade production endpoints.

On this page

Rate limiting PyRIT requests to protect targets: when your team needs it

Picture a team running PyRIT scans against a shared provider quota, or against a chat endpoint that real customers use during the day. Without a brake, an attack run sends requests as fast as the target and its concurrency settings allow, and the scan can exhaust the quota for every other workload on that account or slow production traffic to a crawl. PyRIT targets accept a max_requests_per_minute setting so you can keep a scan within an endpoint's rate limit and avoid the exceptions that follow when a provider starts refusing calls. The limit is enforced on the target side, so it protects the endpoint whichever attack, scenario or script is calling it.

The setting is independent of invocation recording. PyRIT's Prompt Targets documentation describes target-side rate limiting through limit_requests_per_minute, which is a separate control from whatever records each call in memory. Teams sometimes assume that logging calls also throttles them, or that a throttle on one target protects another. Neither is true. Each target that talks to a shared system needs its own limit, and you should confirm the exact parameter names against the PyRIT Prompt Targets documentation for the version you deploy.

Before you choose a number, find out what the provider actually allows for your deployment, which includes the quota shared by other applications, any per-deployment or per-key limits, and how much headroom your production traffic needs at peak. Ask the team that owns the endpoint for those figures in writing. The PyRIT Rate Limit (RPM) Threshold documentation explains the behavior this setting is meant to prevent, so review it with the platform owner before a scan runs against anything live.

Which rate limit option fits which target

This table compares the two PyRIT rate limit controls, max_requests_per_minute on the target and limit_requests_per_minute as a separate target-side control, along with how shared and per-target limits behave when several targets point at one provider. Read each row against the endpoint you are testing, since the right choice depends on whether the limit protects a provider quota, a production service, or both.

DecisionOptionWhen it fitsWhat it does not control
Protect a provider quotamax_requests_per_minute on the targetThe target is an endpoint with a published rate limit and you want PyRIT to stay under it and avoid rate-limit exceptionsLoad from other PyRIT targets or scripts that use the same key unless they share the same limit setting
Limit target-side invocationslimit_requests_per_minute (target-side control)You need a limit that applies to how often the target is invoked, separate from the rate limit setting, and you have confirmed its behavior in your versionQuota exhaustion caused by other clients on the same account or key
One key, several targetsShared limit across targetsSeveral targets or scenarios call one provider deployment, so their combined request rate must stay under one quotaIndependent targets that each set their own value can still exceed the combined quota if the values are added together
Separate endpoints or keysPer-target limitEach target points at a different deployment, region or key, so each quota is independentShared upstream capacity, such as a gateway or a common model backend behind several URLs
Production endpoint in scopeLower limit plus a dedicated test deploymentThe target serves real users, so scans must leave headroom for production traffic (illustrative: a scan limit set well below the sustained production rate)Latency spikes or errors that occur below the configured limit, which still need monitoring on the provider side
Confirm before relying on itDocumentation for your PyRIT versionCheck the Rate Limit (RPM) Threshold and Prompt Targets pages for the exact parameter names, defaults and how the two controls interactBehavior in versions other than the one you have installed

How to configure a requests-per-minute limit on a PyRIT target

This sequence sets a requests-per-minute ceiling on one PyRIT target, proves the ceiling holds in a small run, and tunes it against the endpoint's real limits before a full scan starts. The result is a documented, shared setting that keeps scans within provider quotas and away from production traffic.

  1. Confirm the endpoint's published rate limit

    Before touching PyRIT, ask the provider or the platform owner for the request ceiling that applies to the exact deployment you will test, including whether it is set per key, per deployment, per tenant or per region. Also ask what the endpoint does when the ceiling is exceeded and whether production traffic shares the same quota. Record the answers in your test plan. You are done when you have a written figure and an owner who confirmed it, and you know whether scan traffic and production traffic draw from one pool.

  2. Set max_requests_per_minute on the target

    In the target configuration, set max_requests_per_minute to a value at or below the confirmed ceiling, leaving headroom for other clients that share the quota. The PyRIT documentation describes this setting as the way to stay within an endpoint's rate limit and avoid exceptions. Keep the value in your shared configuration file rather than in code, and do not place API keys in that file; load keys from your secret store as described in the adjacent configuration and Key Vault topics. You are done when the target object reports the configured value at startup and the value appears in version control as a reviewed change.

  3. Verify throughput in a dry run

    Before sending real prompts, run a short test that sends a known number of requests through the target, for example by calling it in a loop with a timer, and compare the observed request count per minute with the configured value. Use a stub or a low-cost test deployment if you have one. Confirm that the target queues or waits rather than bursting when the limit is reached. You are done when the measured rate sits at or just under the configured figure and no requests are dropped silently. If the rate runs well above the configured value, stop and check that the setting was applied to the target you are actually calling.

  4. Run a small scan and watch for rate-limit errors

    Run a scan with a small objective set against the target and keep the logs and PyRIT memory open. Look for rate-limit responses from the endpoint, retries logged by the client, and any exceptions surfaced by PyRIT. Record the number of requests, the count of throttled responses and the time to completion. You are done when the run finishes without unhandled rate-limit exceptions and the throttling count is zero or explained. If throttling appears, note the timestamps so you can compare them with the provider's logs.

  5. Adjust the limit and re-run the same test

    If the small run produced throttling, lower max_requests_per_minute and repeat the same objective set so results are comparable. If it ran cleanly with plenty of spare capacity, raise the value in modest steps and repeat the dry run check each time. Change one setting at a time and record each value, the observed rate and the error count. You are done when the chosen value produces a clean run and the provider's usage view for the deployment matches what PyRIT reported.

  6. Check concurrency and retries against the limit

    Review how concurrency and retry settings in your scan interact with the requests-per-minute value. Several concurrent workers can each send requests that the target limiter must throttle, and automatic retries add extra requests that count toward the ceiling. Confirm with a short test that retry storms do not push traffic above the confirmed quota. You are done when a test with your planned concurrency and retry settings keeps the observed rate under the configured limit and the retry count stays low.

  7. Store the approved setting for the team

    Commit the approved limit, with the date, the confirmed provider figure and the name of the owner who confirmed it, to the shared configuration used by your team, and keep keys in your secret store. Document in the same place the test results from the earlier steps so the next person can see why the value was chosen. Ask the endpoint owner to notify you when quotas change. You are done when a teammate who loads the shared configuration gets the same limit without editing code or copying keys.

How rate limits interact with concurrency and retries

A per-minute cap does not by itself control how many requests are in flight at once, so concurrency and retry behavior can still push a target past the pace you intended. The max_requests_per_minute setting on a PyRIT target limits how often requests are admitted, but if several attack branches or workers call the same target at the same moment, their requests can still arrive together in a short burst. The per-minute figure is an average over a window, not a ceiling on simultaneous load. Before a scan starts, decide two numbers separately: the sustained request rate the endpoint's provider quota or production SLO allows, and the maximum number of parallel calls the target can absorb without queuing or timeouts.

Retries add load that the per-minute setting may not account for in the way you expect. When a request fails with a rate limit or transient error and is retried, the retry can land in the same window as new requests from other workers, so the target sees more traffic right after a failure than it did before. Reason about the combined effect by multiplying parallel workers by the number of attempts each request may make, then checking whether that worst case still fits within the endpoint's quota during a recovery period. Confirm in the PyRIT version you run how retries are counted against the limit, whether backoff is applied between attempts, and whether a retry that is rate limited is itself throttled, because these details differ between releases and between target types.

Treat the interaction as something to verify, not assume. Confirm the exact behavior against the PyRIT version in use by reading the documentation for that release and by running a controlled test against a staging endpoint that mirrors the production quota. Log request timestamps and count simultaneous in-flight calls during the test, then induce a failure to observe the retry pattern. Repeat the check whenever you upgrade PyRIT or change concurrency settings, and agree with the endpoint owner on the observed peak rate that the production scan must not exceed.

Protecting production endpoints during scans

A PyRIT scan sends real traffic to a real endpoint, and that traffic competes with users, other teams and provider quotas. The cards below are the operational controls that keep a scan from becoming an outage or a billing surprise, and each one maps to a setting or process the team can check before the first run.

Keep scan quota separate from users

A scan that uses the same deployment, key or quota as production traffic can exhaust the requests a live application needs. Give scans their own deployment or key where the provider allows it, and set max_requests_per_minute on the scan target so it stays under the share you have agreed. Ask the endpoint owner for the number they can spare, and confirm it against the provider's quota page for that deployment.

Rate limit docs

Stop sharing one key across teams

When several teams point PyRIT at the same key, one team's run looks like another team's outage, and nobody can tell who consumed the quota. Issue a separate credential per team or per environment, and record which key each scan config uses. Keep those keys in a secrets store rather than in shared .env files so rotation does not break every team at once.

Set the limit on the target object

Rate limits apply to the target instance that sends requests, so a limit placed on a scorer, converter or unrelated helper does nothing for the endpoint you are protecting. Check that the target object used by the attack carries the limit, and that any second target pointing at the same endpoint carries it too. Scorers that call a model are separate targets and need their own limit when they share quota.

Watch for 429 responses

A rate-limited endpoint returns throttling errors, and a scan that keeps retrying can turn a brief slowdown into a sustained one. Log throttling responses per run, alert the team when they climb, and stop the run rather than letting it retry indefinitely. Confirm how your provider reports throttling and which retry behavior the PyRIT target applies before you rely on it.

Run scans inside an agreed window

Even a well-limited scan adds load during peak hours, and a release or incident is a poor time to test a model. Agree with the endpoint owner which hours scans may run, write them into the scan schedule, and block runs outside that window in CI. Record the window in the team runbook so anyone who launches a scan knows the rule.

Record rate-limit settings for audit

An auditor or incident reviewer will ask what limit applied to a given run and who approved it. Store the requests-per-minute value, the concurrency setting, the key identity and the run window alongside each scan's results in PyRIT memory or your run log. Keep those records with the scan configuration in version control so a later change to a limit is visible.

Questions teams ask about PyRIT rate limiting

How much effort does it take to configure PyRIT rate limits?

For a single target, the change is small: you set a requests-per-minute value on the target so PyRIT stays within the endpoint's rate limit and avoids exceptions. The effort grows with the number of targets, how many scans share one provider quota, and how many CI runners or team members start scans against the same endpoints. The work is mostly in gathering the right numbers and agreeing who owns each limit, not in the code change itself. Ask any partner for a quote that lists each target, its quota source, and the test runs needed to confirm the limits hold.

Can our team set PyRIT rate limits without outside help?

Yes, if one engineer can read the provider's quota documentation, edit the target configuration, and run a small scan against a staging endpoint. The PyRIT documentation describes the max_requests_per_minute setting for targets and the limit_requests_per_minute option, and the target-side limiter works independently of invocation recording. Teams usually need outside help when several shared quotas, production endpoints, or concurrent CI jobs have to be balanced together, or when the team wants the limits written into a repeatable configuration. Check the current behavior against the documentation for your PyRIT version before you rely on it.

What drives the setup time for PyRIT rate limiting?

Four factors drive most of the time:

  • The number of targets, since each endpoint has its own quota and its own limit value
  • Shared quotas, where several scans, teams or services draw from one provider key
  • CI runners and scheduled jobs that can start scans without a person watching them
  • Concurrency and retries, because parallel attacks and retry behavior multiply the requests sent per minute

Each factor adds investigation and testing. Ask for a quote that names which of these apply to your environment.

What does the work need from our team?

It needs three things from your side. First, endpoint owners who can confirm which production services a scan may touch and who to contact if a limit is wrong. Second, quota data: the rate limits and tokens-per-minute values your provider or gateway enforces, and which keys or subscriptions they apply to. Third, a staging target that mirrors production closely enough to test limits without harming real users. Without a staging target, limits can only be checked against production, which raises risk. Confirm each of these before the work is scheduled.

How long does validation take for different scan sizes?

Validation time scales with scan size, the number of targets, and how many limit combinations you test. A small scan against one target is quick to check, while a large scheduled scan across several endpoints needs a longer run to confirm that the requests-per-minute values hold under concurrency and retries and that no endpoint returns rate-limit errors. The PyRIT documentation does not give a validation duration, so ask any partner to state the test plan, the scan sizes covered, and the expected duration in the written scope before work begins.

What recurring work follows after rate limits are set?

Limits need review whenever the conditions behind them change. Revisit them when a provider changes its quota, when you add a target or a shared key, when you change concurrency or retry settings, and after PyRIT upgrades that touch the targets you use. Someone also needs to watch scan logs for rate-limit exceptions and adjust values before they affect production. Ask whether a quote includes a periodic review, and whether it is a one-time setup or part of an ongoing support retainer.

Could rate limits in PyRIT affect production endpoints?

They can reduce the risk, but they do not remove it on their own. A requests-per-minute limit in PyRIT only controls requests sent from that PyRIT configuration, so other clients sharing the same endpoint or quota still consume capacity. Set limits with the endpoint owner, keep a staging target for trials, and confirm which production services a scan may reach. Treat limits as one control within a wider plan for protecting targets.

How a PyRIT scan request flows through the rate limit

The flow starts when a PyRIT attack generates a prompt and sends it to a target object. The target's rate limit check runs before the request leaves PyRIT, so a request over the configured max_requests_per_minute is held rather than sent. Requests that pass reach the provider endpoint, which is the production system or the quota boundary your team must stay within. If the provider still returns a rate-limit error, the retry path takes over, and this is where concurrency and retry settings can multiply the load you intended to cap.

Requests pass a target-side limit check before reaching the provider endpoint.

Rolling limits out across a team's scans

Once one target has a tested limit, the next step is making that limit the default for everyone who runs scans against the same endpoint. Keep the max_requests_per_minute value in the team's shared configuration rather than in individual scan scripts, so a tester who copies an old script cannot quietly reintroduce a higher rate. Store the settings file outside source control, since it can sit next to credentials and endpoint details, and let each team member's local copy be derived from the shared one. The file layout, loading order and secret handling are covered on the sibling pages on environment files, .pyrit_conf and Key Vault, so this section only concerns the limit values themselves and who owns them.

Record the agreed limit for each endpoint in a short register that names the target, the provider or owner, the quota or capacity figure the limit was based on, the date it was agreed and the person who approved it. Confirm the quota figure with the provider's current documentation or with the production owner, not from memory, because quotas differ by deployment, region and account tier. A register like this also answers the questions a CISO or platform owner will ask later about why a scan ran at a given pace against a production system.

Review every limit when something it depends on changes. Trigger a review when the scan scope grows to cover more attack strategies or more objectives per run, when the team adds a second scan that shares the same endpoint, when the provider changes the account's quota, or when production traffic to that endpoint rises. A review should check the agreed value against the new load and confirm with the production owner that the pace is still acceptable. Treat a limit that nobody has revisited for a long time as unverified, even if it has never caused an error.

How DeployOpen scopes and delivers PyRIT rate limiting

DeployOpen treats PyRIT rate limiting as part of the team's test setup, not as a one-line change. We agree the target inventory, provider quotas and production sensitivity in writing, then configure and verify the request limits against each endpoint the team is allowed to test.

How we scope

  • List every PyRIT target, its provider quota and whether it serves production traffic
  • Record which targets need a max_requests_per_minute limit and which need separate test keys
  • Agree in writing how concurrency and retry settings will be set alongside the limits
  • Confirm who owns each endpoint and who approves changes to its limits
  • Engagements are fixed-scope, with deliverables and timelines agreed before work starts

How we build

  • Configure per-target request limits in the team's PyRIT configuration, kept out of source control
  • Set concurrency and retry behavior so retries do not multiply the requests sent per minute
  • Run a controlled test against each target and check that limits hold without raising exceptions
  • Confirm that limits are applied to the target and not only to a single scan run
  • Test against a non-production endpoint first where the client has one available

How we hand over

  • Deliver a written configuration guide listing each target, its limit and the reason for it
  • Document how to change a limit, who approves the change and how to verify it afterwards
  • Provide a runbook for scans that hit quota errors or slow down a production endpoint
  • Walk the client's engineers through the configuration and the verification steps
  • Keep records of the verification runs so the team can show how limits were tested

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers
  • Review rate limit settings when PyRIT versions, provider quotas or endpoints change
  • Re-check limits after new targets or scan scenarios are added to the team's setup
  • Confirm with your provider the current quota for each deployment before setting a limit
  • Retainer scope and response expectations are agreed in writing before work starts

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.