AgentSecure SDK — LLM DLP proxy for Python
Project description
agentsecure
Python SDK for AgentSecure — drop-in LLM DLP proxy.
Every prompt routed through AgentSecure is scanned for PII before it reaches the model. SSNs, credit cards, and medical records are blocked. Emails, phone numbers, and names are redacted. Everything is logged in your audit trail.
Installation
# OpenAI only
pip install agentsecure-sdk[openai]
# Anthropic only
pip install agentsecure-sdk[anthropic]
# LangChain
pip install agentsecure-sdk[langchain]
# LlamaIndex
pip install agentsecure-sdk[llamaindex]
# Everything
pip install agentsecure-sdk[all]
Quick Start
Get your API key from the AgentSecure dashboard → API Keys.
export AGENTSECURE_KEY=as_xxxxxxxxxxxx
OpenAI
import agentsecure
client = agentsecure.openai(api_key="sk-...")
# Pass agentsecure_key= directly, or set AGENTSECURE_KEY env var
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "My SSN is 123-45-6789. Is that safe?"}],
)
print(response.choices[0].message.content)
# → blocked before reaching OpenAI (400 with matched pattern types)
The returned client is a plain openai.OpenAI instance — all methods, streaming, and async work exactly as documented by OpenAI.
Anthropic
import agentsecure
client = agentsecure.anthropic(api_key="sk-ant-...")
message = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[{"role": "user", "content": "Call John at 555-867-5309."}],
)
print(message.content[0].text)
# → phone number redacted; Claude sees [REDACTED]
Async
import agentsecure
aclient = agentsecure.async_openai(api_key="sk-...")
aclient_ant = agentsecure.async_anthropic(api_key="sk-ant-...")
Other providers (Groq, Mistral, Together AI, xAI, Perplexity…)
All OpenAI-compatible providers route through the OpenAI client:
import agentsecure
groq = agentsecure.client("groq", api_key="gsk_...")
response = groq.chat.completions.create(
model="llama-3.1-70b-versatile",
messages=[{"role": "user", "content": "Hello"}],
)
Supported provider names: openai, anthropic, groq, mistral, gemini,
perplexity, together, xai, cohere, huggingface.
LangChain
from agentsecure.langchain import AgentSecureChatOpenAI, AgentSecureChatAnthropic
llm = AgentSecureChatOpenAI(model="gpt-4o", openai_api_key="sk-...")
llm = AgentSecureChatAnthropic(model="claude-opus-4-7", anthropic_api_key="sk-ant-...")
These are factory functions that return standard ChatOpenAI / ChatAnthropic instances — chains, agents, and tools work without modification.
from langchain_core.prompts import ChatPromptTemplate
from agentsecure.langchain import AgentSecureChatOpenAI
chain = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant."),
("human", "{question}"),
]) | AgentSecureChatOpenAI(model="gpt-4o-mini")
result = chain.invoke({"question": "Summarise quantum computing in one sentence."})
LlamaIndex
from agentsecure.llamaindex import AgentSecureOpenAI
llm = AgentSecureOpenAI(model="gpt-4o", api_key="sk-...")
What gets detected
| Pattern | Action |
|---|---|
| SSN, passport, driver's license, bank account, credit card | Block — 400, request never reaches the LLM |
| Medical record numbers, NPI | Block |
| Email, phone, IP address, date of birth | Redact — replaced with [REDACTED] |
| Person names, organisation names (NER) | Redact — on-device BERT model |
Blocked requests raise an openai.BadRequestError (status 400) with the matched pattern types in the response body. Redacted requests return normally — the model sees the cleaned prompt.
Session tracking (Features 1 & 2)
Pass session_id to enable synthetic entity substitution and session-level accumulation detection:
import agentsecure
client = agentsecure.openai(
api_key="sk-...",
session_id="conv-abc123", # stable per conversation
user_id="user@acme.com", # optional: per-user attribution in audit log
)
With session_id set, the proxy replaces real names/orgs/locations with consistent synthetic equivalents before forwarding to the LLM, and reverses the substitution in the response. The model never sees real entities; the audit log and your app always do.
Configuration
| Parameter | Env var | Description |
|---|---|---|
agentsecure_key= |
AGENTSECURE_KEY |
Your AgentSecure API key (as_...) |
session_id= |
— | Conversation ID — enables Features 1 & 2 |
user_id= |
— | End-user identifier for audit attribution |
base_url= |
— | Override proxy URL (for self-hosted deployments) |
All other keyword arguments are passed through to the underlying client unchanged.
Dashboard
View blocked requests, redacted patterns, and full audit logs at agentsecure.vercel.app.
Project details
Release history Release notifications | RSS feed
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 agentsecure_sdk-0.1.0.tar.gz.
File metadata
- Download URL: agentsecure_sdk-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d81d77837d5074c78c4b7074018b16474d8fecbef37ea4b2d20f897b7798447
|
|
| MD5 |
2150739d802d1c9b5ba8c4656c82290f
|
|
| BLAKE2b-256 |
293ac5769f2d169cd224cf588b898e028eb50cfdcea0d06d3c6ddb4ae7973cd8
|
Provenance
The following attestation bundles were made for agentsecure_sdk-0.1.0.tar.gz:
Publisher:
publish-python-sdk.yml on utpalkh/agentsecure
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentsecure_sdk-0.1.0.tar.gz -
Subject digest:
6d81d77837d5074c78c4b7074018b16474d8fecbef37ea4b2d20f897b7798447 - Sigstore transparency entry: 2158055656
- Sigstore integration time:
-
Permalink:
utpalkh/agentsecure@3156569a0c29f192ec06bab638c562131d23f2e6 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/utpalkh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@3156569a0c29f192ec06bab638c562131d23f2e6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentsecure_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentsecure_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd57b47780d7b1c991d7602653acba78e699f8d629ed4b15a2471ebad71c3cda
|
|
| MD5 |
1b0891434c5dd078831591963382d535
|
|
| BLAKE2b-256 |
cf32e0cf61947bd9487a9a10f6209b3b5bc1a44ed08ac4257c1bb6f1b8434b5e
|
Provenance
The following attestation bundles were made for agentsecure_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish-python-sdk.yml on utpalkh/agentsecure
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentsecure_sdk-0.1.0-py3-none-any.whl -
Subject digest:
fd57b47780d7b1c991d7602653acba78e699f8d629ed4b15a2471ebad71c3cda - Sigstore transparency entry: 2158055674
- Sigstore integration time:
-
Permalink:
utpalkh/agentsecure@3156569a0c29f192ec06bab638c562131d23f2e6 -
Branch / Tag:
refs/tags/sdk-python-v0.1.0 - Owner: https://github.com/utpalkh
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-sdk.yml@3156569a0c29f192ec06bab638c562131d23f2e6 -
Trigger Event:
push
-
Statement type: