Skip to main content

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

kynth-0.5.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kynth-0.5.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file kynth-0.5.0.tar.gz.

File metadata

  • Download URL: kynth-0.5.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kynth-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ddf376cf788275bad523725e43873ce0d6ae67986d253a0638a18d7bf89e4d1d
MD5 820168dda2a66cad69b26af0f545ec79
BLAKE2b-256 57b80a985359e55fbca0c4a6913664a519740faf10877d3404b2a0ff9af49365

See more details on using hashes here.

File details

Details for the file kynth-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: kynth-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for kynth-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b612df35ba0c6cabe5f739c24ca846b1c16907eafb3760995ba8fba1ccba5ae
MD5 284a52f5b310f63ad5e1bbba14a246cd
BLAKE2b-256 7176be0c40254683e4f0058899541b64e6d6046ffd6207c95ecd02823937cb7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page