hanzo-kai
Python client for Kai decisions on the Hanzo API. Send a state and named questions; get typed, calibrated answers back: a label for a choice, a probability for a yes/no noul, an expected level for a score.
Install
pip install hanzo-kai # or: uv add hanzo-kai
Python 3.12 or later. Set HANZO_API_KEY to a Hanzo sk- key.
Quickstart
from hanzo_kai import Choice, Kai, Noul, Score
teams = {"billing": "charges, invoices, refunds", "tech": "bugs and outages"}
billing = {"true": "it concerns charges, invoices or refunds", "false": "it concerns something else"}
questions = {
"team": Choice(instructions="Which team should handle this?", criteria=teams),
"billing": Noul(instructions="Is this about billing?", criteria=billing),
"urgency": Score(instructions="How urgent is this?", criteria=["can wait", "this week", "today"]),
}
with Kai() as kai: # reads HANZO_API_KEY
d = kai.decide({"ticket": "I was charged twice for my March invoice. Please refund the duplicate."}, questions)
print(d.choices["team"].choice, d.choices["team"].probabilities)
print(d.nouls["billing"].noul)
print(d.scores["urgency"].score, d.scores["urgency"].probabilities)
AsyncKai takes the same arguments, with await and async with. kai.models.list() lists the
models that answer decisions.
Settings come from arguments, then HANZO_API_KEY, HANZO_BASE_URL (default
https://api.hanzo.ai), KAI_MODEL (default kai) and KAI_LOG_LEVEL (default warn).
Moving from Jev
hanzo_kai.jev keeps TypeSafe's call shapes on Kai's Jev-compatible path, POST /v1/systemone, answering in Jev's shape:
from hanzo_kai.jev import Choice, Noul, Score, Client as TypeSafeClient ports a TypeSafe program in one line.
Docs
- Kai: https://docs.hanzo.ai/docs/kai
- Moving from TypeSafe's Jev: https://docs.hanzo.ai/docs/guides/migrate/jev
Metadata
Release files for hanzo-kai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hanzo_kai-0.1.0.tar.gz | 105.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hanzo_kai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 128.0 kB
Release files / hanzo_kai-0.1.0.tar.gz
| Download URL | hanzo_kai-0.1.0.tar.gz |
|---|---|
| Size | 105.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb77922f1836883d0bf734eb1c147ea556cadcbc7df1b08ba0977ba42f9ec961
|
|
BLAKE2b-256 checksum How to use checksums |
23d873dc39f40d0b3ec970ad95c99f730df0497d52328feb9bf14100e20c6fd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / hanzo_kai-0.1.0-py3-none-any.whl
| Download URL | hanzo_kai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f40491d3b2a6ee04c68caee0c556473ead0fe8a2d23884511e88ce23619bb19
|
|
BLAKE2b-256 checksum How to use checksums |
2ff612b472d836b3f95c8bf327d21ba5a5741c895c1b857f811d1bb50443a57f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|