@authensor/connector-anthropic
v0.1.0
Published
Authensor safety connector for the Anthropic API — policy evaluation and content scanning on every call
Maintainers
Readme
@authensor/connector-anthropic
Safety connector for the Anthropic API. Wraps @anthropic-ai/sdk so every messages.create() call goes through Authensor policy evaluation and Aegis content scanning.
Quickstart
npm install @authensor/connector-anthropic @anthropic-ai/sdkimport { createSafeAnthropicClient } from '@authensor/connector-anthropic';
const client = await createSafeAnthropicClient({
apiKey: process.env.ANTHROPIC_API_KEY,
policy: {
id: 'my-policy',
name: 'My Policy',
version: '1.0.0',
rules: [
{ id: 'allow-all', effect: 'allow' },
],
},
});
const response = await client.messages.create({
model: 'claude-sonnet-4-5-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello' }],
});What it does
- Before each
messages.create()call, the request content is evaluated against your policy using the Authensor engine. - If the policy says deny, an
AuthensorDeniedErroris thrown. - If the policy says escalate (
require_approval), anAuthensorEscalationErroris thrown. - If the policy says allow, the request is forwarded to the Anthropic API.
- After receiving a response, Aegis scans the output for threats (PII, injection, credentials, exfiltration).
- If Aegis flags the response, an
AuthensorContentThreatErroris thrown.
Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | env var | Anthropic API key |
| policy | Policy \| string | required | Authensor policy object or YAML string |
| principalId | string | 'anthropic-connector' | ID for audit trail |
| aegisEnabled | boolean | true | Enable Aegis response scanning |
| onEvaluation | function | - | Callback after policy evaluation |
| onAegisThreat | function | - | Callback when Aegis flags content |
License
MIT
