Skip to main content
Use this page when your application already calls the Anthropic JavaScript SDK. The wrapper keeps the Anthropic client shape and adds Averta checkpoints around messages.create(...).

Install

The Anthropic wrapper reads AVERTA_API_KEY from the environment. Pass avertaApiKey only when this client should use a different Averta key.

Wrap the Client

Send a Guarded Message

For this call, Averta runs a request checkpoint before Anthropic sees the message and an output checkpoint before your app receives the final text.

Add Tools

If Anthropic returns tool_use blocks, Averta has already checked those tool calls before your app receives them. When your app sends tool_result blocks back, Averta checks those results before Anthropic sees them.

Confirm Decisions

With an allowing policy and a tool call, Events should show a sequence like:
The exact sequence depends on whether the model calls a tool. A request with no tool call can skip tool_call and tool_result. The SDK generates requestId and traceId automatically; pass requestContext only when you need your own conversationId, requestId, or traceId.

Runnable Example

The SDK repository includes a complete Anthropic Messages tool-loop example:
Fill ANTHROPIC_API_KEY and AVERTA_API_KEY in examples/.env before running it.

Current Limit

Anthropic streaming is not supported yet. Streaming calls fail closed before provider execution. Use non-streaming messages.create(...) for guarded Anthropic flows today.

Next Steps

Messages API

Understand the guarded Anthropic surface.

Tools

Learn how tool exposure and tool-call checks work.

Tool results

Screen returned tool content before continuation calls.

Events

Investigate decisions in the dashboard.