Graphorin API reference v0.1.0
Graphorin API reference / @graphorin/provider / / AnthropicAPICounter
Class: AnthropicAPICounter
Defined in: packages/provider/src/counters/anthropic.ts:37
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.
Stable
Implements
Constructors
Constructor
ts
new AnthropicAPICounter(options): AnthropicAPICounter;Defined in: packages/provider/src/counters/anthropic.ts:46
Parameters
| Parameter | Type |
|---|---|
options | AnthropicAPICounterOptions |
Returns
AnthropicAPICounter
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
id | readonly | string | Human-readable identifier ('js-tiktoken@cl100k_base', …). | packages/provider/src/counters/anthropic.ts:38 |
version | readonly | string | Tokenizer version string used for cache invalidation. | packages/provider/src/counters/anthropic.ts:39 |
Methods
count()
ts
count(messages): Promise<number>;Defined in: packages/provider/src/counters/anthropic.ts:56
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:77
Count tokens in a raw text string.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<number>