Skip to main content

tokz

Client for the Tokz Decisions API: typed answers about text from the open OpenDecision models.

pip install tokz

decide() answers a choice, multilabel, bool or score per question, with a probability for every option. The text is read by a model on Tokz servers and is not stored. Each request is billed, so the client never retries one.

import os
from tokz import Tokz

tokz = Tokz(api_key=os.environ["TOKZ_API_KEY"])

out = tokz.decide(
    "I was charged twice and the app keeps logging me out.",
    {
        "queue": {"type": "choice", "options": ["billing", "technical", "account"]},
        "priority": {"type": "score", "low": 1, "high": 5},
    },
)
r = out["results"][0]
r["queue"]["best"], r["priority"]["score"], out["usage"]["billed_tokens"]

catalog = tokz.list_decision_models()

A 402 raises TokzInsufficientCreditsError; every other failure raises TokzError with the HTTP status.

Async

from tokz import AsyncTokz

async with AsyncTokz(api_key=...) as tokz:
    out = await tokz.decide(texts, {"urgent": {"type": "bool"}})

Same methods, same errors.

MIT

Metadata

Release files for tokz 0.5.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 tokz 0.5.0
File Size Uploaded Provenance Actions
tokz-0.5.0.tar.gz 6.0 kB Without provenance Details for tokz-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tokz 0.5.0
File Interpreter ABI Platform Actions
tokz-0.5.0-py3-none-any.whl Python 3 none any Details for tokz-0.5.0-py3-none-any.whl

Total release size: 12.2 kB

Release files / tokz-0.5.0.tar.gz

Download URL tokz-0.5.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3e160a8a9564afbecf38aa43f749974fdcc3ad04df6ee97211350c35dd8dddd1
BLAKE2b-256 checksum
How to use checksums
6d511f7e95eb15a78d338b4cb96a2228d291902ff6ad5120d9ae8422ae01419d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / tokz-0.5.0-py3-none-any.whl

Download URL tokz-0.5.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1d84b8382f6b90cee9c3fe0ac5f003ccbba98c31959c27f8c95fb9eecda7ca5
BLAKE2b-256 checksum
How to use checksums
a75104e2aca327a8369eb0c6f3c618db6342e79059a0a248b33938d9a89b87d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for tokz 0.5.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