Skip to main content

finic-kairos

Python client for Kairos. Track financial events, then ask for a decision at the moment of action.

  • Python 3.9 or later
  • No dependencies: the standard library only
  • Typed (py.typed), and safe to use from several threads

This page is the short version. The full Python SDK guide covers every call, and the TypeScript guide explains actions, labels, links and how to get good decisions in depth.

Install

Install it from PyPI:

pip install finic-kairos

Use

import os
from kairos import Kairos

kairos = Kairos(os.environ["KAIROS_API_KEY"])

# Once, at startup: say what you want decided, in plain language.
kairos.define_action("bank_transfer", {
    "subject": "user",
    "hold": "Should the pending bank transfer be held because the account shows signs of fraud or account takeover?",
    "reasons": {
        "new_device": "The current session uses a device that the account did not use before",
        "new_beneficiary": "The transfer goes to a beneficiary that was added recently",
    },
})

# Anywhere: record what happens. Any event type, any properties.
# A key that ends in _id names an entity: user_id is the entity "user".
kairos.track("transaction", {
    "user_id": "user_123",
    "account_id": "account_456",
    "recipient_id": "recipient_789",
    "amount": 9500,
    "currency": "USD",
})

# At the moment of action: ask.
decision = kairos.decide(
    "bank_transfer",
    {"user_id": "user_123", "recipient_id": "recipient_789", "amount": 9500},
    fallback="review",
)

if decision.decision == "approve":
    ...  # release the transfer

track returns at once and sends in the background. decide waits for the answer, sends what is queued first, and returns the fallback when Kairos cannot answer.

In a web framework

KairosASGI takes the user and the session from the request, for FastAPI, Starlette and any other ASGI framework. It can also send an event for a route that has no track call.

from kairos.middleware import KairosASGI

app.add_middleware(
    KairosASGI,
    client=kairos,
    entities=lambda scope: {"user": scope["state"].get("user_id")},
    session=lambda scope: scope["state"].get("session_id"),
    routes={"PUT /account/password": "password_changed"},
)

kairos.track("transaction", {"amount": 900})  # the user and the session come from the request

See In a web framework.

Import history from files

python -m kairos import events transactions.csv --type transaction --ts created_at --id txn_id --dry-run

See Import your history.

Test

python3 -m unittest discover -s packages/sdk-python/tests     # no network
python3 packages/sdk-python/examples/live_check.py            # against a running server

Metadata

Release files for finic-kairos 0.1.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 finic-kairos 0.1.0
File Size Uploaded Provenance Actions
finic_kairos-0.1.0.tar.gz 49.7 kB Without provenance Details for finic_kairos-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for finic-kairos 0.1.0
File Interpreter ABI Platform Actions
finic_kairos-0.1.0-py3-none-any.whl Python 3 none any Details for finic_kairos-0.1.0-py3-none-any.whl

Total release size: 85.2 kB

Release files / finic_kairos-0.1.0.tar.gz

Download URL finic_kairos-0.1.0.tar.gz
Size 49.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2d5705b6bbdb7942aca906527e61ac1dae5a93c8d86dbd7a2464b30307b0253a
BLAKE2b-256 checksum
How to use checksums
47bb617f2661cd19bc555da6b374367e2d7e8d1624e7c340f3d993d1eac2ae84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / finic_kairos-0.1.0-py3-none-any.whl

Download URL finic_kairos-0.1.0-py3-none-any.whl
Size 35.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0924cf62e133d6527fc4922fddd0eaca1cfca366b98205d06cbcf8adb93b85af
BLAKE2b-256 checksum
How to use checksums
a521e0ee74d693b1c084e85cf197ce2fb30ce12b855ed58335f1c3b39a484655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for finic-kairos 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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