Skip to main content
Use @averta-security/sdk-anthropic when your app already uses the Anthropic JavaScript SDK and you want Averta decisions around the native Messages API lifecycle. The wrapper keeps the Anthropic client shape intact:

Guarded Surface

The current wrapper guards: wrapAnthropic(...) mutates and returns the client you pass in. Do not wrap the same client more than once. Create a fresh Anthropic client for each distinct Averta configuration.

Request Lifecycle

For each supported messages.create(...) call, the wrapper runs these stages:
  1. Validate that the request uses a supported non-streaming Messages shape.
  2. Normalize the latest user message into an Averta request checkpoint payload.
  3. Evaluate request policy and filter tools when Averta returns restrict_tools.
  4. Check pending tool_result blocks when this call is a pure tool-result continuation.
  5. Call Anthropic with the filtered request.
  6. Check returned tool_use blocks before your app receives them.
  7. Check final text output when the response does not contain more tool calls.
If a checkpoint returns block, the wrapper throws AvertaSdkError.

Tool Loop Example

Anthropic tool use stays provider-native. Your app still owns tool execution and message history.
The second messages.create(...) call is where Averta evaluates the returned tool content before Anthropic sees it.

What Gets Normalized

Rich Media

Request preflight supports Anthropic image content blocks only when source.type is base64. Supported MIME types:
  • image/jpeg
  • image/png
  • image/webp
URL image sources, GIF images, document blocks, and other non-text media fail closed before provider execution.

Decision Events

Use onDecision when you need visibility into runtime behavior:
Expected checkpoint names are request, tool_call, tool_result, and output. The exact sequence depends on whether the model requests tools.