Skip to main content
Requires Python 3.9+. The only dependency is httpx, which gives sync and async from one API — so AsyncTokz is not a second HTTP stack with its own timeout semantics to keep in step. Only decide_local needs more, through pip install "tokz[local]".

Decide

tokz.decide(inputs, decisions, *, model=None, timeout=60.0) and tokz.list_decision_models(). See the Decisions API. decide is never retried, because a retry could bill twice. Tokz(api_key, base_url="https://api.tokz.dev", client=None) accepts your own httpx.Client for proxies or tests; a client you pass in is not closed for you. Use with Tokz(...) as tokz: or call close().

Fine tunes

Call a fine tune by name. Needs 0.6+. Up to 16 texts on our servers, and the answer is always under decision. For a multi-label model read selected, because best names a label even when selected is empty.
decide_local runs the same model on this machine for free, with the same result shape.
The first call downloads the model into ~/.cache/tokz on every OS and verifies its hashes. TOKZ_CACHE_DIR moves the cache. After that it works offline, and asks the server about once an hour whether the model still exists. The extra keeps onnxruntime at 1.26.0 or older, because newer versions change the scores. See Fine Tune.

Async

Same methods, same errors. decide_local runs on a worker thread.

Errors

Both are importable from tokz.