Metadata-Version: 2.5
Name: tokz
Version: 0.5.0
Summary: Client for the Tokz Decisions API: typed answers about text from the open OpenDecision models.
Project-URL: Homepage, https://tokz.dev
Project-URL: Documentation, https://docs.tokz.dev
Project-URL: Source, https://github.com/tokz-labs/platform
Author: tokz
License: MIT
Keywords: agents,classification,decisions,llm,opendecision,routing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.24
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Description-Content-Type: text/markdown

# tokz

Client for the Tokz Decisions API: typed answers about text from the open
[OpenDecision](https://github.com/tokz-labs/OpenDecision) models.

```bash
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.

```python
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

```python
from tokz import AsyncTokz

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

Same methods, same errors.

## Links

- [tokz.dev](https://tokz.dev)
- [Documentation](https://docs.tokz.dev)
- [TypeScript SDK](https://www.npmjs.com/package/@tokz/sdk)

MIT
