# pnotp

> Official Python client for the P¬P platform. One account API key (`pnotp_sk_...`)
> trains models, deploys them as live endpoints, runs inference, and powers
> bring-your-own-brain tool-calling agents. PnotP hosts no frontier LLMs — an
> agent's brain is always your own key (Gemini/DeepSeek/OpenAI-compatible) or a
> model you deployed.

The SDK is self-documenting and the docs are offline (no key, no network). Always
prefer the in-package help over remembered signatures — it is generated by
introspection and matches the installed version exactly.

## Help (call these from Python)
- `pnotp.help()` — overview + topic list.
- `pnotp.help("<topic>")` — a topic page. Topics: overview, install, auth,
  quickstart, training, deployments, inference, agents, brains, tools,
  architectures, compliance, credits, errors, help.
- `pnotp.help.search("...")` — rank topics + the live API reference.
- `pnotp.help(pnotp.Agent)` / `pnotp.help("Client.train")` — a symbol's signature + docstring.
- `pnotp.help.errors` — the exception catalog.
- `pnotp.help.toby("...")` — ask PnotP's hosted assistant in plain English (needs
  `PNOTP_API_KEY` + credits; falls back to local docs when offline, never raises).
- `pnotp.help.as_tool()` — a tool so a running `pnotp.Agent` can ask Toby mid-loop.

## Errors
- All exceptions subclass `pnotp.PnotpError` and carry `.help`.
- `AuthError` (bad/missing key), `InsufficientCreditsError` (402), `NotFoundError`
  (404), `TimeoutError`, `MaxStepsExceeded`, `ToolError`, `ModelEndpointError`.
- On any error: `print(pnotp.help.toby(str(err)))`.

## Quickstart
```python
import pnotp
px = pnotp.Client()                                   # PNOTP_API_KEY
project = px.projects.create(name="X", task_type="binary_image_classification")
model = px.models.create(project["id"], name="cnn",
                         architecture=pnotp.architectures.image_classifier(num_classes=2))
px.train(model.id, dataset="train.zip", epochs=5).wait()
dep = px.deployments.upload(project["id"], name="prod", checkpoint="model.pt")
px.predict(dep["deployment"]["id"], "xray.jpg")
```

## Data-compliant inference (zero retention)
- `compliant=True` at deploy time makes an endpoint zero-retention: inputs are
  never persisted, errors are redacted from monitoring, and each response carries
  a `compliance` receipt. Set on `deployments.upload(...)`,
  `deployments.deploy_open_source(...)`, or `deployments.set_compliant(id, True)`.
- Platform capability: raises `APIError` 409 if not enabled; probe with
  `px.deployments.compliance_available()`. `compliant=False` (default) unchanged.
- Agents inherit it: `pnotp.model` uses the same path, so an agent calling a
  compliant endpoint is itself data-compliant. Compliance lives on the deployment,
  not the caller — to ship a compliant agent, deploy its models `compliant=True`.

## Setup
- `pip install pnotp`
- `export PNOTP_API_KEY="pnotp_sk_..."` (mint in Studio → Settings → API keys)
- local backend: `export PNOTP_BASE_URL="http://localhost:8000/v1"`
- agents: also set a brain key, e.g. `export GEMINI_API_KEY="..."`
