Aim Security Guardrails for OpenAI Agents
This package provides guardrails for OpenAI agents that integrate with the Aim Security API to detect and prevent harmful content, sensitive data leakage, prompt injections, and other security threats.
Installation
# install with pip
pip install aim-guardrails
# or install with poetry
poetry add aim-guardrails
Configuration
Set your Aim Security API key as an environment variable:
export AIM_API_KEY=<your-api-key>
Usage
You can use the helper functions to create guardrails with specific configurations:
from pydantic import BaseModel
from agents import Agent, Runner
from aim_guardrails import get_aim_input_guardrail, get_aim_output_guardrail
class MessageOutput(BaseModel):
response: str
# Create guardrails with custom configuration
input_guardrail = get_aim_input_guardrail(
api_key="your-custom-api-key", # Optional: defaults to AIM_API_KEY env var
api_base="https://your-custom-api-base.example.com", # Optional
user_email="user@example.com" # Optional: for tracking
)
output_guardrail = get_aim_output_guardrail(
api_key="your-custom-api-key", # Optional: defaults to AIM_API_KEY env var
api_base="https://your-custom-api-base.example.com", # Optional
user_email="user@example.com" # Optional: for tracking
)
# Create an agent with the configured guardrails
agent = Agent(
name="Customer support agent",
instructions="You are a customer support agent. You help customers with their questions.",
input_guardrails=[input_guardrail],
output_guardrails=[output_guardrail],
output_type=MessageOutput,
)
async def main():
try:
# This will be checked by the input guardrail
result = await Runner.run(agent, "Hello, can you help me with my question?")
print(f"Response: {result.final_output.response}")
except InputGuardrailTripwireTriggered as e:
print(f"Input guardrail triggered: {e}")
except OutputGuardrailTripwireTriggered as e:
print(f"Output guardrail triggered: {e}")
if __name__ == "__main__":
import asyncio
asyncio.run(main())
How It Works
- The input guardrail checks user messages before they're processed by the agent
- The output guardrail checks agent responses before they're returned to the user
- If restricted content is detected, a tripwire is triggered, raising an exception
Creating an Aim Security Guard
- Go to the Aim Application and create a new guard
- Configure your guard's policies in the prompt policy center
- Get your API key from the guard's page
Metadata
Release files for aim-guardrails 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aim_guardrails-0.1.2.tar.gz | 3.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aim_guardrails-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / aim_guardrails-0.1.2.tar.gz
| Download URL | aim_guardrails-0.1.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4e99327f04d93a3d0b7479f11923e2fd94dda3d7e11cfa5dbe8fd8c28c95bba
|
|
BLAKE2b-256 checksum How to use checksums |
d2aadd90be85016311cfc457fce10a09ef2a21bf13f88f11d376ffff29fa118d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.2 Darwin/24.3.0
|
Release files / aim_guardrails-0.1.2-py3-none-any.whl
| Download URL | aim_guardrails-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
875f4565649517c922ed2b11be76cf7dea612f4795de6ff79bb3a1702b150f9a
|
|
BLAKE2b-256 checksum How to use checksums |
6712003620ba53809b0fdc978f991170077576b63177619fd272a5287cdff881
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.2 Darwin/24.3.0
|
Security for aim-guardrails 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.