Metadata-Version: 2.4
Name: agentid-sdk
Version: 0.1.7
Summary: Enterprise Python SDK for AI guardrails, PII protection, and telemetry logging.
Project-URL: Homepage, https://agentid.ai
Project-URL: Repository, https://github.com/ondrejsukac-rgb/agentid/tree/main/python-sdk
Project-URL: Issues, https://github.com/ondrejsukac-rgb/agentid/issues
Author: AgentID
License: MIT
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27.0
Provides-Extra: pii
Requires-Dist: presidio-analyzer>=2.2.0; extra == 'pii'
Requires-Dist: presidio-anonymizer>=2.2.0; extra == 'pii'
Requires-Dist: pyahocorasick>=2.0.0; extra == 'pii'
Requires-Dist: spacy>=3.0.0; extra == 'pii'
Provides-Extra: security
Requires-Dist: google-re2>=1.1.20240702; extra == 'security'
Requires-Dist: numpy; extra == 'security'
Requires-Dist: torch>=2.0.0; extra == 'security'
Requires-Dist: transformers>=4.0.0; extra == 'security'
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'test'
Requires-Dist: pytest>=8.0.0; extra == 'test'
Description-Content-Type: text/markdown

# 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_input` from Guard (if returned).

Default `base_url`: `https://app.getagentid.com/api/v1`

## Install

```bash
pip install agentid-sdk
```

## Optional: Local-First PII Masking (Reversible)

```bash
pip install "agentid-sdk[pii]"
```

## Optional: Enhanced Injection Security Stack

```bash
pip install "agentid-sdk[security]"
```

## Sync Example

```python
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)
```

## Async Example

```python
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

```python
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]
```
