Enterprise Python SDK for AI guardrails, PII protection, and telemetry logging.
Project description
AgentID Python SDK
Lightweight Python client for the AgentID security platform.
guard-> POST/guard(blocking / awaitable, fail-closed on errors)log-> POST/ingest(fire-and-forget telemetry)- OpenAI/LangChain wrappers automatically apply
transformed_inputfrom Guard (if returned).
Default base_url: https://app.getagentid.com/api/v1
Install
pip install agentid-sdk
Optional: Local-First PII Masking (Reversible)
pip install "agentid-sdk[pii]"
Optional: Enhanced Injection Security Stack
pip install "agentid-sdk[security]"
Sync Example
import time
from agentid import AgentID
from openai import OpenAI
agent = AgentID(api_key="sk_live_...", pii_masking=True)
openai = agent.wrap_openai(
OpenAI(api_key="..."),
system_id="...",
user_id="system-auto-summary", # optional service/user identity for audit
)
# Guard + logging happens automatically for chat.completions.create
start = time.perf_counter()
resp = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "User prompt"},
],
)
latency_ms = int((time.perf_counter() - start) * 1000)
print(resp.choices[0].message.content, latency_ms)
Optional timeout tuning
agent = AgentID(
api_key="sk_live_...",
guard_timeout_s=10.0, # default 2.0
ingest_timeout_s=10.0, # default 5.0
)
Async Example
import asyncio
from agentid import AsyncAgentID
from openai import AsyncOpenAI
async def main():
async with AsyncAgentID(api_key="sk_live_...") as agent:
openai = agent.wrap_openai(
AsyncOpenAI(api_key="..."),
system_id="...",
user_id="system-auto-summary", # optional service/user identity for audit
)
resp = await openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "User prompt"}],
)
print(resp.choices[0].message.content)
asyncio.run(main())
Security Notes
- Never print or log your API key.
- AgentID prioritizes security. If the gateway is unreachable, the SDK fails closed to prevent unmonitored PII leaks.
LangChain (Python) Callback
from agentid import AgentID, AgentIDCallbackHandler
agent = AgentID(api_key="sk_live_...")
handler = AgentIDCallbackHandler(agent, system_id="...")
# Then pass `handler` into LangChain callbacks (exact wiring depends on your chain/LLM):
# callbacks=[handler]
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
agentid_sdk-0.1.11.tar.gz
(30.5 kB
view details)
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 agentid_sdk-0.1.11.tar.gz.
File metadata
- Download URL: agentid_sdk-0.1.11.tar.gz
- Upload date:
- Size: 30.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbae134226b6b80a47a9c4843143bf3d4bd34d57df2c2f0ccd3c6574f8056488
|
|
| MD5 |
9655bb7ae744c579b366a38320b8f154
|
|
| BLAKE2b-256 |
1f771a8c9b44a5348d6275dc8715599a56c91c64588b7d11eefad741cbf8f12c
|
File details
Details for the file agentid_sdk-0.1.11-py3-none-any.whl.
File metadata
- Download URL: agentid_sdk-0.1.11-py3-none-any.whl
- Upload date:
- Size: 33.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27eb2022d705692eba6f6b0e51f083a51c0ed45adf7e126142834a30bb0caec0
|
|
| MD5 |
1fd2db67b21edef842f4c8a1130f4b26
|
|
| BLAKE2b-256 |
5c2331042dcacac68eaa72739de2073df37314c6221761735a843eb3dd63150f
|