NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #2182 most downloaded on crates.io
Library for encoding and decoding with the tiktoken library in Rust
Latest stable
0.12.1
Last release 1 months ago
24 Sep 2026
Ships fairly regularly
a new release about every 4 months
Nearly every release is documented
notes for 33 of 36 stable releases
Nothing withdrawn
no release was ever pulled
4 years old
36 releases · first in 2023
Drag across the ruler to compare, or tap a release to open it.
A maintenance release that refreshes upstream tiktoken and restores compatibility with the declared Rust 1.85 minimum. Existing public function signat
A maintenance release that refreshes upstream tiktoken and restores compatibility with the declared Rust 1.85 minimum. Existing public function signatures are unchanged.
gpt-6* names. This adds context metadata only; GPT-6 tokenizer lookup and token-budget helpers remain unsupported. (#174)lazy_static with the standard library's LazyLock. (#165)The minimum supported Rust version remains 1.85.
Thanks to @Expyron for their first contribution in #165.
Full changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.12.0...v0.12.1
Users who call lower-level CoreBPE encoding methods directly should review the breaking changes below.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release backports OpenAI tiktoken 0.13.0 into tiktoken-rs. The main reason to upgrade is better alignment with upstream tokenization behavior, especially the upstream Rust core changes for large BPE pieces and error-aware encoding.
For most users who call the high-level model/token counting helpers, this should behave the same aside from the new Rust compiler requirement. Users who call lower-level CoreBPE encoding methods directly should review the breaking changes below.
tiktoken Rust core from 0.9.0 to 0.13.0.CoreBPE::encode to return Result<(Vec<Rank>, usize), EncodeError>, matching upstream. Regex/tokenization failures can now be reported instead of being hidden behind infallible APIs.encode_as and count to return Result because they call encode.EncodeError so callers can handle encode failures directly.tiktoken 0.13.0 while keeping local extra prefixes isolated.If your code calls CoreBPE::encode, unwrap or propagate the result before using the tokens:
let allowed = bpe.special_tokens();
let (tokens, last_piece_token_len) = bpe.encode("hello <|endoftext|>", &allowed)?;
The generic helpers changed similarly:
let (tokens, last_piece_token_len) = bpe.encode_as::<usize>(text, &allowed)?;
let token_count = bpe.count(text, &allowed)?;
encode_ordinary, encode_ordinary_as, encode_with_special_tokens, and count_ordinary remain infallible.
Projects must now build with Rust 1.85 or newer.
get_chat_completion_max_tokens, get_text_completion_max_tokens, bpe_for_model, or singleton tokenizer constructors should not need call-site changes.CoreBPE::encode, encode_as, or count needs a small migration to handle Result.tiktoken 0.13.0: https://github.com/openai/tiktoken/releases/tag/0.13.0<!-- Release notes generated using configuration in .github/release.yml at v0.11.0 -->
<!-- Release notes generated using configuration in .github/release.yml at v0.11.0 -->
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.10.0...v0.11.0
Rename misleading API functions, deprecate old names by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/154
<!-- Release notes generated using configuration in .github/release.yml at v0.10.0 -->
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.9.1...v0.10.0
Support o-series models, gpt-5, and add o200k_harmony tokenizer for gpt-oss in https://github.com/zurawiki/tiktoken-rs/pull/123
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.7.0...v0.9.1
Nothing published for this version
Remove need for Arc > on singletons by @benbrandt in https://github.com/zurawiki/tiktoken-rs/pull/107
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.6.0...v0.7.0
Minor version release signifies a breaking change in 0.x
Minor version release signifies a breaking change in 0.x
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.9...v0.6.0
Add gpt-4-0125 and gpt-3.5-turbo-1106 context sizes by @mikaelsouza in https://github.com/zurawiki/tiktoken-rs/pull/59
gpt-4-0125 and gpt-3.5-turbo-1106 context sizes by @mikaelsouza in https://github.com/zurawiki/tiktoken-rs/pull/59gpt-3.5-turbo-0125 by @mikaelsouza in https://github.com/zurawiki/tiktoken-rs/pull/60Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.8...v0.5.9
Add tokenizer prefixes for fine-tuned models by @jbgriesner in https://github.com/zurawiki/tiktoken-rs/pull/53
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.7...v0.5.8
Add gpt-4-1106-preview model by @JosephTLyons in https://github.com/zurawiki/tiktoken-rs/pull/49
gpt-4-1106-preview model by @JosephTLyons in https://github.com/zurawiki/tiktoken-rs/pull/49Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.6...v0.5.7
Expose _decode_native methods by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/43
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.5...v0.5.6
return correct context length for text-embedding-ada-002 by @ursachec in https://github.com/zurawiki/tiktoken-rs/pull/41
text-embedding-ada-002 by @ursachec in https://github.com/zurawiki/tiktoken-rs/pull/41Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.4...v0.5.5
Restore minimum supported Rust version (MSRV) to 1.61.0.
Restore minimum supported Rust version (MSRV) to 1.61.0.
Update dependencies Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.1...v0.5.3
Update dependencies
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.1...v0.5.3
Nothing published for this version
Update tests by @kojix2 in https://github.com/zurawiki/tiktoken-rs/pull/28
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.5.0...v0.5.1
Added support for OpenAI function calling. See for more details.
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.5...v0.5.0
fix: unicode splitting and add unicode test cases by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/24
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.4...v0.4.5
Add README.md to package by @fiji-flo in https://github.com/zurawiki/tiktoken-rs/pull/22
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.3...v0.4.4
Support for gpt-3.5-turbo-16k models
Support for gpt-3.5-turbo-16k models
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.2...v0.4.3
Improved interface for split_by_token by @jackbackes in https://github.com/zurawiki/tiktoken-rs/pull/18
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.1...v0.4.2
Add ability to tokenize a string and return the decoded tokens using the correct BPE model by @thejohnbackes in https://github.com/zurawiki/tiktoken-r
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.4.0...v0.4.1
fix: expose num_tokens_from_messages and ensure its implementation is consistent with OpenAI by @j178 in https://github.com/zurawiki/tiktoken-rs/pull/
async-openai optional by @j178 in https://github.com/zurawiki/tiktoken-rs/pull/15Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.3...v0.4.0
chore(deps): update async-openai requirement from 0.9.5 to 0.10.0 by @dependabot in https://github.com/zurawiki/tiktoken-rs/pull/11
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.2...v0.3.3
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.1...v0.3.2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.1...v0.3.2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.0...v0.3.1
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.3.0...v0.3.1
feat: Add gpt-4 models mapping and tests. by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/9
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.2.2...v0.3.0
Do not build python bindings by default by @kelvich in https://github.com/zurawiki/tiktoken-rs/pull/6
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.2.1...v0.2.2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.2.0...v0.2.1
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.2.0...v0.2.1
BREAKING CHANGE: Moved core methods to the root namespace
get_encoder_for_model functionp50k_edit encoderFull Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.1.4...v0.2.0
Refactor tokenization and special tokens by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/3
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.1.3...v0.1.4
Implement cl100k tokenizer by @zurawiki in https://github.com/zurawiki/tiktoken-rs/pull/2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.1.2...v0.1.3
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.1.1...v0.1.2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/compare/v0.1.1...v0.1.2
Full Changelog: https://github.com/zurawiki/tiktoken-rs/commits/v0.1.1
Full Changelog: https://github.com/zurawiki/tiktoken-rs/commits/v0.1.1
Nothing published for this version
One column per quarter.