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.1. The tokenfold[select] extra adds only a compatible tokenfold-select-runtime 0.6.x, 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.1

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.1
File Size Uploaded Provenance Actions
tokenfold-0.6.1.tar.gz 306.5 kB Without provenance Details for tokenfold-0.6.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for tokenfold 0.6.1
File Actions
tokenfold-0.6.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for tokenfold-0.6.1-cp312-abi3-win_amd64.whl
tokenfold-0.6.1-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.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
tokenfold-0.6.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for tokenfold-0.6.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
tokenfold-0.6.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for tokenfold-0.6.1-cp312-abi3-macosx_11_0_arm64.whl
tokenfold-0.6.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for tokenfold-0.6.1-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 23.0 MB

Release files / tokenfold-0.6.1.tar.gz

Download URL tokenfold-0.6.1.tar.gz
Size 306.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b9a6279d26235e2fc4ba717bfa691138abb86710cce005110b256351abc637fc
BLAKE2b-256 checksum
How to use checksums
2d12645a58e4aa473d7d171412e491e56eba2c4181bcf77675e392d8a0ff1263
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.1-cp312-abi3-win_amd64.whl

Download URL tokenfold-0.6.1-cp312-abi3-win_amd64.whl
Size 4.3 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2a7fcf3101f26d40247fa22bf72dde66826e62f14cc00d6b648dfa532cc55fa4
BLAKE2b-256 checksum
How to use checksums
a782f1af39e705a7dc9addf3fe1a0284518b9b5a1b08b4bc633ed48567e4064f
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.1-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL tokenfold-0.6.1-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
03760954097f28daf9a612707753f79e4296987f2c144256d21b80478bf267ae
BLAKE2b-256 checksum
How to use checksums
ccbd8f5836ecc13d3ea968ee790d2d7b01ab5866eeb5ce3f7eecee4cdc1217db
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.1-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL tokenfold-0.6.1-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
18388ad5e2b76d5a9a562fd880da24a60956ceef3a4a37503ec607bbe7bbd5d5
BLAKE2b-256 checksum
How to use checksums
23ea7162c4665382f2346fb224bc471f11846b82eb42f434c6edfd4ae3db5482
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.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL tokenfold-0.6.1-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
ad15c9dde7a47d1bec1d783b2ed540650e6cbe99e389197320891f637a67668d
BLAKE2b-256 checksum
How to use checksums
0f36237c53f8e164b4f4553fc408eebf5aed5ae836c03b45aaa80c23917ba6e1
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.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL tokenfold-0.6.1-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
7c4b889a4dcfb40c480b9cab01d84c70197dc1ad881ece7713e15f415cdc8b9f
BLAKE2b-256 checksum
How to use checksums
a4ed9309f71febf7f0bbf5d2b768b3a92220dd8c1538cf04a5ec8f497ad611b9
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.1

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