Step 1: Setting API Key
Set up your Future AGI account and get started with Future AGI’s robust SDKs. Follow the QuickStart guide:Step 2: Installation and Setup
To begin using Protect initialize the Protect instance. This will handle the communication with the API and apply defined safety checks.FI_API_KEY and FI_SECRET_KEY from your environment variables if not explicitly provided.
Step 3: Define Protect Rules
TheProtect() method accepts several arguments and rules to configure your protection checks.
Arguments
| Argument | Type | Default Value | Description |
|---|---|---|---|
inputs | string or list[string] | — | Input to be evaluated. Can be text, image URL/path, audio URL/path, or data URI |
protect_rules | List[Dict] | — | List of safety rules to apply |
action | string | "Response cannot be generated as the input fails the checks" | Custom message shown when a rule fails |
reason | bool | False | Include detailed explanation of why content failed |
timeout | int | 30000 | Max time in milliseconds for evaluation |
Defining Rules
Rules are defined as a list of dictionaries. Each rule specifies which safety dimension to check.| Key | Required | Type | Values | Description |
|---|---|---|---|---|
metric | yes | string | content_moderation,bias_detection, security, data_privacy_compliance | Which safety dimension to check |
action | no | string | Any custom message | Override the default action message for this specific rule |
- Evaluation stops as soon as one rule fails (fail-fast behavior)
- Rules are processed in parallel batches for optimal performance
- All four safety dimensions work across text, image, and audio modalities
Understanding the Outputs
When a check is run, a response dictionary is returned with detailed results.| Key | Type | Description |
|---|---|---|
status | string | "passed" or "failed" - result of rule evaluation |
messages | string | Custom action message (if failed) or original input (if passed) |
completed_rules | list[string] | Rules that were successfully evaluated |
uncompleted_rules | list[string] | Rules skipped due to early failure or timeout |
failed_rule | list[string] | Which rule(s) caused the failure (empty if passed) |
reasons | list[string] | Explanation(s) of failure or ["All checks passed"] |
time_taken | float | Time taken in seconds |
Pass Example
Fail Example
Examples by Safety Dimension
Content Moderation
Bias Detection
Security
Data Privacy Compliance
Multiple Rules Example
Check multiple safety dimensions simultaneously:Multi-Modal Support in Protect
Protect natively supports text, image, and audio inputs without requiring any configuration changes. Simply pass your input as a string—whether it’s plain text, an image URL, an image file path, an audio URL, or an audio file path. Our system automatically detects the input type and processes it accordingly across all safety dimensions.Supported Input Formats
Text:- Plain text strings
- HTTP(S) URLs (e.g.,
https://example.com/image.jpg) - Local file paths (e.g.,
/path/to/image.png) - Data URIs (e.g.,
data:image/png;base64,...) - Supported formats: JPG, PNG, WebP, GIF, BMP, TIFF, SVG
- HTTP(S) URLs (e.g.,
https://example.com/audio.mp3) - Local file paths (e.g.,
/path/to/audio.wav) - Data URIs (e.g.,
data:audio/wav;base64,...) - Supported formats: MP3, WAV
Text Input Example
Image Input Example
Audio Input Example
Advanced Features
Custom Action Messages per Rule
You can specify different action messages for different rules:Processing Multiple Inputs
Process a list of inputs in sequence (evaluation stops at first failure):Using Environment Variables
Set your API credentials as environment variables for cleaner code:Important Notes
- Local files are automatically converted to data URIs (max 20MB by default)
- Preview URLs (e.g., GitHub blob pages, Google Drive viewers) are rejected—use direct download URLs
- All safety dimensions work across all modalities (text, image, audio)
- Rules are processed in parallel batches for optimal performance
- Evaluation uses fail-fast behavior: stops at first rule violation