PyRIT initializers and registries

PyRIT initializers register your targets, scorers and attack techniques under names so scenarios and the CLI can find them. This page explains how that works and what it takes to write one for your endpoints.

On this page

How PyRIT initializers and registries let scenarios find your endpoints

A team with several model endpoints to red team usually wants its scans to refer to each endpoint by a short name rather than repeating connection details in every run. PyRIT initializers answer that need: they register targets, scorers and techniques by name so that scenarios and the pyrit_scan command can find them. The registry is the lookup table that turns a name such as a staging chat endpoint into a configured target that an attack can call.

Built-in initializers cover the common cases, so the first decision is whether your endpoints fit them. If your targets are standard OpenAI, Azure, Anthropic, Google or Hugging Face models, or a scorer you can configure from the packaged options, the built-in registrations may be enough once credentials are in place. A team needs its own initializer when it has custom HTTP or WebSocket endpoints, a web app driven through Playwright, an internal gateway, or a scorer built on your own logic. Write the registration once so every engineer and every CI job uses the same names, targets and scorer settings, and keep the attack logic in your scenario code rather than in the initializer.

Before you write one, confirm three things in the PyRIT documentation 1.1.0: how the initializer interface expects registrations to be declared in your PyRIT version, how the CLI lists registered names, and how a scenario selects a target by name. Those details are version-specific, so do not copy examples from older posts or from the archived repository. Each registered name should map to one endpoint and one set of credentials, and the credentials should come from your .env or secret store rather than the initializer file. Test the registration by listing names from the CLI and by running a single low-volume objective against each one, then record which names your team has agreed to use so a renamed endpoint does not silently break a scheduled scan.

How an initializer connects configuration, registries and scenarios

The flow starts with settings in ~/.pyrit/.pyrit_conf and credentials in ~/.pyrit/.env, which the initializer reads together. The initializer then registers targets, scorers and techniques in PyRIT's registries under names. Scenarios and pyrit_scan look those names up rather than building objects themselves. Check the trust boundary: credentials should stay inside the operator's environment, and every registered endpoint should be one your organization has approved.

Configuration and credentials flow through an initializer into named registries that scenarios and pyrit_scan use.

Which registration approach fits your team

If your team only needs the targets PyRIT ships with, you register nothing of your own. The built-in target classes for providers such as OpenAI, Azure, Anthropic, Google and Hugging Face are already visible to scenarios and the CLI, so your work is limited to supplying credentials in ~/.pyrit/.env and settings in ~/.pyrit/.pyrit_conf. Your team maintains only those two files on each workstation.

  • What gets registered: the built-in targets, scorers and techniques that ship with the PyRIT version you have installed, not endpoints your organization owns.
  • Who maintains it: the PyRIT maintainers keep the built-ins current, while your team pins the version and reviews release notes before each upgrade.
  • What changes on rotation: a rotated provider key is updated in .env, with no code change and no change to scenario files.
  • Where the gap is: a built-in target does not know about your internal gateway or custom application, so anything behind those systems stays out of reach until you add an initializer.

Check that the built-in target you need exists in the version you pin, and confirm the upgrade notes before moving to a newer release.

Initializer options and when each fits

This table compares the registration points an initializer can populate: targets, scorers, techniques, and labels or settings. Read each row as a question: what does this register, and does my team need it before a scenario or the CLI can run? Confirm exact class names and config keys against the PyRIT 1.1.0 documentation before you write code.

Registration pointWhat it registersWhen it fitsTrade-off
Target registrationNamed target endpoints that attacks and scenarios send prompts to, such as an OpenAI-compatible model or a custom HTTP appYour team tests several endpoints and wants scenarios to refer to them by name instead of repeating connection detailsEvery target you register is a connection someone must keep current, and a stale endpoint name fails late in a run
Scorer registrationNamed scorers that judge whether a response is harmful or a refusal, including LLM judges and content safety scorersYour organization has agreed scoring criteria and wants every run to use the same judgeA shared scorer can hide disagreement about what counts as a failure, so record which judge model and version produced each result
Technique registrationNamed attack strategies, such as single-turn or multi-turn techniques, that scenarios can selectScenarios should run a fixed, reviewed set of attack techniques across teamsA fixed list limits ad hoc testing, so keep a documented path for adding techniques when the program matures
Labels and settingsMetadata such as operator, operation or environment labels, and default configuration values read from .pyrit_confYou need results traceable to a team, project or environment in memory and reportsLabels only help if people apply them consistently, so agree on naming before the first shared run
Built-in initializers onlyThe default set of targets, scorers and techniques shipped with PyRITA single operator is evaluating PyRIT or running a short proof of conceptLittle setup work, but endpoints that match your environment must still be configured separately
Custom organizational initializerYour own endpoints, scorers and techniques mapped to names your teams useSeveral teams share PyRIT against internal model gateways or custom appsHighest upfront design and ongoing ownership; confirm the initializer API and registration hooks in the 1.1.0 documentation

