Skip to main content

Forge Verify SDK — Verify AI agent decisions with cryptographic attestation

Project description

Forge Verify SDK for Python

PyPI License: MIT Python 3.9+

Verify every AI agent action before execution. Cryptographic attestation. Sub-15ms 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 forge.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://forge.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

  1. Go to veritera.ai
  2. Sign up (free tier: 250 verifications)
  3. Copy your API key from the dashboard
  4. 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

veritera-0.4.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

veritera-0.4.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file veritera-0.4.0.tar.gz.

File metadata

  • Download URL: veritera-0.4.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for veritera-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4411462202802ce76a8137f73e38438969342a5549eb511d1a933da1d8397456
MD5 aa00d91ea1a929fcdd91ce8b37d533f6
BLAKE2b-256 3473c95a0b7fd67721f748674e3290e1966198d690fe9d0048741000dbc4c6cd

See more details on using hashes here.

File details

Details for the file veritera-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: veritera-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for veritera-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6de67bac1036b110276d3cfd2271c4e9567d41f8606afd3b7d9667948c8a47d3
MD5 8199f69f491f383505d75fa1ba7b6a9d
BLAKE2b-256 c5a2a88f581fae3886863e6cd04619345e9f326c8f60710071af894820557d87

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