@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:| Anthropic call | Status | Notes |
|---|---|---|
client.messages.create(...) | Supported | Non-streaming Messages calls. |
client.messages.create({ stream: true, ... }) | Not supported | Fails closed before Anthropic is called. |
client.messages.stream(...) | Not supported | Fails closed before Anthropic is called. |
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 supportedmessages.create(...) call, the wrapper runs these stages:
- Validate that the request uses a supported non-streaming Messages shape.
- Normalize the latest user message into an Averta request checkpoint payload.
- Evaluate request policy and filter tools when Averta returns
restrict_tools. - Check pending
tool_resultblocks when this call is a pure tool-result continuation. - Call Anthropic with the filtered request.
- Check returned
tool_useblocks before your app receives them. - Check final text output when the response does not contain more tool calls.
block, the wrapper throws AvertaSdkError.
Tool Loop Example
Anthropic tool use stays provider-native. Your app still owns tool execution and message history.messages.create(...) call is where Averta evaluates the returned tool content before Anthropic sees it.
What Gets Normalized
| Input | Averta behavior |
|---|---|
| Latest user text | Sent as the request checkpoint payload. |
| Latest user base64 image blocks | Sent as media on the request checkpoint. |
| Tool definitions | Sent for request-time exposure policy. |
Final user message containing only tool_result blocks | Sent through tool-result checkpoints before provider execution. |
Assistant tool_use blocks returned by Anthropic | Sent through tool-call checkpoints before your app receives them. |
| Final assistant text | Sent through output checkpoints when no tool calls remain. |
Rich Media
Request preflight supports Anthropicimage content blocks only when source.type is base64.
Supported MIME types:
image/jpegimage/pngimage/webp
Decision Events
UseonDecision when you need visibility into runtime behavior:
request, tool_call, tool_result, and output. The exact sequence depends on whether the model requests tools.