Writing and loading an initializer for your organization's endpoints

This sequence takes a team from a clean PyRIT install to a registered internal endpoint and scorer that scenarios and the CLI can find by name. Each step closes with a check, so the team knows the initializer loads before anyone runs a scenario against a production-adjacent system.

  1. Install PyRIT on a supported Python version

    Create a virtual environment on Python 3.13, which the PyRIT documentation recommends, or on any version from 3.10 up to but not including 3.15. Install the package from PyPI with pip, then confirm that PyRIT imports in that environment and that the pyrit_scan command is on the path. Record the Python and PyRIT versions in your team's setup notes, because initializer code depends on the package version you run. The step is complete when both checks pass from the environment your team will use for scenario runs.

  2. Create the initializer module

    Create a Python module in a directory your team controls, outside the PyRIT source tree, such as a small package that holds your organization's initializers. Import the initializer interfaces from the PyRIT documentation for the version you installed, and do not copy examples from older releases, because initializer interfaces have changed across releases. Keep the module in version control with the rest of your red teaming configuration. The check is that the module imports cleanly in the same environment and contains no endpoint keys.

  3. Register one endpoint target by name

    Inside the initializer, construct a target for one internal endpoint, such as a custom HTTP application or a self-hosted model, and register it under a stable name. Read the endpoint URL and credentials from environment variables or a Key Vault bootstrap document, not from literal strings in the module. Choose names that describe the system and environment, for example (illustrative) a test-only chat endpoint, so reviewers can tell targets apart in results. The check is a short script or debug listing that resolves the target object from its registered name.

  4. Register one scorer by name

    Add a scorer to the same initializer. Choose a scorer type that matches the harm you test, such as an LLM judge or custom logic, and confirm which scorer types your PyRIT version supports before you choose. If the scorer calls a model, register that model as its own target so its endpoint and credentials are handled the same way. The check is that the scorer resolves by name and returns a result for one sample response from your target.

  5. Reference the registered names in configuration

    Edit ~/.pyrit/.pyrit_conf to load your initializer module and to name the targets and scorers you registered. Keep credentials in ~/.pyrit/.env or your secret store so the configuration file holds no keys and can be committed to a team repository. Confirm the exact configuration keys for initializer loading in the 1.1.0 documentation before you edit the file. The check is that a new shell under the same user profile starts without errors that name your initializer or the registered names.

  6. Verify the names in the CLI listing

    Run the CLI listing command that shows registered targets, scorers and techniques, and confirm that your names appear alongside the built-in ones. Confirm the exact command for your version in the documentation first. Ask the platform owner to run the same listing on the shared runner, because a name that appears on one workstation but not in CI usually points to a path or configuration difference. The check is that each registered name appears once, spelled exactly as you wrote it. If a name is missing, the initializer did not load, so review the module path in the configuration.

  7. Run a dry scenario against registered names

    Start a scenario with pyrit_scan that uses your target and scorer by name, with a small objective set and the minimal run options your version offers (confirm the dry-run options in the documentation). Confirm that the run starts and resolves each name without errors, then review the stored conversation and its score in memory. Record the run identifier and the initializer version in your setup notes. The check is one conversation in memory linked to your target name, with a score from your scorer. Any later change to the initializer should repeat the listing check and this run.

Security considerations for shared initializers

A shared initializer decides which endpoints, models and scorers every tester on a team reaches, so it carries the same risks as any shared configuration code. The cards below cover where secrets live, how initializer code is reviewed, how names and memory are protected, and how changes are controlled over time.

Keep endpoint keys out of initializer source

An initializer should reference endpoint credentials by name, never hold the key itself. Keys written into Python source get committed, copied into tickets and left on shared workstations. Load them from the environment file or Key Vault set up in the sibling configuration and Key Vault topics, and check that no initializer in your repository contains a literal key, token or connection string before it is merged.

PyRIT on GitHub

Review initializer code before CI runs it

An initializer is executable Python that runs whenever a scan or CI job loads it, so a change to it is a change to code execution. Require a second reviewer for any edit that adds a network call, opens a socket, reads a file outside the project or installs a package. Pin the PyRIT version the pipeline uses so a reviewed initializer runs against the framework version it was tested with.

Name targets so they cannot be confused

Registries resolve targets, scorers and techniques by name, so two similar names can send a production-facing test to the wrong endpoint. Adopt a convention that encodes environment and owner, such as a prefix for staging or production, and reject duplicate names at load time. Illustrative example: a name like chat-prod should never point at a sandbox deployment, and a reviewer should be able to tell from the name alone which system a run will hit.

