Skip to content
1 min read · 90 words

Function: countAnthropicMessagesTokensWithResolvedOptions()

ts
function countAnthropicMessagesTokensWithResolvedOptions(
  resolved: AnthropicMessagesAdapterOptions,
  input:
    | AnthropicMessagesCountTokensRequestInput
    | AnthropicMessagesCountTokensInput,
  deps?: AnthropicMessagesCountTokensDeps,
): Promise<{
  inputTokens: number;
  raw: unknown;
}>;

Defined in: src/batteries/llm/anthropic_messages/count_tokens.ts:383

Counts tokens using already-resolved Anthropic adapter options.

Parameters

ParameterTypeDescription
resolvedAnthropicMessagesAdapterOptionsFully merged and validated adapter options.
input| AnthropicMessagesCountTokensRequestInput | AnthropicMessagesCountTokensInputEither a DispatchContext or a pre-built Anthropic-shaped input object.
deps?AnthropicMessagesCountTokensDepsOptional helper dependencies, including the structured log channel.

Returns

Promise<{ inputTokens: number; raw: unknown; }>

The named token-count field plus the raw SDK response.