Current collected state Current
Observed since 20 Oct, 20:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python SDK for Aegis LLM Inference Firewall
Python SDK for Aegis LLM Inference Firewall.
pip install aegis-firewall
from aegis import AegisClient, AegisFirewall
# Create client
client = AegisClient(
base_url="http://localhost:8080",
api_key="your-api-key",
)
# Create firewall wrapper
firewall = AegisFirewall(client)
# Add user message
user_span = firewall.add_user_message("Send email to john@example.com")
# Execute tool call with taint tracking
result = firewall.safe_execute_tool_call(
"tool.send_email",
{"to": "john@example.com", "subject": "Hello"},
[user_span.id]
)
if result["success"]:
print("Tool call executed successfully")
else:
print(f"Tool call failed: {result['error']}")
import asyncio
from aegis import AegisAsyncClient, AegisAsyncFirewall
async def main():
async with AegisAsyncClient(
base_url="http://localhost:8080",
api_key="your-api-key",
) as client:
firewall = AegisAsyncFirewall(client)
# Add user message
user_span = await firewall.add_user_message("Send email")
# Execute tool call
result = await firewall.safe_execute_tool_call(
"tool.send_email",
{"to": "john@example.com"},
[user_span.id]
)
print(f"Success: {result['success']}")
asyncio.run(main())
client = AegisClient(
base_url="http://localhost:8080",
api_key="optional-api-key",
timeout=30.0,
retries=3,
)
validate_tool_call(tool_call) - Validate tool callcreate_span(span_data) - Create new spanget_span(span_id) - Get span by IDlist_decisions(session_id=None) - List decisionsget_approval(approval_id) - Get approvallist_approvals() - List pending approvalsapprove(approval_id) - Approve requestdeny(approval_id, reason) - Deny requestget_trace(session_id) - Get traceverify_trace(bundle_data) - Verify tracehealth() - Health checkfirewall = AegisFirewall(client)
add_user_message(content) - Add user messageadd_document(content, sensitivity=...) - Add RAG documentadd_system_prompt(content) - Add system promptexecute_tool_call(capability, args, source_span_ids) - Execute tool callsafe_execute_tool_call(...) - Safe execution with error handlingget_session_spans() - Get all spansclear_session() - Clear sessionfrom aegis import PolicyBuilder, TrustLevel
policy = (
PolicyBuilder()
.allow("tool.read_calendar", TrustLevel.UNTRUSTED_USER)
.allow("tool.send_email", TrustLevel.UNTRUSTED_USER, requires_approval=True)
.deny("payments.*", TrustLevel.UNTRUSTED_DOCUMENT)
.block_untrusted_documents()
.block_secret_data()
.require_approval_for_high_risk()
.auto_deny_after(30)
.build()
)
# Export as .aegis format
aegis_format = PolicyBuilder().allow("tool.send_email").to_aegis_format()
from aegis import AegisClient, AegisFirewall, SensitivityLevel
client = AegisClient(base_url="http://localhost:8080")
firewall = AegisFirewall(client)
# Add user query
user_span = firewall.add_user_message("What is our pricing?")
# Add retrieved documents (automatically marked as untrusted)
doc = firewall.add_document("Pricing: $99/month", SensitivityLevel.PUBLIC)
# Tool call sourced only from documents will be BLOCKED
result = firewall.safe_execute_tool_call(
"tool.send_email",
{"to": "attacker@evil.com"},
[doc.id] # Only document source - blocked by taint tracking!
)
assert not result["success"], "Should be blocked"
def handle_approval(approval_id: str):
print(f"Waiting for approval: {approval_id}")
# Notify admin, poll for status, etc.
result = firewall.safe_execute_tool_call(
"tool.execute_code",
{"code": "print('hello')"},
[user_span.id],
on_approval_required=handle_approval
)
import asyncio
from aegis import AegisAsyncClient, AegisAsyncFirewall
async def main():
async with AegisAsyncClient("http://localhost:8080") as client:
firewall = AegisAsyncFirewall(client)
user_span = await firewall.add_user_message("Hello")
result = await firewall.execute_tool_call(
"tool.search_web",
{"query": "weather"},
[user_span.id]
)
print(f"Allowed: {result.allowed}")
asyncio.run(main())
from aegis import (
CapabilityBlockedError,
ApprovalRequiredError,
NetworkError,
)
try:
result = client.validate_tool_call(tool_call)
except CapabilityBlockedError as e:
print(f"Blocked: {e.capability} - {e.reason}")
except ApprovalRequiredError as e:
print(f"Approval needed: {e.approval_id}")
await handle_approval(e.approval_id)
except NetworkError as e:
print(f"Network error: {e.status_code}")
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black aegis/
# Type check
mypy aegis/
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 2.0.0 | 25 Feb 2026 | 11 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 20:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:cc2a389d44a256be505edcbac03c5207beda8e22cdf1457497e502eb5c88f3e4