tokenmeter-core
Count tokens and encode text with o200k_base. Special markers such as
<|endoftext|> are treated as ordinary text, matching tiktoken's
encode_ordinary. The vocabulary is embedded and initialized once on first
use. Threads share the immutable vocabulary. Repeated calls to prepare()
reuse the first initialization result.
use ;
count, encode and split accept up to 1,048,576 UTF-8 bytes (1 MiB).
They return Error::InputTooLarge for longer text, Error::Tokenization
when tokenization fails and Error::Internal when initialization fails.
split(text, limit) counts the entire input and returns up to limit
groups from its start. Each group ends at a token boundary that is also a
grapheme boundary. Its end is an exclusive UTF-8 byte offset in the original
string. Use the preceding group's end (or zero) as its start.