Forge Verify SDK — Verify AI agent decisions with cryptographic attestation
Project description
Forge Verify SDK for Python
Verify every AI agent action before execution. Cryptographic attestation. Sub-millisecond latency. Zero data access.
Install
pip install veritera
Complete Flow: Zero to Verified in 60 Seconds
from veritera import Forge
forge = Forge(api_key="vt_live_...") # Get your key at veritera.ai
# 1. Create a policy (do this once)
policy = forge.create_policy_sync(
name="finance-controls",
description="Block high-value transactions and dangerous operations",
rules=[
{"type": "action_whitelist", "params": {"allowed": ["payment.read", "payment.create", "balance.check"]}},
{"type": "amount_limit", "params": {"max": 10000, "currency": "USD"}},
{"type": "action_blacklist", "params": {"blocked": ["database.drop", "admin.override"]}},
],
)
print(f"Policy created: {policy.name} (ID: {policy.id})")
# 2. Verify an action
result = forge.verify_sync(
action="payment.create",
agent_id="finance-bot",
params={"amount": 500, "currency": "USD", "recipient": "vendor@acme.com"},
policy="finance-controls",
)
if result.verified:
print(f"Approved — proof: {result.proof_id}")
# Safe to execute the action
else:
print(f"Blocked — reason: {result.reason}")
# Do NOT execute
# 3. List your policies
for p in forge.list_policies_sync():
print(f" {p.name} (v{p.version}) — {len(p.rules)} rules")
# 4. Test a policy without executing
test = forge.test_policy_sync(
policy_id=policy.id,
action="database.drop",
params={"table": "users"},
)
print(f"Test: {test.verdict}") # "denied"
That's it. No GUI needed. No dashboard required. Everything from code.
Async Usage
import asyncio
from veritera import Forge
async def main():
async with Forge(api_key="vt_live_...") as forge:
policy = await forge.create_policy(
name="email-controls",
rules=[{"type": "rate_limit", "params": {"max_per_hour": 50}}],
)
result = await forge.verify_decision(
agent_id="support-bot",
action="send_email",
params={"to": "customer@example.com", "subject": "Your refund"},
policy="email-controls",
)
print("Approved" if result.verified else f"Blocked: {result.reason}")
asyncio.run(main())
Generate Policies from Natural Language
Don't want to write JSON rules? Describe what you want in plain English:
result = forge.generate_policy_sync(
"Only allow my agent to read files, send emails (max 50 per hour), "
"and check balances. Block all deletions and admin operations.",
save=True, # save it immediately
)
print(f"Created: {result['name']}")
print(f"Rules: {result['rules']}")
Use with Framework Integrations
The policy you create here works with all Forge framework packages:
# Create the policy once
forge.create_policy_sync("finance-controls", rules=[...])
# Then use it in any framework:
# OpenAI Agents SDK: forge_protect(tools, policy="finance-controls")
# LangGraph: ForgeVerifyMiddleware(policy="finance-controls")
# CrewAI: ForgeVerifyTool(policy="finance-controls")
# LlamaIndex: ForgeVerifyToolSpec(policy="finance-controls")
| Package | Install |
|---|---|
| forge-openai | pip install forge-openai |
| langchain-forge | pip install langchain-forge |
| crewai-forge | pip install crewai-forge |
| llama-index-tools-forge | pip install llama-index-tools-forge |
API Reference
Forge(api_key, **options)
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | Your API key (vt_live_... or vt_test_...) |
base_url |
str |
https://veritera.ai |
API base URL |
timeout |
float |
10.0 |
Request timeout (seconds) |
max_retries |
int |
2 |
Retries on 5xx errors |
fail_closed |
bool |
True |
Return denied instead of raising on errors |
debug |
bool |
False |
Enable debug logging |
Verification
| Method | Description |
|---|---|
verify_decision(agent_id, action, params, policy) |
Verify an action (async) |
verify_sync(action, agent_id, params, policy) |
Verify an action (sync) |
get_proof(proof_id) |
Retrieve a verification proof |
verify_proof_locally(attestation, payload, public_key) |
Verify Ed25519 attestation offline |
Policies
| Method | Description |
|---|---|
create_policy(name, rules, description) |
Create a new policy (async) |
create_policy_sync(name, rules, description) |
Create a new policy (sync) |
list_policies() / list_policies_sync() |
List all active policies |
get_policy(policy_id) / get_policy_sync(policy_id) |
Get a policy by ID |
update_policy(policy_id, name, rules, description) / update_policy_sync(...) |
Update a policy |
delete_policy(policy_id) / delete_policy_sync(policy_id) |
Deactivate a policy |
test_policy(policy_id, action, params) / test_policy_sync(...) |
Test a policy without persisting |
generate_policy(prompt, save) / generate_policy_sync(...) |
Generate policy from natural language |
get_policy_templates() |
Get all available policy templates |
Policy Rule Types
| Type | Description | Params |
|---|---|---|
action_whitelist |
Only allow specific actions | {"allowed": ["action1", "action2"]} |
action_blacklist |
Block specific actions | {"blocked": ["action1", "action2"]} |
amount_limit |
Cap transaction amounts | {"max": 10000, "currency": "USD"} |
rate_limit |
Limit action frequency | {"max_per_hour": 50} |
time_window |
Restrict to business hours | {"start": "09:00", "end": "17:00", "timezone": "US/Eastern"} |
require_confirmation |
Flag for human approval | {"actions": ["payment.create"]} |
recipient_constraint |
Control who agent can contact | {"allowed_domains": ["@company.com"]} |
resource_access |
Restrict file/resource access | {"denied_resources": [".env*", "*.key"]} |
custom |
Custom constraint logic | {...} |
Delegations
| Method | Description |
|---|---|
create_delegation(agent_id, allowed_actions, constraints, expires_in) |
Create a scoped delegation |
Account
| Method | Description |
|---|---|
get_usage(period) |
Get billing usage statistics |
health() |
Check API health |
Error Handling
from veritera import ForgeError, RateLimitError
try:
result = await forge.verify_decision(...)
except RateLimitError as e:
print(f"Rate limited — retry in {e.retry_after_ms}ms")
except ForgeError as e:
print(f"Error: {e.code} ({e.status}): {e}")
Fail-Closed (Default)
When fail_closed=True, network/server errors return a denied result instead of raising. Your agent is blocked, not crashed. This is the safe default.
Circuit Breaker
After 5 consecutive failures, the SDK opens a circuit breaker for 30 seconds. After 30s, one request is allowed through (half-open). On success, the circuit closes.
Requirements
- Python >= 3.9
- Dependencies:
httpx,cryptography
Get Your API Key
- Go to veritera.ai
- Sign up (free tier: 250 verifications)
- Copy your API key from the dashboard
- Set it:
export VERITERA_API_KEY=vt_live_...
License
MIT — Forge by Veritera AI
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
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 veritera-0.3.0.tar.gz.
File metadata
- Download URL: veritera-0.3.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c27c1f33541e466075c4ccd35c7198f8686457b5ced4b76f5f18bb60095f14
|
|
| MD5 |
863e98569e100d2c625eb7e0a844cce4
|
|
| BLAKE2b-256 |
756d09cc964f0aefb4876cc3d854261676f94116eda772d70d94e62391f4f9ca
|
File details
Details for the file veritera-0.3.0-py3-none-any.whl.
File metadata
- Download URL: veritera-0.3.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.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e2b69c93c7af4bd8ec0202d139cc5d0f69a8a2d04182d8412a561269aa1ff45
|
|
| MD5 |
b24a9188117b6e2853d2f4443a9c0649
|
|
| BLAKE2b-256 |
29f9cbb8bec6a100b3bd65edeec4e97acbad9f5cc8f230384fc288acb0e68abb
|