AnthropicMessagesProvider
Defined in: providers/anthropic.ts:19
Extends
Section titled “Extends”BaseProviderAdapter
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AnthropicMessagesProvider(
client):AnthropicMessagesProvider
Defined in: providers/base-provider.ts:23
Parameters
Section titled “Parameters”client
Section titled “client”unknown
Returns
Section titled “Returns”AnthropicMessagesProvider
Inherited from
Section titled “Inherited from”BaseProviderAdapter.constructor
Properties
Section titled “Properties”providerId
Section titled “providerId”
readonlyproviderId:"anthropic"
Defined in: providers/anthropic.ts:20
Overrides
Section titled “Overrides”BaseProviderAdapter.providerId
Methods
Section titled “Methods”countTokens()
Section titled “countTokens()”countTokens(
messages,descriptor,_spec?):Promise<number>
Defined in: providers/anthropic.ts:282
Count tokens in messages using Anthropic’s native token counting API.
This method provides accurate token estimation for Anthropic models by:
- Using the native messages.countTokens() API
- Properly handling system messages and conversation structure
- Transforming messages to Anthropic’s expected format
Parameters
Section titled “Parameters”messages
Section titled “messages”The messages to count tokens for
descriptor
Section titled “descriptor”Model descriptor containing the model name
_spec?
Section titled “_spec?”Optional model specification (currently unused)
Returns
Section titled “Returns”Promise<number>
Promise resolving to the estimated input token count
Throws
Section titled “Throws”Never throws - falls back to character-based estimation (4 chars/token) on error
Example
Section titled “Example”const count = await provider.countTokens( [{ role: "user", content: "Hello!" }], { provider: "anthropic", name: "claude-3-5-sonnet-20241022" });generateImage()
Section titled “generateImage()”generateImage():
Promise<never>
Defined in: providers/anthropic.ts:38
Returns
Section titled “Returns”Promise<never>
generateSpeech()
Section titled “generateSpeech()”generateSpeech():
Promise<never>
Defined in: providers/anthropic.ts:52
Returns
Section titled “Returns”Promise<never>
getModelSpecs()
Section titled “getModelSpecs()”getModelSpecs():
ModelSpec[]
Defined in: providers/anthropic.ts:26
Optionally provide model specifications for this provider. This allows the model registry to discover available models and their capabilities.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”BaseProviderAdapter.getModelSpecs
stream()
Section titled “stream()”stream(
options,descriptor,spec?):LLMStream
Defined in: providers/base-provider.ts:37
Template method that defines the skeleton of the streaming algorithm. This orchestrates the four-step process without dictating provider-specific details.
Parameters
Section titled “Parameters”options
Section titled “options”descriptor
Section titled “descriptor”Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”BaseProviderAdapter.stream
supports()
Section titled “supports()”supports(
descriptor):boolean
Defined in: providers/anthropic.ts:22
Parameters
Section titled “Parameters”descriptor
Section titled “descriptor”Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”BaseProviderAdapter.supports
supportsImageGeneration()
Section titled “supportsImageGeneration()”supportsImageGeneration(
_modelId):boolean
Defined in: providers/anthropic.ts:34
Parameters
Section titled “Parameters”_modelId
Section titled “_modelId”string
Returns
Section titled “Returns”boolean
supportsSpeechGeneration()
Section titled “supportsSpeechGeneration()”supportsSpeechGeneration(
_modelId):boolean
Defined in: providers/anthropic.ts:48
Parameters
Section titled “Parameters”_modelId
Section titled “_modelId”string
Returns
Section titled “Returns”boolean