Catalog PyPI
Back to packageRELEASE DETAILS

0.1.2

PyPI

aim-guardrails

Aim Security Guardrails for OpenAI Agents

Published13 Mar 2025
Direct dependencies4
Transitive dependenciesNot calculated

README

Version 0.1.2 documentation

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

  1. The input guardrail checks user messages before they're processed by the agent
  2. The output guardrail checks agent responses before they're returned to the user
  3. If restricted content is detected, a tripwire is triggered, raising an exception

Creating an Aim Security Guard

  1. Go to the Aim Application and create a new guard
  2. Configure your guard's policies in the prompt policy center
  3. Get your API key from the guard's page

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 4

Native requirements
4 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic>=2.0.0runtime
httpx
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx>=0.24.0runtime
openai
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
openai>=1.0.0runtime
openai-agents
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
openai-agents<0.0.4,>=0.0.3runtime

Distribution files

2 collected
aim_guardrails-0.1.2-py3-none-any.whl

bdist_wheel · 4.9 KB · Python py3

Source file
aim_guardrails-0.1.2.tar.gz

sdist · 3.65 KB · Python source

Source file

Repository

PENDING
yourusername/aim-guardrails

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:19 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:ca4428b129a82aefc880218a2de83facfc619b87f8de60c85c0fa69eeeea55b2

Other collected versions

View all collected versions →