Get Started with Pangea AI Guard
Using Pangea with Portkey
1. Add Pangea Credentials to Portkey
- Navigate to the Pluginspage underSidebar
- Click on the edit button for the Pangea integration
- Add your Pangea token and domain information (refer to Pangea’s documentation for how to obtain these credentials)
2. Add Pangea’s Guardrail Check
- Navigate to the Guardrailspage and click theCreatebutton
- Search for Pangea’s AI Guard and click Add
- Configure your guardrail settings: recipe & debug (see Pangea’s API documentation for more details)
- Set any actions you want on your check, and create the Guardrail!
Guardrail Actions allow you to orchestrate your guardrails logic. You can learn them here
| Check Name | Description | Parameters | Supported Hooks | 
|---|---|---|---|
| AI Guard | Analyze and redact text to avoid manipulation of the model and malicious content | recipe (string), debug (boolean) | beforeRequestHook,afterRequestHook | 
3. Add Guardrail ID to a Config and Make Your Request
- When you save a Guardrail, you’ll get an associated Guardrail ID - add this ID to the input_guardrailsoroutput_guardrailsparams in your Portkey Config
- Create these Configs in Portkey UI, save them, and get an associated Config ID to attach to your requests. More here.
- NodeJS
- Python
- OpenAI NodeJS
- OpenAI Python
- cURL
Using Raw Guardrails with Pangea
You can define Pangea guardrails directly in your code for more programmatic control without using the Portkey UI. This “raw guardrails” approach lets you dynamically configure guardrails based on your application’s needs.We recommend that you create guardrails using the Portkey UI whenever possible. Raw guardrails are more complex and require you to manage credentials and configurations directly in your code.
Key Configuration Properties
Key Configuration Properties
Available Pangea Guardrails
| Guardrail Name | ID | Description | Parameters | 
|---|---|---|---|
| Pangea AI Guard | pangea.textGuard | Scans LLM inputs/outputs for malicious content, harmful patterns, etc. | recipe(string),debug(boolean) | 
| Pangea PII Guard | pangea.pii | Detects and optionally redacts personal identifiable information | redact(boolean) | 
Implementation Examples
Key Configuration Properties
Key Configuration Properties
- type: Always set to- "guardrail"for guardrail checks
- id: A unique identifier for your guardrail
- credentials: Authentication details for Pangea- api_key: Your Pangea API key
- domain: Your Pangea domain (e.g.,- aws.us-east-1.pangea.cloud)
 
- checks: Array of guardrail checks to run- id: The specific guardrail ID from the table above
- parameters: Configuration options specific to each guardrail
 
- deny: Whether to block the request if guardrail fails (true/false)
- async: Whether to run guardrail asynchronously (true/false)
- on_success/- on_fail: Optional callbacks for success/failure scenarios- feedback: Data for logging and analytics
- weight: Importance of this feedback (0-1)
- value: Feedback score (-10 to 10)
 
When using raw guardrails, you must provide valid credentials for the Pangea service directly in your config. Make sure to handle these credentials securely and consider using environment variables or secrets management.

