Metadata-Version: 2.4
Name: airg-client
Version: 0.4.2
Summary: Python client for the AI Runtime Governor – runtime AI-agent governance service
Project-URL: Homepage, https://developers.airg.nov-tia.com/
Project-URL: Documentation, https://app.airg.nov-tia.com/docs
Author: NOVTIA LTD
License-Expression: MIT
License-File: LICENSE
Keywords: agent-governance,agents,ai-agents,ai-runtime-governor,ai-safety,airg,approvals,human-in-the-loop,llm,runtime-policy
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.9
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 :: Security
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24.0
Description-Content-Type: text/markdown

# airg-client

Python client for the **AI Runtime Governor** – a runtime governance layer for AI agents.

The Governor evaluates every tool invocation against configurable policies and
returns an **allow / block / review** decision before the tool executes.

## Installation

```bash
pip install airg-client
```

Requires Python 3.9 or later. Create an API key in the
[AIRG dashboard](https://app.airg.nov-tia.com).

## Quick start

```python
import os
from airg import AIRG

client = AIRG(
    base_url="https://api.airg.nov-tia.com",
    api_key=os.environ["GOVERNOR_API_KEY"],
)

decision = client.evaluate(
    tool="issue_refund",
    args={"order_id": "A-1001", "amount": 40, "currency": "GBP"},
    context={"session_id": "abc-123"},
)
print(decision["decision"])      # "allow" | "review"
print(decision["risk_score"])    # 0 – 100
print(decision["explanation"])
```

## Configuration

| Environment variable | Description |
|---|---|
| `GOVERNOR_URL` | Base URL of the Governor service (default `http://localhost:8000`; the hosted service is `https://api.airg.nov-tia.com`) |
| `GOVERNOR_API_KEY` | API key (`airg_…`) |

Or pass them explicitly:

```python
client = AIRG(api_key="airg_...", base_url="https://api.airg.nov-tia.com")
```

## API

### `AIRG(*, api_key=None, base_url=None, timeout=10.0)`

Create a client. Reads `GOVERNOR_API_KEY` and `GOVERNOR_URL` from
environment variables when not provided.

### `client.evaluate(tool, args, context=None, *, review_mode="hold", hold_timeout=60) → dict`

Evaluate a tool call. Returns the decision dict:

```python
{
    "decision": "allow",        # "allow" | "block" | "review"
    "risk_score": 0.15,
    "explanation": "Low-risk read operation",
    "policy_ids": ["shell-guard"],
    "modified_args": None,
}
```

Raises `BlockedError` if the decision is `"block"`.

**Review decisions.** By default (`review_mode="hold"`, since 0.4.0) a
`"review"` decision waits up to `hold_timeout` seconds for a reviewer. The
call returns only if the action is approved; otherwise it raises
`ReviewRejectedError` or `ReviewExpiredError`, so your code does not run it.

```python
client.evaluate("wire_transfer", {"amount": 250000}, hold_timeout=120)
# returns once approved; raises ReviewRejectedError or ReviewExpiredError otherwise
```

To get the decision back at once instead, pass `review_mode="proceed"`. Your
code must then not run the action until a reviewer approves it; the first
time this happens the client emits a `ReviewNotEnforcedWarning`.

**Upgrading from 0.3.x:** `review_mode` used to default to `"proceed"`. Code
that relied on that and handles reviews itself should pass
`review_mode="proceed"` explicitly.

`hold_timeout` is capped at 300 seconds by the Governor.

### `client.scan(text, agent_id=None, session_id=None, context=None) → dict`

Scan agent output for threats before sending to users.

### `client.verify(action_id, tool, result, context=None) → dict`

Post-execution verification. Raises `VerificationError` on violations.

### `client.ingest_spans(spans) → dict`

Batch-ingest agent trace spans.

### `client.list_traces(**filters) → list`

List traces with optional filters (`agent_id`, `session_id`, `has_blocks`, `limit`, `offset`).

### `client.get_trace(trace_id) → dict`

Fetch full trace detail.

### `client.delete_trace(trace_id) → dict`

Delete all spans for a trace.

## Exceptions

| Exception | Description |
|---|---|
| `AIRGError` | Base exception |
| `BlockedError` | Governor blocked the action |
| `ReviewRejectedError` | Human reviewer rejected |
| `ReviewExpiredError` | Review timed out |
| `VerificationError` | Post-execution violation |
| `ReviewNotEnforcedWarning` | Warning: a `"review"` decision returned without waiting (`review_mode="proceed"`) |

## Requirements

- Python ≥ 3.9
- [httpx](https://www.python-httpx.org/) ≥ 0.24.0

## Links

- Documentation: https://app.airg.nov-tia.com/docs
- Developer site: https://developers.airg.nov-tia.com/
- TypeScript SDK: [`@novtia-npm/airg-client` on npm](https://www.npmjs.com/package/@novtia-npm/airg-client)

## License

MIT © 2026 NOVTIA LTD. The full text is in the `LICENSE` file included in the package.
