Click here to learn how to access your API key.
"FI_API_KEY"
and "FI_SECRET_KEY"
with your actual credentials before executing the code.
The Protect Client let’s you initialize protect.
Protect
accepts several arguments and rules to configure your protection checks.
Argument | Type | Default Value | Description |
---|---|---|---|
input | string | — | Input text to be evaluated. This may be simple text, an audio url or a local audio file path |
protect_rules | List[Dict] | — | Rules to apply on input |
action | string | Custom failure message | Message shown on failure |
reason | bool | False | Include failure reason in output |
timeout | int | 0.3 | Max time (in seconds) allowed for checks |
use_flash | bool | False | Uses flash protection, if True, the protect will be run in flash mode and ignore all the rules |
Key | Required | Type | Values | Description |
---|---|---|---|---|
metric | ✅ | string | Toxicity , Tone , Sexism , Prompt Injection , Data Privacy | Which metric to apply |
contains | Tone only | list[string] | "neutral" , "joy" , "love" , "fear" , "surprise" , "sadness" , "anger" , "annoyance" , "confusion" | Values to check for (e.g., ["anger", "sadness"] ) |
type | Tone only | string | any , all | Match if any or all values match |
Key | Type | Description |
---|---|---|
status | string (passed / failed ) | Result of rule evaluation |
messages | string | Final message or original input. |
completed_rules | list[string] | Successfully completed rules |
uncompleted_rules | list[string] | Rules skipped due to early failure or timeout |
failed_rule | string / None | Which rule caused failure |
reason | string | Explanation of failure |
time_taken | float | Time taken (seconds) |
protect
function
protect
function is a shortcut for the Protect
class. Please configure the FI_API_KEY
and FI_SECRET_KEY
environment variables before using the protect
function.