Creates a new ClaudeAdapter instance.
Claude adapter configuration
ReadonlyproviderProvider identifier (e.g., 'anthropic', 'openai')
ReadonlymodelModel identifier (e.g., 'claude-sonnet-4', 'gpt-4o')
ReadonlycapabilitiesCapabilities this model supports
Protected ReadonlyloggerLogger for request/response logging
Protected ReadonlyconfigConfiguration for the adapter
Check if this adapter supports a specific capability.
The capability to check for
True if the capability is supported
ProtectedlogLog details about an outgoing request. Sanitizes sensitive information before logging.
The completion request to log
ProtectedlogLog details about a received response.
The completion response to log
ProtectedtransformTransform a provider-specific error into a standardized ModelError.
Maps common error patterns to appropriate error codes:
The original error from the provider
A standardized ModelError
Validates adapter configuration. Extends base validation with Claude-specific checks.
Send a completion request to Claude.
The completion request
Result with response or ModelError
Stream a completion request from Claude.
The completion request
Count tokens in text using Claude-specific estimation.
Claude uses a custom tokenizer. This provides a more accurate estimate than the base adapter's generic calculation.
Text to count tokens for
Approximate token count
(#2540) List models the Anthropic API currently exposes.
Wraps client.models.list(). Cached for 5 min, in-flight promise
shared across concurrent callers, throws on non-2xx so the
harness-side identity resolver knows to fall back.
Claude/Anthropic model adapter.
Provides a unified interface for interacting with Anthropic's Claude models. Supports completion, streaming, tool use, and vision capabilities.
Example