Skip to main content

flowx-border

Inspects the text going into and coming out of an LLM, and returns a structured decision plus an evidence record. It ships its own open-weight detection models and runs them on CPU.

Two functions. It does not sit in front of your model, hold your API key, or make the call for you.

Install

pip install flowx-border

Python 3.11 or newer. Two optional extras exist because two detectors need a parser: flowx-border[sql] for sql_injection and flowx-border[schema] for json_schema.

Model weights are fetched once, on first load, and cached. After that a scan needs no network.

Use

from flowx_border import load_policy, scan_input, scan_output

policy = load_policy("policies/default.yaml")

decision = scan_input(user_text, policy)
if decision.verdict == "block":
    return refusal(decision.evidence.record_id)

answer = your_llm(decision.text)

checked = scan_output(answer, policy)
return checked.text, checked.evidence

Both functions take (text, policy, ctx=None) and return a Decision:

verdict         "allow" | "redact" | "block" | "flag"
text            possibly redacted or rewritten
original_text   what came in
findings        one Finding per detection: detector, label, score, span, action
evidence        EvidenceRecord
elapsed_ms      float
tiers_run       which tiers ran, which is not always all of them

ctx carries what the text does not say: sources for groundedness, an optional locale hint, and free metadata. A detector that needs it and does not get it reports that it could not run rather than passing quietly.

Policy

Policy is data, never code. Two policies ship in policies/.

policy_id: default
version: 1

fail_mode:
  T0: closed          # a detector that errors blocks the scan
  T1: open            # a detector that errors is recorded and the scan continues
  T2: open
  T3: open

detectors:
  secrets:
    on_fail: block
  pii:
    on_fail: redact
    threshold: 0.5
    options:
      entities: [CARD, DATE, EMAIL, IBAN, NATIONAL_ID, PERSON, PHONE]
      entity_actions:
        date: flag    # found and recorded, but left in the text
  toxicity:
    on_fail: flag

Detectors run in tiers. T0 always runs and cannot be disabled. T1 and T2 run on the standard path, and T2 may be disabled per policy. T3 runs only when a lower tier flags, or when the policy sets always: true.

registry.deployment_notes(policy) returns one line per thing a policy asks of the machine beyond a CPU and the base install.

Evidence

Every scan produces a record. It contains hashes, never raw user text.

from flowx_border.evidence import sign_record, verify_record

signed = sign_record(decision.evidence, your_private_key)
assert verify_record(signed, your_public_key)

The library never holds a signing key. Serialisation is canonical JSON, so a hash computed on one machine matches one computed on another, and a scan is deterministic given the same input and the same model revisions.

This does not make anyone compliant with anything. It records which checks ran and what they found. Obligations under any AI regulation sit with the provider or deployer of a system, not with a library inside it.

Documentation

Quickstart a first scan, and the policy file
The two functions what a Decision means
The evidence record fields, hashing, signing
Tiers what runs when
Offline what works with the network down
Detectors every detector, generated from the code
Measured performance latency and quality, per detector
Languages the 26 supported languages
Migrating from llm-guard scanner to detector mapping

Not every catalogued detector runs on a fresh install. docs/detectors.md is generated from the code and says which, and the numbers in docs/reference/performance.md come from benchmarks/collect.py.

Known issues

open_issues.md lists what is measured, unfixed and why, with the number attached to each. Four detectors have documented false positives on ordinary text, and two of them are disabled in the shipped policies for that reason.

Contributing

CONTRIBUTING.md has the setup, the test markers and what a change has to satisfy. Please do not put real personal data in an issue: this library exists to find it, so send a synthetic equivalent with the same shape.

Licence

Apache-2.0.

Metadata

Release files for flowx-border 0.4.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 flowx-border 0.4.0
File Size Uploaded Provenance
flowx_border-0.4.0.tar.gz 799.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flowx-border 0.4.0
File Interpreter ABI Platform
flowx_border-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / flowx_border-0.4.0.tar.gz

Download URL flowx_border-0.4.0.tar.gz
Size 799.9 kB
Tags Source
SHA-256 checksum
How to use checksums
afa3257fa5ef81a35453fc5fd185c5da92de137a4a004cd93eaac97054494397
BLAKE2b-256 checksum
How to use checksums
b564ad3c879e9edc965b426ecf72948821d78a353756557e7f7fd99dddcf6ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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}

Release files / flowx_border-0.4.0-py3-none-any.whl

Download URL flowx_border-0.4.0-py3-none-any.whl
Size 425.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b0a1dc5a1459e090fb3e01d9bc62678f2baa588378e127d743815ee75e1aeab
BLAKE2b-256 checksum
How to use checksums
ca619f270330de1a97a0f06e0192d8ad56970d23a16ab27033476ea15a69ab52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","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}

Security for flowx-border 0.4.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.

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