Skip to main content

Python SDK for Statis — the trust layer for production AI agents (policy-gated tool calls + signed receipts)

Project description

statis-ai

The trust layer for production AI agents. One decorator turns any function into a policy-gated, audit-logged tool call. No agent framework lock-in, no proxy in front of your model, no rewrites.

statis-ai is the Python SDK for Statis. Drop it in front of any side-effectful function your agent calls — Stripe refunds, internal APIs, database writes — and Statis evaluates a deterministic policy before the function executes, then writes a signed receipt of the decision.

from statis import gate

@gate(action_name="issue_refund")
def issue_refund(charge_id: str, recipient_email: str, cents: int) -> dict:
    return stripe.Refund.create(charge=charge_id, amount=cents)

The decorator does three things on every call:

  1. Context In — Strips prompt injections, redacts PII, meters tokens before the model call. (Re-exported from statis-kit, our open-source pre-call hygiene library.)
  2. Action Out — Sends the proposed call to the Statis policy engine. Approved → executes. Denied → raises ActionDeniedError with a receipt. Escalated → human approves in the console; agent resumes.
  3. Receipt Through — Every decision is recorded in an Ed25519-signed, hash-chained ledger. Verifiable offline with the public key at /.well-known/aarm-pubkey.

Install

pip install statis-ai
# optional: receipt signature verification (offline)
pip install "statis-ai[verify]"

Set your API key:

export STATIS_API_KEY=st_...

(Get one for free during beta at statis.dev.)

Quick start — gate a function

from statis import gate, ActionDeniedError

@gate(
    action_name="issue_refund",
    entity=lambda: {"customer_id": "CUST-7781"},
    target_system="stripe",
    timeout_s=10,
)
def issue_refund(charge_id: str, recipient_email: str, cents: int) -> dict:
    """Issue a Stripe refund. Only runs after the policy engine approves."""
    return {"id": f"re_{charge_id[-6:]}", "amount": cents, "status": "succeeded"}


try:
    result = issue_refund(
        charge_id="ch_3PxOrder9921",
        recipient_email="alice@bigcustomer.com",
        cents=4999,
    )
    print("approved:", result)

except ActionDeniedError as e:
    print(f"denied by rule {e.receipt.rule_id}: {e}")
    # e.receipt has receipt_id, hash, signature — audit-ready, no extra wiring.

Policy as code

Rules are deterministic YAML, evaluated server-side per call. No LLM in the decision path:

- rule_id: refund_recipient_must_match_state
  action_type: issue_refund
  conditions:
    recipient_matches_customer_of_record: true
  decision: APPROVED
  priority: 100

Apply with the CLI:

statis policy apply policies.yaml

What you get out of the box

  • @statis.gate decorator — sync + async, idempotent, with timeout + escalation
  • StatisClient — lower-level access for custom flows
  • process_context() — re-exported from statis-kit for one-line pre-call hygiene (Guard + Compressor + Meter)
  • CLI — statis init, statis policy apply, statis receipts list, statis receipts verify
  • Distributed lock + at-most-once execution semantics
  • Console (web UI) for approvals, escalations, kill-switch, and receipt verification

Free during beta

The Developer Cloud (policy engine, ledger, console) is free while in beta — no Stripe at launch. Self-hosted Enterprise (SSO, SCIM, VPC, compliance exports) is contract-driven.

Links

License

MIT.

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

statis_ai-0.4.2.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

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

statis_ai-0.4.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file statis_ai-0.4.2.tar.gz.

File metadata

  • Download URL: statis_ai-0.4.2.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for statis_ai-0.4.2.tar.gz
Algorithm Hash digest
SHA256 11da941aab129713bbfa204c131190a5dbedb849d1d8ae8a8f6ed60e4be9e9cf
MD5 96d58351a63e1c5f08649a3e8292ab58
BLAKE2b-256 a714326d10b500d4f6216290181c5dbe84c2bf843f27781df4f131b864b7acc5

See more details on using hashes here.

File details

Details for the file statis_ai-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: statis_ai-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for statis_ai-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8836b99cbfe9496edccdccc5b119e0367d1042ffc0d681cdbf73ff42a30c59f6
MD5 8b7aa426210df22a3075bae576d92c55
BLAKE2b-256 18736aec29da823a548549ffbb25fd3d289b3981b730df7ee443ce17dbdfced5

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