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.
Licence
Apache-2.0.
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 flowx_border-0.1.0.tar.gz.
File metadata
- Download URL: flowx_border-0.1.0.tar.gz
- Upload date:
- Size: 704.3 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce81da1e313982c9f8b0254b58f67d3fad75c6916a440189bf000b89ab06cb9d
|
|
| MD5 |
9b2c8b43a5cd80d00049f123249eb656
|
|
| BLAKE2b-256 |
6eebb0e1945771d729a61db51e145dea52993fe0169ded2527fa0e94fe914c5c
|
File details
Details for the file flowx_border-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flowx_border-0.1.0-py3-none-any.whl
- Upload date:
- Size: 410.6 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f1eb468676d86dde1f6aa6f9520ebc41c2301145b74769cc83d7950e4cac6ba
|
|
| MD5 |
6c5f21ad2796c98e14761a54cf0c9c24
|
|
| BLAKE2b-256 |
fed9c57d6241c285efb42b14dc5d3acdaa419405658d8b530f1f0e61c4c72ad9
|