Skip to content

estimateTokens

function estimateTokens(text): number;

Defined in: core/src/context.ts:24

Four characters per token is the rule of thumb every provider’s own calculator agrees with to within a fifth, which is all the precision this needs. It decides WHEN to fold: folding one turn early costs a cheap model call, folding one turn late costs the whole turn.

Parameter Type
text string

number