Description
The Anthropic LLM Provider is a direct, BYOK implementation of Dots' common LLMProvider contract. It supports buffered completion and token-streaming paths, system and user prompts, multi-turn messages, tool definitions and returned tool calls, stop sequences, sampling controls, deadlines, cancellation, usage reporting, and per-call model selection. The adapter defaults to the Haiku tier with a 200,000-token context window and a 4,096-token output ceiling.
Network behavior is kept behind a thin Anthropic HTTP module. The adapter validates its key, classifies authentication, throttling, schema, timeout, and availability failures into named error classes, and applies bounded retries without exposing prompts or credentials in errors. Cost estimates use the frozen Anthropic pricing table and the actual input/output token shape reported by results.
Selling Points
- One typed provider contract lets Chat, extraction, enrichment, and agent workflows call Anthropic without vendor-specific request code.
- Buffered and streaming modes share the same final result contract, so persistence does not depend on presentation style.
- Structured usage counters support honest cost records, including cache-read and cache-write token distinctions when reported.
- BYOK construction keeps key custody at the composition root and out of package environment access.
- Named errors let callers respond differently to invalid keys, rate limits, bad schemas, and temporary provider outages.
User Story
A hosted Chat composition resolves an Anthropic key, constructs the adapter, and sends a multi-turn request with allowed tools and a deadline. The UI renders streaming deltas while the terminal result supplies the final text, model, stop reason, and usage for persistence and metering. A rate limit arrives as a typed condition the dispatcher can surface or retry deliberately.
Extension Surface
Pluggable is the first true rung because packages/llm-providers/src/types.ts defines the formal LLMProvider interface and packages/llm-providers/src/anthropic.ts supplies one swappable implementation. packages/llm-providers/src/provider-registry.ts provides the parallel runtime registration point. Consumers depend on the contract rather than importing Anthropic HTTP directly.
Capabilities & Limits
- Completes or streams text with messages, tools, stop controls, cancellation, deadlines, and model override.
- Returns model, provider, stop reason, tool calls, and detailed token usage.
- Estimates cost from a frozen model table and maps network failures into stable error classes.
- Limits: Zero Retention is an Anthropic account-level commercial setting, not a request header; deployers must configure the account.
- Limits: the direct text adapter does not accept image blocks; image description uses the sibling vision capability.
Implementation Map
packages/llm-providers/src/anthropic.tspackages/llm-providers/src/anthropic-http.tspackages/llm-providers/src/types.tspackages/llm-providers/src/cost.tspackages/llm-providers/src/errors.ts