Skip to main content

secure-ai

Data loss prevention for AI agents. Put a check in front of every action an agent takes, before it takes it.

pip install secure-ai-guard

Status: written, not yet executed — there was no Python interpreter on the machine this was built on. Run pytest before trusting it. The TypeScript SDK it mirrors does pass its suite.

The one thing worth knowing

guard wraps a function your agent already calls, and calls it with the rewritten arguments:

from secure_ai import SecureAI

sai = SecureAI(api_key=os.environ["SECURE_AI_KEY"], agent="support-bot")

send_email = sai.guard("email.send", mailer.send)
send_email({"to": "ana@clientfirm.com", "body": "About invoice 4471…"})

The agent wrote a real address. mailer.send receives a stand-in. Nothing in the agent's code had to check a decision — which is the point. Protection that depends on remembering to check it ends at the fourteenth call site.

If the policy refuses, the wrapped function is never called and ActionBlocked is raised.

As a decorator:

@sai.guarded("email.send")
def send(payload): ...

A whole toolbelt at once

tools = sai.guard_tools(agent.tools)

Wraps whichever attribute holds the callable — func, _run, run — so LangChain and similar frameworks are governed in one line. Shapes it does not recognise are returned untouched rather than raising.

Rules

Rules live on the account, not in the request. An agent cannot argue with them.

sai.set_policy({
    "fallback": "redact",
    "rules": [
        {"kind": "secret", "decision": "block"},
        {"kind": "card", "decision": "block", "direction": "outbound"},
        {"kind": "email", "decision": "allow", "tools": ["crm.*"]},
    ],
    "denyTools": ["shell.*"],
})

sai.allow_value("@ourcompany.com")   # stop flagging your own domain

When an action contains several findings, the most severe decision wins.

The trail

sai.summary()                # counts over a recent window
sai.audit(limit=100)         # the records themselves

Records hold the kind and location of what was found — card at body.payment.number — and never the value. Finding has no field for one.

When Secure AI is unreachable

Default is on_unreachable="closed": the action does not happen. Correct for a security control, and it does mean an outage here stops agents.

SecureAI(api_key=..., on_unreachable="open")   # availability over control

Failing open never waves a real refusal through — a 401, 402 or quota error is an answer, not an outage, and still raises.

No code to change at all

If wrapping each tool is too invasive, point the HTTP client the agent already uses at the gateway. Every request it makes is inspected on the way out, and no call site changes:

from openai import OpenAI

openai = OpenAI(
    base_url=sai.gateway_url("https://api.openai.com/v1"),
    default_headers=sai.gateway_headers(forward_auth=f"Bearer {os.environ['OPENAI_KEY']}"),
)

Two credentials travel and they are kept apart on purpose: your Secure AI key authenticates you to us and is never forwarded; forward_auth is the destination's own and becomes the outbound Authorization.

For code that makes a call rather than holding a client:

res = sai.gateway("POST", "https://api.vendor.com/v1/send", body={"to": "ana@clientfirm.com"})
res.status, res.json(), res.decision

That form raises ActionBlocked on a refusal, so it fails the way a guarded function fails. Pass raise_on_block=False to get the response back instead. A 403 from the destination itself is not mistaken for one of ours — only our own blocked_by_policy code raises.

The gateway will not forward to private or link-local addresses, so it cannot be pointed at a cloud metadata service. Bodies it cannot read as text — an image, a zip — are forwarded and the response carries X-Secure-AI-Inspected: false, rather than a clean log implying a check that did not happen.

No dependencies

Standard library only. This runs beside your model client and your framework, and every dependency it adds is a version conflict it can cause.

Full reference: https://secureai.one/developers

Metadata

Release files for secure-ai-guard 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for secure-ai-guard 0.2.3
File Size Uploaded
secure_ai_guard-0.2.3.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for secure-ai-guard 0.2.3
File Interpreter ABI Platform
secure_ai_guard-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / secure_ai_guard-0.2.3.tar.gz

Download URL secure_ai_guard-0.2.3.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5e35e88592c4e62c4cd6d643bdd04c68ce8069b23cf4ec330a93e38b18ecc139
BLAKE2b-256 checksum
How to use checksums
2e7b878b0efa9da393a692aee6e8af70f388f95c3464a74a7e0cc89fd85a2668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / secure_ai_guard-0.2.3-py3-none-any.whl

Download URL secure_ai_guard-0.2.3-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebb38210e2ff73b56fb187369a9f3ccf8156486679880cab599c2a938c0f68a0
BLAKE2b-256 checksum
How to use checksums
5d6fe09b8f1e69ec8b07adc44af7fcee5ba7a9d511d006584f33b50ac84bc75a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

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