Anthropic Integration
Evaluate Anthropic Claude model inputs and outputs against your governance policies.
Overview
The Anthropic integration lets you evaluate Claude model inputs and outputs against your governance policies using the Aguardic SDK. Your application calls Anthropic directly — Aguardic never touches your LLM traffic. Policy evaluation happens in your code before and after each LLM call.
Setup
1
Create integration
Navigate to Integrations in the Aguardic dashboard, click Add Integration, and select Anthropic. Give it a name and copy the API key.
2
Bind policies
Go to Policy Bindings and bind your governance policies to the Anthropic integration.
3
Install the SDK
npm install @aguardic/sdk4
Add evaluation calls
Use the SDK to evaluate inputs before sending them to Anthropic, and evaluate outputs after receiving them.
Store your Aguardic API key securely. It is shown only once. If you lose it, regenerate it from the integration settings.
Code Example
import Aguardic from "@aguardic/sdk";
import Anthropic from "@anthropic-ai/sdk";
const aguardic = new Aguardic(process.env.AGUARDIC_API_KEY);
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const messages = [
{ role: "user" as const, content: "Summarize our compliance requirements" },
];
// 1. Evaluate input before sending to Anthropic
const inputCheck = await aguardic.evaluate({
input: {
provider: "anthropic",
model: "claude-sonnet-4-20250514",
messages,
},
targetKey: "chat-completion",
});
if (inputCheck.enforcementAction === "BLOCK") {
console.log("Blocked:", inputCheck.violations);
} else {
// 2. Call Anthropic directly
const message = await anthropic.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: 1024,
messages,
});
const responseText =
message.content[0]?.type === "text" ? message.content[0].text : "";
// 3. Evaluate output
const outputCheck = await aguardic.evaluate({
input: {
provider: "anthropic",
model: "claude-sonnet-4-20250514",
response: responseText,
},
targetKey: "chat-completion-output",
});
if (outputCheck.enforcementAction === "BLOCK") {
console.log("Output blocked:", outputCheck.violations);
} else {
console.log(responseText);
}
}What Gets Evaluated
Input Evaluation
MessagesUser and assistant message content
System promptThe system instruction if provided
ModelThe model name for model-specific policies
Multimodal contentText parts from content arrays. Image presence is available as metadata.
Output Evaluation
Response textText blocks from the assistant response
Tool useAny tool_use blocks the model produced
Enforcement Actions
The enforcementAction field in the evaluation response tells you what to do:
BLOCKDo not send the request to Anthropic (input) or do not show the response to the user (output).
APPROVAL_REQUIREDHold the request until a reviewer approves it. Poll the
reviewRequestId for a decision.WARNAllow the request but log the violation for review.
ALLOWNo violations or policy allows continuation.
Why Sidecar Over Proxy
Unlike proxy-based approaches that route all LLM traffic through a third party, Aguardic's sidecar model means:
- No added latency — Evaluation runs in parallel, not in the request path
- No single point of failure — Your LLM calls go direct; if Aguardic is down, you decide the fallback
- Your keys stay with you — Aguardic never sees your Anthropic API key
- Full control — You choose exactly when and what to evaluate
Next Steps
- OpenAI Integration — Same pattern for GPT models
- Gemini Integration — Same pattern for Google AI
- JavaScript SDK — Full SDK reference
- Your First Policy — Create policies to evaluate against