Skip to main content

Governance Engine by zeb labs

Project description

Z-GRC - Z Governance, Risk, Control Engine

Python Version Code Style: Ruff PyPI version PyPI Downloads

Enterprise-grade governance engine for Large Language Model applications. Provides automatic interception, policy enforcement, quota management, and comprehensive observability across multiple LLM providers with zero code changes.

Installation

uv add z-grc

Or with auto-instrumentation:

uv add z-grc[auto-instrument]

Quick Start

import zgrc
import boto3
import json

# Initialize GRC
zgrc.init(api_key="your-zgrc-api-key")

# Use your LLM SDK normally - GRC handles everything
client = boto3.client("bedrock-runtime", region_name="us-east-1")

response = client.invoke_model(
    modelId="us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    body=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 1024,
        "messages": [{"role": "user", "content": "Hello!"}]
    })
)

# Z-GRC automatically:
# - Validates quota before requests
# - Tracks token usage
# - Enforces policies
# - Sends telemetry (traces, metrics, logs)

Features

Zero-Code Integration

Drop-in solution requiring only zgrc.init(). Works with existing code without modifications.

Auto-Discovery

Automatically detects and intercepts installed LLM SDKs:

  • AWS Bedrock (boto3)
  • Anthropic (coming soon)
  • OpenAI (coming soon)
  • Azure OpenAI (coming soon)

Policy Enforcement

Real-time quota validation and token limit enforcement. Blocks requests when quota is exceeded.

from zgrc.utils import QuotaExceededException

try:
    response = client.invoke_model(...)
except QuotaExceededException as e:
    print(f"Quota exceeded: {e.used}/{e.limit} tokens")

Auto-Instrumentation

Optional automatic instrumentation for HTTP clients, web frameworks, databases, and more:

zgrc.init(
    api_key="your-zgrc-api-key",
    auto_instrument=True,
    app_name="my-app",
    environment="production"
)

Framework Agnostic

Works with vanilla SDKs and popular frameworks:

# PydanticAI
from pydantic_ai import Agent
agent = Agent("bedrock")
result = await agent.run("Your prompt")

# LangChain
from langchain_aws import ChatBedrock
llm = ChatBedrock(model_id="...")
response = llm.invoke("Your prompt")

# Strands Agents
from strands_agents import Agent
agent = Agent(provider="bedrock")
response = agent.execute("Your prompt")

Streaming Support

Fully supports streaming responses with automatic token tracking:

response = client.converse_stream(
    modelId="...",
    messages=[{"role": "user", "content": [{"text": "Tell me a story"}]}]
)

for event in response["stream"]:
    if "contentBlockDelta" in event:
        print(event["contentBlockDelta"]["delta"]["text"], end="")

Configuration

zgrc.init(
    api_key: str,                  # Your Z-GRC API key (required)
    auto_instrument: bool = False, # Enable auto-instrumentation
    app_name: str = None,          # Application name for telemetry
    environment: str = None,       # Environment (dev/staging/prod)
    log_level: int = logging.ERROR # Z-GRC internal log level
)

Building Executables

Build standalone executables with PyInstaller:

macOS/Linux

./build.sh

Output: dist/z-grc-proxy-macos-arm64 or dist/z-grc-proxy-linux-x86_64

Windows

build.bat

Output: dist/z-grc-proxy-windows-x64.exe

Test Executable

# macOS/Linux
./dist/z-grc-proxy-macos-arm64 --api-key=zgrc_xxx

# Windows
dist\z-grc-proxy-windows-x64.exe --api-key=zgrc_xxx

Note: Certificates auto-generate in ~/.mitmproxy/ on first run. Users must set HTTPS_PROXY and NODE_EXTRA_CA_CERTS environment variables.

Installing Executor

macOS / Linux

curl -fsSL https://raw.githubusercontent.com/zeb-ai/z-grc/main/install.sh | bash

Windows (PowerShell)

irm https://raw.githubusercontent.com/zeb-ai/z-grc/main/install.ps1 | iex

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

z_grc-0.0.14.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

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

z_grc-0.0.14-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file z_grc-0.0.14.tar.gz.

File metadata

  • Download URL: z_grc-0.0.14.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for z_grc-0.0.14.tar.gz
Algorithm Hash digest
SHA256 1bffb0a4cf2433cf046499b338b14de424c93e9d720307bbfcb718354342e26a
MD5 cbce18b770300c98be00f120a25458ac
BLAKE2b-256 b5bce0c101aa465842f2ca091163226063f9f76bc0803acd8300d6b9b25519ca

See more details on using hashes here.

File details

Details for the file z_grc-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: z_grc-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for z_grc-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 fc5ebd4c8e6da33e5b902d2b8bc9519b51e60a3bb5a5f6c3e55ee066ea0071ad
MD5 33e5bd2cd8dd6f8eee7f257e5e5b1b97
BLAKE2b-256 ca03397ca2c04bde461915d70085f76f159e0c7af75ceca32ded612afa1e52ff

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