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

from governor_client import evaluate_action, GovernorBlockedError
import governor_client

# Set your API key (or export GOVERNOR_API_KEY in your environment)
governor_client.GOVERNOR_API_KEY = "airg_your_key_here"
governor_client.GOVERNOR_URL = "https://ai-runtime-governor.fly.dev"

# Evaluate a tool call against the Governor
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 set them programmatically:

import governor_client

governor_client.GOVERNOR_URL = "https://ai-runtime-governor.fly.dev"
governor_client.GOVERNOR_API_KEY = "airg_your_key_here"

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.0.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.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: airg_client-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2cd7ed1b822f5cb7a2bec1b9417a83c86ce9b08ab5aeb7a51e557e3be3407122
MD5 df40f4c92fd72d28f9d5f496d7ae6f4b
BLAKE2b-256 b7535263f2621fa167248a1674d8d49c7cf2e7a4aeaf90f275c5c16bed072e49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: airg_client-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0ce963651353e0bf03ed0bdf366f40857d459109c8aff67ff4f33363ae91eb5
MD5 73dab9b87def66ece7659f5d129e8c38
BLAKE2b-256 645161036b81f94137de9de5b229e93bac7a6ed58ba9b7f08b5c8a02a5c39480

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