Restrict access to conversation memory

PyRIT memory stores the prompts sent to each target and the responses it returned, which can include sensitive test content and model output. Decide who can read the SQLite file or the Azure SQL database that backs it, and keep that access separate from the access that runs scans. Ask your team which group owns the memory store and how long its records are kept before you share it across the team.

Report vulnerabilities through the MSRC policy

If you find a flaw in PyRIT itself, such as one that exposes keys through an initializer path or leaks memory contents, report it privately rather than opening a public issue. The project directs vulnerability reports to the Microsoft Security Response Center under its security policy. Record that route in your team runbook so testers know where to send a finding before they discuss it in a shared channel.

PyRIT repository

Control changes when endpoints move

When a model deployment is renamed, rotated or retired, every initializer that points at it must change together, or scans will fail or quietly target the wrong system. Treat endpoint changes as tracked changes with an owner, a reviewer and a note in the initializer history. Confirm with each endpoint owner before a move, and rerun a short smoke test against the updated registry entry before the next scheduled scan.

Questions teams ask before writing their own initializer

How much effort does a first PyRIT initializer take?

The effort depends mostly on how many endpoints you need to register, how each one authenticates, and how far its request and response shapes differ from the standard chat format. A single OpenAI-compatible internal endpoint with a key is a small job. A set of custom HTTP endpoints with token refresh, non-standard payloads and separate scorer models is a larger one. No effort figure is supplied for this work, so ask any partner to break the estimate down per endpoint in a written scope, separating discovery, code, configuration, test runs and handover. Also ask whether the estimate includes reviewing the initializer after each PyRIT upgrade.

Can an internal developer write an initializer alone?

Often yes, if that developer already writes Python, understands the endpoints being registered, and can get test accounts for them. The harder parts are rarely the Python itself. They are agreeing on which targets, scorers and techniques should be registered under which names, handling credentials without hardcoding them, and proving that scenarios and the CLI find each entry. A single engineer can usually cover the core work, but a second reviewer is worth having for anything that touches shared credentials or production-adjacent endpoints.

What does the team need to provide for the work?

Plan to provide three things before the build starts:

  • Python skills in the team that will maintain the code, including comfort with packaging and configuration files
  • Written endpoint documentation: base URLs, authentication method, request and response formats, rate limits and owners
  • Test accounts or sandbox keys that can send traffic without touching production data or quotas

Without these, most delays come from discovery rather than coding. Ask any partner to confirm in writing which of these they expect you to supply.

Will a custom initializer keep working after PyRIT upgrades?

It can, but it is not guaranteed by the framework, so plan for a check after every upgrade. PyRIT has had breaking releases, and the upgrade path has changed how components are organized, so registration code that works today may need adjustment later. Keep the initializer in version control, pin the PyRIT version it was tested against, and run a small registry check after each upgrade. Confirm the exact changes for your target version in the PyRIT release notes before you upgrade.

What would a partner scope before writing an initializer?

A partner should scope the inventory of endpoints and their owners, the authentication design for each, the names and grouping used for targets, scorers and techniques, the secrets handling approach, the test plan that proves scenarios and the CLI can find every entry, and the handover material. The written scope should also state what is excluded, such as building new endpoints on your side, changing PyRIT itself, or running red team campaigns. Ask for deliverables and acceptance checks, not only hours.

What makes the effort grow after the first version?

Each added endpoint usually adds more than its coding time, because it brings its own credentials, owners, quotas and test cases. Changes in authentication, such as moving from static keys to Entra ID or a secrets vault, also reach every registered entry. Ask whether the scope covers adding endpoints later and whether ongoing support is a fixed-scope change or a retainer. DeployOpen offers ongoing support and upgrades as retainers, and its fixed-scope engagements are agreed in writing before work starts.

How do we know the initializer works before we rely on it?

Test it in three steps: confirm each target, scorer and technique loads without error, confirm scenarios and the CLI resolve each registered name, and run a low-volume request against each endpoint with a test account. Record the results and keep them with the initializer so a reviewer can repeat the checks after a change. Ask any partner to show how these checks are documented and who signs off on them.

Limits to confirm in your environment

Initializer and registry behavior depends on the PyRIT version, the Python runtime and the endpoint types your team needs to reach. Confirm each of these in a test environment before you write code that other people will depend on.

Pin the PyRIT version

Initializer and registry names can change between releases, so an initializer that works on one version may fail to load on another. Pick a version, record it in your project lockfile or requirements file, and test initializers against that exact version. The current release at the time of writing is v1.1.0, but confirm which version your team standardizes on and review the release notes before any upgrade. Pin the version before you register a single name.

PyRIT releases

Check the supported Python version

The PyPI package supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Your initializer runs inside that interpreter, so any typing features, dependency pins or internal packages you import must work on the version your runners and workstations use. Confirm the interpreter on shared CI runners and CoPyRIT hosts, not only on developer laptops.

Confirm built-in target coverage

Before writing a custom initializer, check whether PyRIT's built-in targets already cover your endpoint types, including OpenAI, Azure, Anthropic, Google, Hugging Face, custom HTTP or WebSocket endpoints and Playwright-driven web apps. Custom registration is only needed for gaps, such as an internal gateway with its own authentication scheme. Ask your platform team which endpoints are in scope so you do not duplicate a built-in target under a new name.

PyRIT documentation

Verify registry behavior across 1.0 and 1.1

Registry behavior has changed across the 1.0 architecture and the 1.1 release, so initializers written for one generation may register objects differently or be called at a different point in startup. Run your initializer through the CLI and a sample scenario on the version you pin, and confirm that every target, scorer and technique name resolves. If you carry older code forward, retest it rather than assuming the registry still behaves the same way.

Resolve duplicate names deliberately

When two initializers register the same name, a scenario may run against an unexpected target or scorer. Confirm how the registry resolves the conflict on your pinned version, whether it raises an error, keeps the first or last registration, or silently overwrites. Adopt a naming prefix per organization, such as an internal team identifier, so that collisions are visible in code review and not discovered during a live assessment.

Test name resolution in scenarios

Scenarios and the CLI look up registered names at run time, so a name that loads in a shell may still fail inside a scheduled job with a different working directory or environment file. Run a scenario that references each custom name from the same CI runner or host that will execute it in production. Record the outcome so that a missing registration is caught before a scan starts against a production endpoint.

What a scoped initializer engagement covers

A scoped initializer engagement starts with an inventory of the endpoints your team wants PyRIT to reach. For each one, the work records the endpoint type (for example, an OpenAI-compatible API, an Azure deployment, a custom HTTP or WebSocket app, or a local model server), the authentication method, the owner who can rotate its credentials, and whether it is meant for objective generation, adversarial chat or scoring. That inventory decides how many targets, scorers and techniques the initializer must register and under which names. Confirm with your platform team which endpoints are in scope now and which will follow, because each one adds a registration to test and document.

The next stage is initializer design and build. The deliverable is a Python initializer that registers your organization's targets, scorers and techniques by name so that scenarios and the pyrit_scan command can find them without hand-written setup in each run. Credentials are read from configuration and secret stores rather than written into the initializer, and the design should show which .pyrit_conf or environment settings the initializer depends on. Testing happens against non-production targets first. The engagement should include checks that each name resolves, that a failed endpoint produces a clear error, and that a test scan runs end to end. Ask for written test evidence as a deliverable, not only a statement that testing was done.

Documentation and handover close the engagement. Expect written material that explains each registered name, its target, the settings it needs and the owner to contact when it breaks, along with a short runbook for adding a new endpoint. Handover should walk your engineers through the code and a sample addition so the team can extend the initializer without the partner. The work is fixed-scope: scope, deliverables and the handover plan are agreed in writing before work starts, and the quote follows from that written scope. Ask any provider to state in writing which items are included, which are optional, and what happens if an endpoint changes after handover.

How DeployOpen scopes and supports PyRIT initializers

DeployOpen treats PyRIT initializers and registries as part of the team's configuration, not as a one-off script. We scope which targets, scorers and techniques your organization needs to find by name, build and test the initializer against your endpoints, and document how it runs so your team can maintain it. Engagements are fixed-scope and agreed in writing before work starts.

How we scope

  • Inventory the endpoints, models and internal services that scenarios and the CLI must reach by name
  • Agree which scorers and attack techniques each registry entry must expose to your testers
  • Record the environments, owners and configuration sources the written scope covers before any build starts

How we build

  • Write the initializer for your organization's endpoints, keeping names consistent across targets, scorers and techniques
  • Test registration with the PyRIT CLI and a sample scenario so lookups by name resolve as expected
  • Keep credentials out of the initializer by pointing it at your configured secret sources

How we hand over

  • Deliver the initializer code, registry naming conventions and a short guide to adding new endpoints
  • Document the configuration files, load order and the test steps your team uses to confirm registration
  • Walk your engineers through the handover and record open decisions for your owners to confirm

How we support

  • Review initializer changes when PyRIT releases change registration behavior or your endpoints change
  • Support upgrades to newer PyRIT versions through a planned retest of registrations and scenarios
  • Ongoing support and continuous testing are available as a retainer agreed in writing

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.