Skip to main content

Authevo Python SDK

Official Python SDK for Authevo - Cryptographically verifiable agent actions with policy enforcement.

PyPI version Downloads Python 3.8+

Features

  • ✅ Cryptographic Signatures: Ed25519 signatures for every action
  • ✅ Policy Enforcement: OPA integration for runtime policy evaluation
  • ✅ Automatic Retries: Exponential backoff on transient failures
  • ✅ Idempotency: Built-in idempotency key generation
  • ✅ Framework Integrations: LangChain and CrewAI support
  • ✅ Async/Await: Full async support for high performance
  • ✅ Type Safe: Comprehensive type hints

Installation

pip install authevo

Optional Dependencies

# LangChain integration
pip install authevo[langchain]

# CrewAI integration
pip install authevo[crewai]

# All integrations
pip install authevo[all]

# Development dependencies
pip install authevo[dev]

Quick Start

import asyncio
from authevo import AuthevoAgent

async def main():
    # Generate a new agent
    async with AuthevoAgent.generate() as agent:
        print(f"Agent DID: {agent.keypair.did}")
        
        # Register with the API
        await agent.register(name="My Agent")
        
        # Execute a verifiable action
        result = await agent.execute_action(
            action="refund",
            payload={"orderId": "123", "amount": 50}
        )
        
        print(f"Action submitted: {result['id']}")
        print(f"Policy decision: {result['policyDecision']['decision']}")

asyncio.run(main())

Configuration

Configure the SDK via environment variables or code:

Environment Variables

export AUTHEVO_API_URL="https://api.authevo.com"
export AUTHEVO_API_KEY="authevo_..."
export AUTHEVO_TIMEOUT=30
export AUTHEVO_MAX_RETRIES=3

Programmatic Configuration

from authevo import AuthevoAgent, AuthevoConfig

config = AuthevoConfig(
    api_url="https://api.authevo.com",
    api_key="authevo_...",
    timeout=30,
    max_retries=3
)

agent = AuthevoAgent.generate(config=config)

Framework Integrations

LangChain

from authevo import AuthevoAgent
from authevo.langchain import VerifiableTool
from langchain.agents import initialize_agent
from langchain.llms import OpenAI

# Create Authevo agent
agent = AuthevoAgent.generate()

# Wrap as LangChain tool
refund_tool = VerifiableTool(
    name="process_refund",
    description="Process customer refund with policy enforcement",
    authevo_agent=agent,
    action="refund"
)

# Use with LangChain
llm = OpenAI(temperature=0)
langchain_agent = initialize_agent(
    tools=[refund_tool],
    llm=llm,
    agent="zero-shot-react-description"
)

result = langchain_agent.run("Process a refund for order-123, amount $50")

CrewAI

from authevo import AuthevoAgent
from authevo.crewai import verifiable_task

agent = AuthevoAgent.generate()

@verifiable_task(agent=agent, action="refund")
def process_refund(order_id: str, amount: float):
    # Your refund logic here
    return {"status": "refunded", "amount": amount}

# Function automatically verifies before execution
result = process_refund("order-456", 75.0)

Error Handling

The SDK provides specific exceptions for different error scenarios:

from authevo import (
    AuthevoAgent,
    PolicyDeniedError,
    AuthenticationError,
    RateLimitError,
    NetworkError
)

async with AuthevoAgent.generate() as agent:
    try:
        result = await agent.execute_action(
            action="refund",
            payload={"orderId": "123", "amount": 500}
        )
    except PolicyDeniedError as e:
        print(f"Action denied by policy: {e.reason}")
        print(f"Policy ID: {e.policy_id}")
    except AuthenticationError:
        print("Invalid API key")
    except RateLimitError as e:
        print(f"Rate limited. Retry after {e.retry_after}s")
    except NetworkError as e:
        print(f"Network error: {e}")

Automatic Retries

The SDK automatically retries on transient failures with exponential backoff:

# Default: 3 retries with 2s base delay
# Attempt 1: immediate
# Attempt 2: wait 2s
# Attempt 3: wait 4s
# Attempt 4: wait 8s

# Customize retry behavior
config = AuthevoConfig(
    api_url="https://api.authevo.com",
    max_retries=5  # Up to 5 retry attempts
)

Examples

See the examples/ directory for more:

Documentation

Development

# Install in development mode
pip install -e .[dev]

# Run tests
pytest

# Format code
black authevo/ tests/

# Type checking
mypy authevo/

License

MIT - See LICENSE for details.

Support

Metadata

Release files for authevo 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for authevo 1.1.0
File Size Uploaded
authevo-1.1.0.tar.gz 26.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for authevo 1.1.0
File Interpreter ABI Platform
authevo-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.8 kB

Release files / authevo-1.1.0.tar.gz

Download URL authevo-1.1.0.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
169aa5aab98224a48784acb73eef80c862cbdedd382c8c388c79534f7ebefa41
BLAKE2b-256 checksum
How to use checksums
74de679c14877af69a4b89067e50f0424a8c309314cb3ab4000d15ded7fd6bc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / authevo-1.1.0-py3-none-any.whl

Download URL authevo-1.1.0-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7648bafd60e2030f0369aa27d51257d61c47059783153f3f3aec615bbf295ef3
BLAKE2b-256 checksum
How to use checksums
7f7bb4cab4c10d3668974ae012a9ca7dc05d29bee7d62e11f0d70b94d11d5f0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page