Back to Documentation

Security Policies

Create and manage comprehensive security policies for your AI applications.

Create a Policy

const policy = await client.policies.create({
  name: "Production Policy",
  rules: {
    inputScanning: { enabled: true, mode: "strict" },
    outputFiltering: { enabled: true, categories: ["harmful"] },
    piiMasking: { enabled: true, types: ["all"] },
    rateLimiting: { requestsPerMinute: 100 },
    logging: { level: "detailed", retention: "30d" }
  }
});

Policy Components

Input Rules

Define how inputs are scanned and validated.

Output Rules

Configure output filtering and sanitization.

Access Controls

Set permissions and rate limits.

Audit & Logging

Configure logging and retention policies.

Apply Policy to Resources

// Apply to an agent
await client.agents.update(agentId, {
  policyId: policy.id
});

// Apply to API key
await client.apiKeys.update(keyId, {
  policyId: policy.id
});