Skip to main content

Python SDK for the PolicyMesh AI Agent Control Platform

Project description

PolicyMesh Python SDK

The official Python SDK for the PolicyMesh AI Agent Control Platform.

Agents propose. PolicyMesh enforces.

Installation

pip install policymesh

Quick Start

from policymesh import PolicyMeshClient

# Initialize with your org ID and API key
# Get your API key at https://policymesh.vercel.app → API Keys
client = PolicyMeshClient(
    org_id="your_org_id",
    api_key="your_api_key"
)

# Evaluate an agent action
decision = client.evaluate(
    agent_id="my_agent",
    action_type="data_export",
    data_classification="confidential",
    record_count=1500,
    description="Exporting customer records to external email"
)

print(decision.decision)       # "block"
print(decision.policy_matched) # "Sensitive Data Export Block"
print(decision.is_blocked)     # True

Using the Guard Decorator

from policymesh import PolicyMeshClient

client = PolicyMeshClient(
    org_id="your_org_id",
    api_key="your_api_key"
)

@client.guard(action_type="production_deploy", environment="production")
def deploy_to_production():
    print("Deploying to production...")

deploy_to_production()

Simple Boolean Check

if client.allow(agent_id="my_agent", action_type="data_access"):
    pass

Handling Decisions

from policymesh import PolicyMeshClient, PolicyBlockedError, PolicyEscalateError

client = PolicyMeshClient(
    org_id="your_org_id",
    api_key="your_api_key"
)

try:
    decision = client.evaluate(
        agent_id="my_agent",
        action_type="production_deploy",
        environment="production"
    )
    if decision.is_flagged:
        print("Action flagged but allowed.")
except PolicyBlockedError as e:
    print(f"Action blocked: {e.policy_matched}")
except PolicyEscalateError as e:
    print(f"Action requires approval: {e.policy_matched}")

Action Types

Action Type Description
data_export Exporting data to external systems
data_access Accessing sensitive data
data_delete Deleting data
data_modify Modifying data
external_email Sending emails to external addresses
external_message Sending external messages
webhook_call Calling webhooks
production_deploy Deploying to production
code_execution Executing code
file_read Reading files
file_write Writing files
file_delete Deleting files
permission_change Modifying permissions
auth_change Changing authentication
api_key_create Creating API keys
payment Processing payments
vendor_action Vendor operations
external_api_call Calling external APIs
web_browse Browsing the web
web_scrape Scraping web content
database_query Querying databases
database_write Writing to databases
database_delete Deleting from databases
model_call Calling AI models
prompt_injection Detected prompt injection
custom Custom action types

Data Classifications

Classification Description
public Publicly available data
internal Internal company data
confidential Confidential business data
restricted Highly restricted or regulated data

Getting Your API Key

  1. Sign in at https://policymesh.vercel.app
  2. Go to API Keys in the sidebar
  3. Click Generate Key
  4. Copy and save your key — it is shown only once

Links

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

policymesh-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

policymesh-0.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file policymesh-0.2.0.tar.gz.

File metadata

  • Download URL: policymesh-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for policymesh-0.2.0.tar.gz
Algorithm Hash digest
SHA256 be84ba2ea62191040b64640fe22504971f0b3ca90c2453ae4164d02e7fd2ea39
MD5 ad2174517b96af6547e5eb21396c0b89
BLAKE2b-256 d1c5cacdc65bcb770d95f373374e858b404b640cab5eab67ceb3477204fecd20

See more details on using hashes here.

File details

Details for the file policymesh-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: policymesh-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for policymesh-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdd318849d2cc202f05c840879c052537a48aecb81a77b42f584f0fe3eedc010
MD5 39dafa17fd0c09a8f7534710d1af5eb2
BLAKE2b-256 5ed3f43878b547d55936e2afbd0f72839951f292884258242d4097efe7fa7af4

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