Skip to content

AnthropicMessagesProvider

Defined in: providers/anthropic.ts:19

  • BaseProviderAdapter

new AnthropicMessagesProvider(client): AnthropicMessagesProvider

Defined in: providers/base-provider.ts:23

unknown

AnthropicMessagesProvider

BaseProviderAdapter.constructor

readonly providerId: "anthropic"

Defined in: providers/anthropic.ts:20

BaseProviderAdapter.providerId

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

LLMMessage[]

The messages to count tokens for

ModelDescriptor

Model descriptor containing the model name

ModelSpec

Optional model specification (currently unused)

Promise<number>

Promise resolving to the estimated input token count

Never throws - falls back to character-based estimation (4 chars/token) on error

const count = await provider.countTokens(
[{ role: "user", content: "Hello!" }],
{ provider: "anthropic", name: "claude-3-5-sonnet-20241022" }
);

generateImage(): Promise<never>

Defined in: providers/anthropic.ts:38

Promise<never>


generateSpeech(): Promise<never>

Defined in: providers/anthropic.ts:52

Promise<never>


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.

ModelSpec[]

BaseProviderAdapter.getModelSpecs


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.

LLMGenerationOptions

ModelDescriptor

ModelSpec

LLMStream

BaseProviderAdapter.stream


supports(descriptor): boolean

Defined in: providers/anthropic.ts:22

ModelDescriptor

boolean

BaseProviderAdapter.supports


supportsImageGeneration(_modelId): boolean

Defined in: providers/anthropic.ts:34

string

boolean


supportsSpeechGeneration(_modelId): boolean

Defined in: providers/anthropic.ts:48

string

boolean