Skip to main content

Tokenfold Python SDK

Offline native request fitting. Python 3.12 or newer is required by the replacement SDK. Experimental Select uses a separately approved, explicitly configured runtime; base import and Core fitting never load models or download assets.

from tokenfold import fit

result = fit("Keep this text unchanged.", target_tokens=32)
text = result.require_met()

Advanced compression, decoding, retrieval and historical compression report readers are available under tokenfold.lowlevel. Fit receipts are a separate schema.

fit never sends a request. Text is opaque and unchanged; Data(value) renders compact JSON. Data(value, representation="folded") explicitly opts into the reversible Tokenfold codec: the consumer must understand that syntax (or decode with tokenfold.lowlevel.decode). Typed JSON normalizes safe integral floats and signed zero in Rust; default JSON preserves insertion order, while explicit folded JSON may normalize per-object key order. Opaque text is byte-preserved.

Provider Request.openai(...) / Request.anthropic(...) payloads are full request objects, not bare message lists. The default encoding counter cannot establish provider framing and returns unavailable. Supply a complete-request counter, or explicitly choose the historical ProviderCounter.openai(model="gpt-4o-2024-08-06") local estimate. Estimates never become met: strict require_met() rejects them; per-fit budget_mode="best_effort" permits require_fit() only when the finite estimate fits. This offline recipe is not proof of billing or model availability.

A client owns independent fitting sessions and supports with, async with and await client.afit(...). Custom counters are synchronous and must support concurrent, deterministic calls; async fitting runs them off-loop. Blocking application callbacks cannot be forcibly preempted, so no bounded whole-call/close deadline is promised across them. Cancellation waits for native inference cleanup before raising.

Selection is experimental and unqualified. It requires both an approved runtime (SelectRuntime(config_path, experimental=True)) configured on Tokenfold and allow_selection=True on that individual fit. Group annotations alone are not consent. Required groups and the query are retained; callers must bundle semantic dependencies themselves. warmup() only loads that configured runtime; import and already-fitting Core requests never start it. Provisioning the optional runtime and acquiring its pinned local model are separate explicit setup actions.

Install with pip install tokenfold==0.6.0. The exact tokenfold[select] extra adds only tokenfold-select-runtime==0.6.0, not ML packages. Prebuilt targets: Linux GNU x64/arm64, macOS x64/arm64, Windows x64, gated by installed artifact CI before release. See the migration guide for provisioning, grouping recipes and queue/cold-start limits. The pinned tokenizer may refuse long valid inputs with AccountingError (and its own panic diagnostic); there is no heuristic/zero fallback.

Metadata

Release files for tokenfold 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tokenfold 0.6.0
File Size Uploaded Provenance Actions
tokenfold-0.6.0.tar.gz 305.9 kB Without provenance Details for tokenfold-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tokenfold 0.6.0
File Actions
tokenfold-0.6.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for tokenfold-0.6.0-cp312-abi3-win_amd64.whl
tokenfold-0.6.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for tokenfold-0.6.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
tokenfold-0.6.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for tokenfold-0.6.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
tokenfold-0.6.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for tokenfold-0.6.0-cp312-abi3-macosx_11_0_arm64.whl
tokenfold-0.6.0-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for tokenfold-0.6.0-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 23.0 MB

Release files / tokenfold-0.6.0.tar.gz

Download URL tokenfold-0.6.0.tar.gz
Size 305.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2f0a2a512db748ea7059777dc1da531f4e632cb4986f82442d3ce4bd6cd253de
BLAKE2b-256 checksum
How to use checksums
151f58203897d3962886bd0f630f63f2e6dc7b35f78e243d7e9115dba5fc411b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tokenfold-0.6.0-cp312-abi3-win_amd64.whl

Download URL tokenfold-0.6.0-cp312-abi3-win_amd64.whl
Size 4.3 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1d78b9f7c3969cc59ae85d1aafb30c34cb0b162473f08f5cccca871d08f44f34
BLAKE2b-256 checksum
How to use checksums
e25391f37367e66fafce791cad027f6241eb15f33dfe899a68e28f3f8209144c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tokenfold-0.6.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tokenfold-0.6.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
1872dc94eafb96719b2bcc6cc87c1cd97f5310ef48b7ab501adaf21a568bf7d9
BLAKE2b-256 checksum
How to use checksums
15030db4cf93ae81db757ec72fed11b18cce5e784cee9c44be6503ff5ff70a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tokenfold-0.6.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL tokenfold-0.6.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 4.7 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
56671d6b6e8abc19191fc79b7953286c31426758f4a2dfdaacf2b2e6dbb8542f
BLAKE2b-256 checksum
How to use checksums
168fa576fd2ca430024da88de1e38618776e6292504b951a8f598740f9840544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tokenfold-0.6.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL tokenfold-0.6.0-cp312-abi3-macosx_11_0_arm64.whl
Size 4.5 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3531da91d9903b9a4fe3b886eaa6cefb266d838cb666790416db39689278dd81
BLAKE2b-256 checksum
How to use checksums
b957240e3884b67a5f24cfdea9f8db38c1ccb7f86f21c2bd3118f9b8f34ffa33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tokenfold-0.6.0-cp312-abi3-macosx_10_12_x86_64.whl

Download URL tokenfold-0.6.0-cp312-abi3-macosx_10_12_x86_64.whl
Size 4.5 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bd3cc02f3fc56e7f636df7ad3a9458ad790017c585274bdb73a4a46b256a346c
BLAKE2b-256 checksum
How to use checksums
39dccfae80acedd7e6b975b9b9ff51efe545452a0cca08d39b7ebfb747ca62cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tokenfold 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page