run_red_teaming(), following the same example as docs/testing_guide/basic_red_teaming.py from the TrustTest repository.
This example uses
IcantAssistTarget, a dummy target that always refuses unsafe requests, so you can run the workflow end to end before switching to your own app. To test a real endpoint, replace it with an HttpTarget as shown in the Http Target tutorial.Configure the Environment
Add your NeuralTrust target token to your.env file:
Create the Target and Client
run_red_teaming() needs a target to attack and, optionally, a client to save generated scenarios, test sets, and evaluation runs.
Run the Catalog
The basic example runs the catalog in English and generates 50 test cases per scenario:evaluate=False, TrustTest builds the red-team scenarios and saves their test sets, but it does not execute the evaluator suites yet.
Tune the Run
You can adjust the basic script depending on what you need:- Change
languagesto generate scenarios in multiple languages. - Increase or decrease
num_test_casesto control how many attacks are generated per scenario. - Set
evaluate=Trueto immediately run the evaluator suites and persist the evaluation results. - Pass
multi_turn_enabled=Trueto include multi-turn prompt injection scenarios. - Use
category={...}to restrict the run to specific parts of the catalog, such as{"unsafe_outputs", "system_prompt_disclosure"}.