Docs Demo
Integration

SDK

If you write the agent yourself, wrap tool functions directly in code. The same policy engine, inspectors and audit log are used.

Wrap a tool

import { createAvertGate, AvertGateSecurityError } from "@avertgate/cli/sdk";

const gate = createAvertGate({
  policyPath: "./policy.yaml",
  agentId: "support-agent-v1",
});

const issueRefund = gate.wrapTool("issue_refund", async ({ orderId, amount }) => {
  return payments.refund(orderId, amount);
});

try {
  await issueRefund({ orderId: "ORD-100123", amount: 750 });
} catch (err) {
  if (err instanceof AvertGateSecurityError) {
    console.log(err.decision, err.reason, err.ruleId);
  }
}

Low level: guard()

const result = await gate.guard(
  "send_email",
  { to: recipient, body },
  () => mailer.send({ to, body }),
  { sessionId: "sess-42" },
);

Configuration options

OptionDescription
policy / policyPathFile path, raw YAML or an object.
agentId, orgIdIdentity and tenant.
auditDbPathSQLite path; :memory: for an ephemeral log.
apiKey, baseUrlCloud-managed policy: resolved through AvertGate.create().
requestApprovalApproval callback. Default: deny (fail-closed).
shadowModeObserve-only mode.
enableHotReloadHot-reload when the policy file changes.
tracer, metricsRegistryOpenTelemetry and Prometheus.

Framework adapters

wrapOpenAITool wraps an OpenAI tool definition and its executor together; wrapLangChainTool is for LangChain tools. Both support the catchErrors option.

Cloud-managed policy

const gate = await AvertGate.create({
  apiKey: process.env.AVERTGATE_API_KEY, // ag_live_...
  agentId: "support-agent-v1",
});

This form pulls the policy from the dashboard via /api/gateway/resolve and sends events to /api/events/ingest.