Skip to main content

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

pip install airg-client

Quick start

from airg import AIRG

client = AIRG()

decision = client.evaluate(
    tool="shell_exec",
    args={"command": "ls -la /tmp"},
    context={"session_id": "abc-123"},
)
print(decision["decision"])      # "allow" | "review"
print(decision["risk_score"])    # 0.0 – 1.0
print(decision["explanation"])

Configuration

Environment variable Description
GOVERNOR_URL Base URL of the Governor service
GOVERNOR_API_KEY API key (airg_…)

Or pass them explicitly:

client = AIRG(api_key="airg_...", base_url="https://...")

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:

{
    "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.

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 ≥ 0.24.0

License

MIT — see LICENSE.

Metadata

Release files for airg-client 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for airg-client 0.4.0
File Size Uploaded Provenance Actions
airg_client-0.4.0.tar.gz 6.6 kB Without provenance Details for airg_client-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for airg-client 0.4.0
File Interpreter ABI Platform Actions
airg_client-0.4.0-py3-none-any.whl Python 3 none any Details for airg_client-0.4.0-py3-none-any.whl

Total release size: 14.5 kB

Release files / airg_client-0.4.0.tar.gz

Download URL airg_client-0.4.0.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
418b4961a2bcd04515856baf48275c7281730cfcc16a6cb839e67ce9ea3bbcc4
BLAKE2b-256 checksum
How to use checksums
a87d0b98ce2b50b5d1d2cf487a626b1a593a5fce47bd5e4be0400c9b718019a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / airg_client-0.4.0-py3-none-any.whl

Download URL airg_client-0.4.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0059e3d5412eb4e3219e0f98371fb7c9bd6c0fc6bae3a8e5817a0c692b1bf8c5
BLAKE2b-256 checksum
How to use checksums
9f7be8e659bb5435cb5cdc0eada5d01170e0d0ac09ae5e2683a7618b46925bd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for airg-client 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page