Anthropic
The Anthropic SDK is the production path for Claude. agentfootprint’s
anthropic()factory wraps it as anLLMProvider— same interface asmock(), so the rest of your agent code is identical between dev and prod.
Install
Section titled “Install”npm install @anthropic-ai/sdkThe SDK is a peer dependency declared in peerDependenciesMeta with optional: true — npm doesn’t auto-install it. Lazy-required at first call; friendly install hint if missing.
import { Agent, anthropic } from 'agentfootprint';
const provider = anthropic({ apiKey: process.env.ANTHROPIC_API_KEY!, // defaultModel: 'claude-sonnet-4-5-20250929', // optional, used when Agent doesn't override});
const agent = Agent.create({ provider, model: 'claude-sonnet-4-5-20250929',}).build();Model strings need date suffixes (claude-sonnet-4-5-20250929, claude-haiku-4-5-20251001) — Anthropic’s API requires the explicit version for stability.
Tools (native function calling)
Section titled “Tools (native function calling)”Anthropic’s Messages API has native tool_use blocks. The provider translates the agent’s Tool[] into the API’s tool format and round-trips assistant tool_calls via LLMMessage.toolCalls. ReAct correctness preserved across multi-iteration runs.
Streaming
Section titled “Streaming”provider.stream(req) uses the SDK’s native iterator; chunks land as they arrive. Final chunk carries the full LLMResponse (toolCalls + usage + stopReason) — single round-trip serves UI tokens AND ReAct decisioning.
Production patterns
Section titled “Production patterns”Wrap with resilience decorators for production:
import { withRetry, withFallback, anthropic, openai } from 'agentfootprint';
const provider = withRetry( withFallback( anthropic({ apiKey: process.env.ANTHROPIC_API_KEY! }), openai({ apiKey: process.env.OPENAI_API_KEY! }), ), { maxAttempts: 5 },);See Resilience guide.
Browser variant
Section titled “Browser variant”For browser environments where the Anthropic Node SDK doesn’t bundle cleanly, use BrowserAnthropicProvider — fetch-based, zero peer deps. Requires the anthropic-dangerous-direct-browser-access: true header (which the provider sets automatically). Production browser apps should proxy through a backend.
Limitations
Section titled “Limitations”- Multi-modal content (images, video) not supported —
LLMMessage.contentisstring. responseFormat(JSON-Schema-coerced output) not exposed yet — pass schema instructions viasystemPrompt.
Next steps
Section titled “Next steps”- Resilience — wrap with
withRetry/withFallback - Streaming — token-by-token UI rendering