Skip to main content

Python client for the AI Runtime Governor – runtime AI-agent governance service

Project description

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

The client reads GOVERNOR_URL and GOVERNOR_API_KEY from environment variables automatically — just like the OpenAI SDK.

from governor_client import evaluate_action, GovernorBlockedError

try:
    decision = evaluate_action(
        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"])
except GovernorBlockedError as e:
    print(f"Blocked: {e}")

Configuration

Environment variable Default Description
GOVERNOR_URL http://localhost:8000 Base URL of the Governor service
GOVERNOR_API_KEY (empty) API key (airg_…) sent as X-API-Key header

You can also override them in code:

import governor_client

governor_client.GOVERNOR_URL = "..."
governor_client.GOVERNOR_API_KEY = "airg_..."

API

evaluate_action(tool, args, context=None) → dict

Send a tool call to the Governor for evaluation.

Returns the full decision dict:

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

Raises GovernorBlockedError if the decision is "block".

governed_call(tool, args, context=None) → dict

Convenience wrapper around evaluate_action. Identical behaviour — callers should inspect decision for "review" and handle accordingly.

GovernorBlockedError

Exception raised when the Governor blocks a tool invocation. Subclass of RuntimeError.

Requirements

  • Python ≥ 3.9
  • httpx ≥ 0.24.0

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airg_client-0.3.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airg_client-0.3.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file airg_client-0.3.1.tar.gz.

File metadata

  • Download URL: airg_client-0.3.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for airg_client-0.3.1.tar.gz
Algorithm Hash digest
SHA256 cf70767f48bf108db98021161a236a4da27f090e2c07de07bc641f03253fd71a
MD5 36950667f3b436488a91e094acdce7b3
BLAKE2b-256 7f9b381947e0d40e47e5a6ae01dc91ddf667ff7403ca3f066a66b40d8f9031d6

See more details on using hashes here.

File details

Details for the file airg_client-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: airg_client-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for airg_client-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 90ef3bcc5fa7255b9fc45acb689d703a086d82b94b2cdc54455f6e70d9937933
MD5 a3045de54022e3dfebd73e45d06c605a
BLAKE2b-256 ae10ecde0e8be871ae03f771d909223172b90902288978e6d34e4f4533543731

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page