Official Python SDK for Kynth Core — the AI back-end for your product.
Project description
kynth
Official Python SDK for Kynth Core — the AI back-end for your product. Parse documents, extract fields, redact PII, analyze contracts, fight chargebacks, and enrich companies.
pip install kynth
Quickstart
from kynth import Kynth
client = Kynth(api_key="ksk_live_...")
doc = client.parse(file_url="https://.../invoice.pdf")
print(doc["totalAmount"]) # 4820.5
print(doc["usage"]["balanceRemaining"]) # 490
Get a key (and 500 free credits) at api.kynth.studio. Zero dependencies — stdlib only, Python 3.8+.
Methods
Every method returns the endpoint result as a dict, including a usage envelope. A non-2xx response raises a typed KynthError (and never burns credits).
client.parse(file_url=...) # documents → JSON
client.extract(text=..., fields=["order", "total"]) # pull named fields
client.classify(text=..., labels=["billing", "tech"]) # label text
client.summarize(text=..., length="standard") # summary + actions
client.redact(text=...) # strip PII/PHI
client.sentiment(text=..., aspects=["product"]) # sentiment + aspects
client.contract(file_url=...) # contract → terms + risks
client.chargeback(reason=..., transaction={"amount": 129}) # representment packet
client.enrich(email="sam@stripe.com") # company profile
client.account() # balance
Async & webhooks
A hundred-page contract doesn't fit in a request/response cycle. The document endpoints — parse, invoice, receipt, statement, resume, tables, split, compare, contract — take async_=True and hand you a job instead of a result. (async is a Python keyword, hence the trailing underscore; the wire field is async.)
job = client.parse(file_url="https://.../contract.pdf", async_=True)
done = client.wait_for_job(job["jobId"])
if done["status"] == "succeeded":
print(done["result"]["totalAmount"])
else:
print(done["error"]) # failed jobs are never charged
Use client.get_job(job_id) for a single poll if you'd rather drive the loop yourself.
Every job reaches a terminal state. If the instance running yours dies mid-flight, it is marked failed with an explanation rather than left running forever — and you aren't billed for it. Nothing is silently retried; resubmit and you stay in control of the spend.
Webhooks
Pass a callback_url (public https) and the finished job is POSTed to it, signed with your account's webhook secret from the API keys page:
client.parse(file_url=..., async_=True, callback_url="https://you.example/hooks/kynth")
import hmac, hashlib
# X-Kynth-Signature: sha256=<hex HMAC-SHA256 of the RAW body>
def verify(raw_body: bytes, header: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(header.removeprefix("sha256="), expected)
Delivery is best-effort and never retried — polling is the source of truth.
Error handling
from kynth import Kynth, KynthError
client = Kynth(api_key="ksk_live_...")
try:
client.parse(file_url="https://.../invoice.pdf")
except KynthError as err:
# err.code: "insufficient_credits" | "rate_limited" | "unauthorized" | ...
print(err.code, err.status, err.message)
MIT © Kynth Studios
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kynth-0.3.0.tar.gz.
File metadata
- Download URL: kynth-0.3.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd8a34e482e4e08154c1ec67465e2015df3556aaf67270fc4ce7552bc4522303
|
|
| MD5 |
02753de4714bb85450f9dbe664ac8920
|
|
| BLAKE2b-256 |
b46a8da06d973671c46c80bd9dba38a1c0feb7ddc1bab2b5affb633eb67204bf
|
File details
Details for the file kynth-0.3.0-py3-none-any.whl.
File metadata
- Download URL: kynth-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac710e5ac4f736636fb9b12ea4927de11194b69af7a2d8b85d6f09434bd2e963
|
|
| MD5 |
1a204934078da863b3dd5843617a90f6
|
|
| BLAKE2b-256 |
a098b3cce78d74b2c019c62f2c46c509488c0ee1e15f7b48f2d8f7f380a3a2a9
|