Metadata-Version: 2.4
Name: nail-sdk
Version: 1.0.0
Summary: NAIL — AI Agent Liability SDK. Real-time monitoring, circuit-breaking, and insurance certification for AI agents.
Project-URL: Homepage, https://neuravant.ai
Project-URL: Documentation, https://neuravant.ai/sdk
Project-URL: Repository, https://github.com/neuravant/nail-sdk
Project-URL: Bug Tracker, https://github.com/neuravant/nail-sdk/issues
Author-email: Neuravant <api@neuravant.ai>
License-Expression: Apache-2.0
Keywords: agent,ai,circuit-breaker,insurance,monitoring,safety,telemetry
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software 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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2.0
Provides-Extra: all
Requires-Dist: anthropic>=0.18; extra == 'all'
Requires-Dist: crewai>=0.1; extra == 'all'
Requires-Dist: langchain-core>=0.1; extra == 'all'
Requires-Dist: openai>=1.0; extra == 'all'
Requires-Dist: pyautogen>=0.2; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.18; extra == 'anthropic'
Provides-Extra: autogen
Requires-Dist: pyautogen>=0.2; extra == 'autogen'
Provides-Extra: crewai
Requires-Dist: crewai>=0.1; extra == 'crewai'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1; extra == 'langchain'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Description-Content-Type: text/markdown

# nail-sdk

**NAIL — AI Agent Liability SDK**

Real-time monitoring, circuit-breaking, and insurance certification for AI agents. Drop-in integration with OpenAI, Anthropic, LangChain, CrewAI, and AutoGen.

## Before You Start

You need two things from the [NAIL Portal](https://neuravant.ai/portal):

1. **Register your agent** — Dashboard → Agents → Add Agent. Note the agent name you choose.
2. **Generate an API key** — Dashboard → SDK & API Keys → Generate Key. Select the scopes you need (at minimum `agent:read`).

Store your key as an environment variable — never hard-code it:

```bash
export NAIL_API_KEY="nail_sk_YOUR_KEY_HERE"
```

Add that line to your `.env` file or deployment secrets (Render, Railway, Cloud Run, etc.).

---

## Install

```bash
pip install nail-sdk                    # Core SDK
pip install nail-sdk[openai]            # + OpenAI wrapper
pip install nail-sdk[anthropic]         # + Anthropic wrapper
pip install nail-sdk[langchain]         # + LangChain callbacks
pip install nail-sdk[all]               # Everything
```

---

## Quick Start

### OpenAI

```python
import os
from nail.sdk.openai_plugin import nail_wrap_openai
import openai

client = openai.OpenAI()
client, nail = nail_wrap_openai(
    client,
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-openai-agent",       # matches the name in your NAIL Portal
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}]
)
print(nail.session_summary)
```

### Anthropic

```python
import os
from nail.sdk.anthropic_plugin import nail_wrap_anthropic
import anthropic

client = anthropic.Anthropic()
client, nail = nail_wrap_anthropic(
    client,
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-anthropic-agent",    # matches the name in your NAIL Portal
)

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}]
)
```

### LangChain

```python
import os
from nail.sdk.langchain_plugin import NAILGuardMiddleware

middleware = NAILGuardMiddleware(
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-langchain-agent",    # matches the name in your NAIL Portal
)
chain.invoke({"input": "..."}, config={"callbacks": [middleware]})
```

### CrewAI

```python
import os
from nail.sdk.crewai_plugin import nail_wrap_crew

crew, nail = nail_wrap_crew(
    my_crew,
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-crew-agent",         # matches the name in your NAIL Portal
)
result = crew.kickoff()
```

### Any Python Agent (decorator)

```python
import os
from nail.sdk import Neuravant

nail = Neuravant(
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-agent",              # matches the name in your NAIL Portal
)

@nail.monitor
async def handle_query(user_input: str) -> str:
    return await my_llm_call(user_input)
```

### AutoGen

```python
import os
from nail.sdk.autogen_plugin import NAILAutoGenMonitor

monitor = NAILAutoGenMonitor(
    api_key=os.getenv("NAIL_API_KEY"),
    agent_name="my-autogen-agent",      # matches the name in your NAIL Portal
)
for agent in [agent1, agent2]:
    monitor.register(agent)
```

---

## No-Code / Non-Technical Setup (Proxy Mode)

If you use a no-code tool (Voiceflow, Make, Zapier, n8n, Dify, Flowise, etc.) and **cannot modify Python code**, use NAIL Proxy instead.

**Step 1 — Get your proxy-enabled key**

In the Portal → SDK & API Keys → Generate Key, tick the **proxy:use** scope.

**Step 2 — Point your tool at the NAIL proxy**

Instead of your LLM provider's base URL, use:

| Provider  | Original URL                          | NAIL Proxy URL                                    |
|-----------|---------------------------------------|---------------------------------------------------|
| OpenAI    | `https://api.openai.com`              | `https://neuravant.ai/proxy/openai/v1`            |
| Anthropic | `https://api.anthropic.com`           | `https://neuravant.ai/proxy/anthropic/v1`         |
| Mistral   | `https://api.mistral.ai`              | `https://neuravant.ai/proxy/mistral/v1`           |
| Cohere    | `https://api.cohere.ai`               | `https://neuravant.ai/proxy/cohere/v1`            |

**Step 3 — Add your NAIL key as a custom header**

In your no-code tool's HTTP settings, add one custom request header:

```
X-NAIL-API-Key: nail_sk_YOUR_KEY_HERE
```

Your existing provider API key stays in the `Authorization: Bearer <provider-key>` header as normal. No other changes needed.

**Test with curl:**

```bash
curl https://neuravant.ai/proxy/openai/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "X-NAIL-API-Key: nail_sk_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"ping"}]}'
```

All LLM traffic is transparently forwarded. NAIL monitoring (latency, tokens, pathology detection) runs in the background. No code changes required.

---

## What You Get

- **Circuit Breaker** — auto-kills runaway agents on latency, cost, or error spikes
- **Telemetry** — latency, token usage, cost tracking with PII scrubbing
- **Pathology Detection** — sycophantic decay, consensus paralysis, shadow delegation
- **Live Badge** — embeddable SVG showing real-time NAIL safety rating
- **Compliance** — GDPR, SOC 2, EU AI Act scanning built in

## Links

- **Docs**: [neuravant.ai/sdk](https://neuravant.ai/sdk)
- **Portal**: [neuravant.ai/portal](https://neuravant.ai/portal)
- **Support**: api@neuravant.ai
