type
AnthropicMessageCreateParamsAnthropicMessageLikeAnthropicMessageStreamLikeAnthropicClientLikeAnthropicGuardConfig
Anthropic adapter for guard-sdk.
Version 0.5.0
Anthropic messages adapter for `guard-sdk`.
Peer dependencies
Anthropic messages adapter for guard-sdk.
Wraps an Anthropic client instance so that messages.create calls are automatically bounded by cost, token, call, and timeout limits. Stream finalization is also supported.
import Anthropic from "@anthropic-ai/sdk";
import { createAnthropicGuard } from "@guard-sdk/anthropic";
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const guarded = createAnthropicGuard(anthropic, {
name: "anthropic-message",
maxCostUsd: 1,
maxTokens: 5000,
timeoutMs: 30000,
});
const response = await guarded.messages.create({
model: "claude-opus-4-1-20250805",
messages: [{ role: "user", content: "Summarize this." }],
});
console.log(response.usage);
Requires @anthropic-ai/sdk >=0.61.0 <1 in your project.
Full declarations live in API Spec for @guard-sdk/anthropic.
AnthropicMessageCreateParamsAnthropicMessageLikeAnthropicMessageStreamLikeAnthropicClientLikeAnthropicGuardConfigcreateAnthropicGuard