Integrations¶
AegisAI provides integration connectors for popular AI frameworks and status endpoints to verify connectivity.
Integration Status Endpoints¶
Check whether framework integrations are configured and operational:
LangChain¶
Response:
OpenAI¶
Response:
LangChain Integration¶
Wrap LangChain agents with AegisAI policy checks and audit logging.
Architecture¶
flowchart LR
LC[LangChain Agent] --> CB[AegisAI Callback]
CB --> PC[Policy Check]
CB --> AL[Audit Log]
PC --> OPA[OPA Engine]
AL --> DB[(PostgreSQL)]
Usage Pattern¶
from aegisai.sdk import AegisAIClient
from langchain.agents import AgentExecutor
client = AegisAIClient(api_key="your-key", agent_name="langchain-agent")
await client.register()
# Before each tool call
decision = await client.check_policy(
action="tool_call",
resource=tool_name,
context={"input": tool_input},
)
if decision.allowed:
result = await tool.run(tool_input)
await client.log_action(
action="tool_call",
resource=tool_name,
input_data={"input": tool_input},
output_data={"result": result},
)
else:
raise PermissionError(decision.reason)
LangChain Callback Handler¶
Integrate at the callback level to automatically log all agent steps:
- Create a custom
BaseCallbackHandlerthat callsclient.log_action() - Attach the handler to your
AgentExecutor - Policy checks run before tool invocations
Phase 2 integration
The LangChain connector is part of Phase 2 integrations. Check /integrations/langchain/status to verify availability in your deployment.
OpenAI Integration¶
Monitor OpenAI API usage through AegisAI audit trails.
Usage Pattern¶
from aegisai.sdk import AegisAIClient
from openai import AsyncOpenAI
client = AegisAIClient(api_key="your-key", agent_name="openai-agent")
await client.register()
openai_client = AsyncOpenAI()
async with client.observe("completion", "gpt-4") as obs:
obs.set_input({"model": "gpt-4", "prompt_length": len(prompt)})
response = await openai_client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}],
)
obs.set_output({
"tokens": response.usage.total_tokens,
"finish_reason": response.choices[0].finish_reason,
})
Policy Controls for LLM Calls¶
Apply compliance policies to LLM operations:
decision = await client.check_policy(
action="llm_completion",
resource="gpt-4",
context={
"contains_pii": True,
"data_classification": "confidential",
"purpose": "customer_support",
},
)
GDPR and HIPAA templates evaluate PII/PHI context fields automatically.
Webhook Integration¶
For non-Python frameworks, use webhooks:
| Framework | Integration Method |
|---|---|
| Node.js / TypeScript | HTTP client + HMAC signing |
| Java / Spring | RestTemplate + HMAC signing |
| Go | net/http + crypto/hmac |
| Serverless (Lambda) | API Gateway + webhook endpoint |
Docker Compose Stack¶
All integrations run within the standard Docker Compose stack:
| Service | Port | Integration Role |
|---|---|---|
app |
8000 | API, SDK, webhooks, integration status |
opa |
8181 | Policy evaluation for all integrations |
postgres |
5432 | Audit log persistence |
redis |
6379 | Real-time event delivery |
Integration Comparison¶
| Method | Languages | Policy Check | Audit Log | Heartbeat | Complexity |
|---|---|---|---|---|---|
| Python SDK | Python | ✅ Built-in | ✅ Built-in | ✅ Built-in | Low |
| REST API | Any | ✅ Manual | ✅ Manual | ✅ Manual | Medium |
| Webhooks | Any | ❌ Separate call | ✅ Via event | ✅ Via event | Medium |
| LangChain | Python | ✅ Callback | ✅ Callback | ✅ SDK | Low |
| OpenAI | Python | ✅ SDK wrapper | ✅ Observer | ✅ SDK | Low |
Third-Party SIEM Export¶
Export audit logs for external security tools:
# JSON export for Splunk, Elastic, etc.
curl "http://localhost:8000/api/v1/audit/export/json?limit=10000" \
-H "X-API-Key: <key>" \
-o audit_for_siem.json
Configure your SIEM to ingest the JSONL format with fields: agent_id, action, resource, risk_score, signature, created_at.