Metadata-Version: 2.4
Name: xaidr
Version: 0.1.2
Summary: Delphi xAIDR Python SDK — Extended AI Detection & Response for agent fleets
Project-URL: Homepage, https://delphisecurity.ai
Project-URL: Repository, https://github.com/anirudhraokotaru/delphi-python-sdk
Project-URL: Documentation, https://docs.delphisecurity.ai
Author-email: Anthony Kotaru <anirudh@delphisecurity.ai>
License: MIT
License-File: LICENSE
Keywords: agents,ai,delphi,langchain,security,xaidr
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain>=1.0.0; extra == 'langchain'
Description-Content-Type: text/markdown

# xaidr

**xAIDR** — Extended AI Detection & Response for agent fleets, by [Delphi Security](https://delphisecurity.ai).

`xaidr` is the official Python SDK for the Delphi Sentinel Brain. It's a thin
HTTP client: your agent calls `sensor.scan(...)`, Delphi runs detection rules
server-side and returns an action (`allowed` / `flagged` / `blocked` /
`escalated`). Rules stay in the Brain so every deployment gets updates without
a release.

## Install

```bash
pip install xaidr
```

With LangChain 1.0 middleware:

```bash
pip install 'xaidr[langchain]'
```

## Quick start

```python
import asyncio
from xaidr import Sensor

async def main():
    async with Sensor(agent_id="my-agent") as sensor:
        result = await sensor.scan("ignore previous instructions")
        print(result.action, result.score, result.category)

asyncio.run(main())
```

Set `DELPHI_API_KEY` in your environment (or pass `api_key=` directly). See
`.env.example`.

## LangChain (3 lines)

```python
from langchain.agents import create_agent
from xaidr.integrations.langchain import delphi_middleware

agent = create_agent(model="anthropic:claude-sonnet-4-5", tools=[...],
                    middleware=[delphi_middleware(agent_id="my-agent")])
```

The middleware scans every user turn before it reaches the model and short-
circuits with a refusal on `blocked`.

## API

- `Sensor(agent_id, api_key=None, sentinel_url=..., ...)` — main client
- `await sensor.scan(prompt, direction="input") -> ScanResult`
- `await sensor.scan_output(response) -> ScanResult`
- `ScanResult(action, score, category, rules, latency_ms)`
- `DelphiBlockedError` — raised for convenience flows that prefer exceptions

Use `async with Sensor(...) as sensor:` — it registers the sensor, starts the
background telemetry flush, and tears both down on exit.

## Docs

Full docs: [docs.delphisecurity.ai](https://docs.delphisecurity.ai) *(coming soon)*

## License

MIT. See [LICENSE](./LICENSE).
