PackageTrack
Sign in Get early access

tiktoken-rs

Library for encoding and decoding with the tiktoken library in Rust

0.12.0 15M downloads/mo #2524 most downloaded on crates.io zurawiki/tiktoken-rs

What this package is like to depend on

Last release 2 months ago

02 Jun 2026

Release timing varies

gaps range from 2 weeks to 7 months

Some releases are documented

notes for 9 of 35 stable releases

Nothing withdrawn

no release was ever pulled

4 years old

35 releases · first in 2023

5 releases in the last 12 months

see the full history below

Release timeline

35 releases · Feb 2023 to Jun 2026
2024 2025 2026
Release Pre-release

Releases

latest 35
  1. 0.12.0 02 Jun 2026
    Release notes

    Summary

    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.

    What Changed

    • Backported the vendored OpenAI tiktoken Rust core from 0.9.0 to 0.13.0.
    • Added the upstream large-piece BPE merge path. Functionally, this improves behavior for very large or repetitive inputs that previously stressed the merge algorithm.
    • Changed 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.
    • Updated encode_as and count to return Result because they call encode.
    • Re-exported EncodeError so callers can handle encode failures directly.
    • Aligned the vendored core with Rust 2024 and raised the crate MSRV to Rust 1.85.
    • Synced model-to-tokenizer mappings with upstream tiktoken 0.13.0 while keeping local extra prefixes isolated.
    • Hardened asset downloads with SHA-256 checks and a repo-root-aware asset path.

    Breaking Changes

    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.

    Practical Impact

    • Applications processing long repeated text should see more robust tokenization behavior.
    • Code that only uses helpers like get_chat_completion_max_tokens, get_text_completion_max_tokens, bpe_for_model, or singleton tokenizer constructors should not need call-site changes.
    • Code using low-level CoreBPE::encode, encode_as, or count needs a small migration to handle Result.

    Links

    Open source →
  2. 0.11.0 08 Apr 2026
    Release notes

    What's Changed

    Features

    • Add gpt-5.4 support, fix context sizes for o1-mini/chatgpt-4o/gpt-4.5 by @zurawiki in #156
    • Add generic token type APIs (FromRank trait) by @zurawiki in #157
    • Add gpt-5.2/5.3/codex model support by @zurawiki in #159
    • Return Option from get_context_size, improve error messages, bump to 0.11.0 by @zurawiki in #160

    Other Changes

    Full Changelog: v0.10.0...v0.11.0

    Open source →
  3. 0.10.0 08 Apr 2026
    Release notes

    What's Changed

    Features

    • Use singleton BPE in num_tokens_from_messages and get_completion_max_tokens by @zurawiki in #140
    • Count function_call tokens in num_tokens_from_messages by @zurawiki in #145
    • Change decode() to accept &[Rank] and make decode_bytes() public by @zurawiki in #146
    • Return &'static CoreBPE from get_bpe_from_model and get_bpe_from_tokenizer by @zurawiki in #147
    • Rename misleading API functions, deprecate old names by @zurawiki in #154
    • Add count-only token counting APIs by @zurawiki in #153

    Bug Fixes

    • Fix should-publish version check failing in CI by @zurawiki in #143
    • Fix gpt-3.5 model version check in num_tokens_from_messages by @zurawiki in #144

    Dependencies

    • chore(deps): update extractions/setup-just action to v3 by @renovate[bot] in #127
    • chore(deps): update actions/checkout action to v5 by @renovate[bot] in #126
    • chore(deps): pin swatinem/rust-cache action to 98c8021 by @renovate[bot] in #125
    • chore(deps): update actions/checkout v6, pin rust-toolchain, update create-gh-release v1.10.0 by @zurawiki in #142
    • chore(deps): update extractions/setup-just action to v4 by @renovate[bot] in #150
    • chore(deps): update swatinem/rust-cache action to v2.9.1 - autoclosed by @renovate[bot] in #149
    • Sync regex patterns with upstream tiktoken, bump deps, port tests by @zurawiki in #151
    • Bump async-openai to 0.34, add tool_calls/refusal token counting, update docs by @zurawiki in #152

    Other Changes

    Full Changelog: v0.9.1...v0.10.0

    Open source →
  4. 0.9.1 09 Nov 2025
    Release notes

    What's Changed

    • Support o-series models, gpt-5, and add o200k_harmony tokenizer for gpt-oss in #123

    Full Changelog: v0.7.0...v0.9.1

    Open source →
  5. 0.9.0 09 Nov 2025

    Nothing published for this version

  6. 0.7.0 19 May 2025
    Release notes

    What's Changed

    • Remove need for Arc<Mutex<>> on singletons by @benbrandt in #107
    • Update to latest tiktoken + new model support by @benbrandt in #106
    • Dependency and build/CI updates

    New Contributors

    Full Changelog: v0.6.0...v0.7.0

    Open source →
  7. 0.6.0 14 Oct 2024
    Release notes

    Minor version release signifies a breaking change in 0.x

    What's Changed

    • Add support for chatgpt-4o-latest by @Congyuwang in #85
    • Refactor internals to make future updates to tiktoken easier to merge
    • Do not expose tiktoken internal modules and functions
    • Update dependencies

    New Contributors

    Full Changelog: v0.5.9...v0.6.0

    Open source →
  8. 0.5.9 16 May 2024
    Release notes

    What's Changed

    New Contributors

    Full Changelog: v0.5.8...v0.5.9

    Open source →
  9. 0.5.8 22 Dec 2023
    Release notes

    What's Changed

    New Contributors

    Full Changelog: v0.5.7...v0.5.8

    Open source →
  10. 0.5.7 14 Nov 2023
    Release notes

    What's Changed

    New Contributors

    Full Changelog: v0.5.6...v0.5.7

    Open source →
  11. 0.5.6 21 Oct 2023

    Nothing published for this version

  12. 0.5.5 16 Oct 2023

    Nothing published for this version

  13. 0.5.4 18 Sep 2023

    Nothing published for this version

  14. 0.5.3 02 Sep 2023

    Nothing published for this version

  15. 0.5.2 02 Sep 2023

    Nothing published for this version

  16. 0.5.1 14 Aug 2023

    Nothing published for this version

  17. 0.5.0 27 Jun 2023

    Nothing published for this version

  18. 0.4.5 26 Jun 2023

    Nothing published for this version

  19. 0.4.4 20 Jun 2023

    Nothing published for this version

  20. 0.4.3 17 Jun 2023

    Nothing published for this version

  21. 0.4.2 24 Apr 2023

    Nothing published for this version

  22. 0.4.1 16 Apr 2023

    Nothing published for this version

  23. 0.4.0 05 Apr 2023

    Nothing published for this version

  24. 0.3.3 23 Mar 2023

    Nothing published for this version

  25. 0.3.2 18 Mar 2023

    Nothing published for this version

  26. 0.3.1 18 Mar 2023

    Nothing published for this version

  27. 0.3.0 18 Mar 2023

    Nothing published for this version

  28. 0.2.2 15 Mar 2023

    Nothing published for this version

  29. 0.2.1 07 Mar 2023

    Nothing published for this version

  30. 0.2.0 07 Mar 2023

    Nothing published for this version

  31. 0.1.4 03 Mar 2023

    Nothing published for this version

  32. 0.1.3 03 Mar 2023

    Nothing published for this version

  33. 0.1.2 02 Feb 2023

    Nothing published for this version

  34. 0.1.1 02 Feb 2023

    Nothing published for this version

  35. 0.1.0 02 Feb 2023

    Nothing published for this version

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive