Graphorin API reference v0.15.1
Graphorin API reference / @graphorin/provider / / AnthropicAPICounter
Class: AnthropicAPICounter
Defined in: packages/provider/src/counters/anthropic.ts:44
Stable
Counter that talks to POST /v1/messages/count_tokens when an API key is configured. Without an API key, the counter delegates to JsTiktokenCounter('cl100k_base') - the closest publicly-available proxy for Anthropic's tokenizer.
Implements
Constructors
Constructor
ts
new AnthropicAPICounter(options): AnthropicAPICounter;Defined in: packages/provider/src/counters/anthropic.ts:55
Parameters
| Parameter | Type |
|---|---|
options | AnthropicAPICounterOptions |
Returns
AnthropicAPICounter
Properties
Methods
count()
ts
count(messages): Promise<number>;Defined in: packages/provider/src/counters/anthropic.ts:66
Count tokens in a list of Messages (system/user/assistant/tool).
Parameters
| Parameter | Type |
|---|---|
messages | readonly Message[] |
Returns
Promise<number>
Implementation of
countText()
ts
countText(text): Promise<number>;Defined in: packages/provider/src/counters/anthropic.ts:97
Count tokens in a raw text string.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<number>