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.net → 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
- Sign in at https://policymesh.net
- Go to API Keys in the sidebar
- Click Generate Key
- 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.4.0.tar.gz
(10.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file policymesh-0.4.0.tar.gz.
File metadata
- Download URL: policymesh-0.4.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cddeafb57240a38a6e7612e25625175a94732b6fed62de1ff436df6f5526ba2
|
|
| MD5 |
a3b128c956f52773f2ae5eb10e025885
|
|
| BLAKE2b-256 |
7c377cc5adea4315833ab97d9ea07b47202c4306f9c845e42e54090510726f65
|
File details
Details for the file policymesh-0.4.0-py3-none-any.whl.
File metadata
- Download URL: policymesh-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e83167654784d08b9458c79fc510cfffeb57ee538a68efe5e1e7b4a9d67344f
|
|
| MD5 |
f94a737ca42dc9eb67963aed1034e704
|
|
| BLAKE2b-256 |
d22b05a895d47cc688d2f56f79ef2743ddfbb7c39738d37cd598ef6d5068ba6c
|