Catalog PyPI
PACKAGE EXPLORERView in registry

agentsecure-sdk

PyPI

AgentSecure SDK — LLM DLP proxy for Python

aianthropicdlpllmopenaiproxysecurity
Versions collected1
Direct dependencies7From release 0.1.0
Last observed20 Oct, 23:19 UTC

README

Version 0.1.0 documentation

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

PatternAction
SSN, passport, driver's license, bank account, credit cardBlock — 400, request never reaches the LLM
Medical record numbers, NPIBlock
Email, phone, IP address, date of birthRedact — 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

ParameterEnv varDescription
agentsecure_key=AGENTSECURE_KEYYour 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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.013 Jul 20267

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
utpalkh/agentsecure

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:19 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:6d8d33a8b823b805d5904cef42014f28d48c78f0b10f6c6f4b1989e0787b1187