Skip to main content

Official Python client for the Ardyn Liability Verification Substrate API

Project description

Ardyn Python SDK

Official Python client for the Ardyn Liability Verification Substrate API.

Installation

pip install ardyn

Quick Start

New customer? Create your account self-service — no Ardyn involvement required. See Self-Service Onboarding below to obtain your API key, then use it here.

import asyncio
from ardyn import ArdynClient

async def main():
    async with ArdynClient(
        gateway_url="https://api.ardyn.ai",
        api_key="your-api-key",   # obtained from self-service onboarding (see below)
    ) as client:
        # Register an agent on AMD SEV-SNP hardware (production path)
        agent = await client.register_agent(
            platform="amd_sev_snp",
            capabilities=["sev_snp_report"],
            public_key="your-ed25519-public-key-hex",
        )
        print(f"Agent ID: {agent.agent_id}")

        # Activate the agent — self-service, no Ardyn approval required
        activated = await client.activate_agent(agent.agent_id)
        print(f"Agent status: {activated.status}")  # -> Active

        # Create an attestation (issues a DDC)
        attestation = await client.attest(
            tool_name="web_search",
            input_hash="sha256:abc123...",
            output_hash="sha256:def456...",
        )
        print(f"Attestation ID: {attestation.attestation_id}")
        print(f"DDC ID: {attestation.ddc_id}")

        # Verify a DDC (convenience — trusts the gateway)
        result = await client.verify(attestation.ddc_id)
        print(f"Valid: {result.valid}")

        # Trustless verify: re-derive the verdict from raw evidence
        # Requires the raw hardware report bytes — no trust in Ardyn.
        # Use the standalone ardyn-verify CLI:
        #   ardyn-verify --input ddc_response.json --allowlist allowlist.json

asyncio.run(main())

Trustless Verification

The gateway's verify() is a convenience — it trusts the gateway. For cryptographic certainty, use the standalone ardyn-verify CLI, which re-derives every claim from raw hardware evidence:

# Install the verifier (Rust binary)
cargo install ardyn-verify

# Verify a DDC offline — zero trust in Ardyn or any remote service
ardyn-verify --input ddc.json

# AMD SEV-SNP: trustless hardware re-verification with measurement allowlist
ardyn-verify --input ddc.json --allowlist measurements.json

# NVIDIA GPU CC: trustless GPU attestation re-verification
ardyn-verify --input ddc.json --nvidia-rim rim.json

The verifier checks:

  • Issuer Ed25519 signature (pins the embedded public key)
  • Schema version and provenance gate
  • Hardware report re-verification (VCEK chain for AMD, device cert chain for NVIDIA)
  • Measurement allowlist match
  • Coherence score recomputation

Where verification happens:

Path Trust Model Use Case
client.verify(ddc_id) Trusts gateway Quick check
ardyn-verify --input Zero-trust local Audit, compliance, court-admissible
ardyn-verify --allowlist Trustless hardware Prove execution on specific known-good code

## Self-Service Onboarding

Create your account and obtain an API key without contacting Ardyn. The gateway
exposes public self-service onboarding endpoints:

```bash
# 1. Register — starts onboarding, sends a verification email + 2FA setup
curl -X POST https://api.ardyn.ai/onboarding/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@company.com", "organization": "My Company", "plan": "pro"}'

# 2. Verify email (link in the email) and verify 2FA to activate the tenant
curl -X POST https://api.ardyn.ai/onboarding/verify-2fa \
  -H "Content-Type: application/json" \
  -d '{"tenant_id": "<from step 1>", "code": "<TOTP code>"}'
# -> returns your api_key (unless payment is required, in which case next_step="payment")

# 3. Check status any time
curl https://api.ardyn.ai/onboarding/status/<tenant_id>

The returned api_key is what you pass to ArdynClient(api_key=...). The admin-only register_tenant method exists for internal/operator use only and is not part of the customer onboarding path.

Features

  • Async-first: Built on httpx for modern async Python
  • Type-safe: Full type annotations and dataclass models
  • Auto-retry: Exponential backoff on transient failures (3 attempts: 1s, 2s, 4s)
  • Connection pooling: Efficient HTTP/2 connection reuse
  • Comprehensive errors: Typed exceptions for auth, not-found, validation, and server errors

API Reference

ArdynClient

ArdynClient(
    gateway_url: str,        # Base URL of the Ardyn gateway
    api_key: str,            # API key for authentication
    timeout: float = 30.0,   # Request timeout in seconds
    max_retries: int = 3,    # Max retry attempts
)

Methods

Method Description
register_tenant(name, config?) Internal/operator use only (admin route) — customers onboard via the self-service flow above
register_agent(platform, capabilities, public_key, manifest_signature?, cert_fingerprint?) Register an agent
activate_agent(agent_id) Activate your own agent (tenant self-service — no Ardyn approval)
heartbeat(agent_id, status, uptime_secs, attestations_performed, agent_instance_id?) Send agent heartbeat
attest(tool_name, input_hash, output_hash, metadata?) Create attestation
submit_proof(request_id, agent_id, proof_type, proof_data, timestamp, signature, input_hash?, output_hash?) Submit proof
verify(ddc_id) Verify a DDC
get_usage(tenant_id) Get usage statistics
get_settlement(tenant_id, period) Get settlement details
get_dashboard(tenant_id) Get dashboard data
health() Check gateway health

Error Types

  • ArdynError - Base exception
  • AuthError - Authentication failed (401/403)
  • NotFoundError - Resource not found (404)
  • ValidationError - Request validation failed (400/422)
  • ServerError - Server error (5xx)

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

License

MIT

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

ardyn-0.2.2.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

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

ardyn-0.2.2-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file ardyn-0.2.2.tar.gz.

File metadata

  • Download URL: ardyn-0.2.2.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ardyn-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4966abaee9a6f02a4e44fddf9eb24c974771eb276787ffb163f7f37a6089e0fd
MD5 95d088d27c71b34faeeed235f3dfd121
BLAKE2b-256 143b154759a9e0c727d30bec333e1464ea8a77062c62c504bf80629825d347b4

See more details on using hashes here.

File details

Details for the file ardyn-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: ardyn-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ardyn-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37769d3d88fe7ff59857798a504a9ab8698c350ee1deb6094cb3c237f9273963
MD5 6b2b563c3dbd37d86ec383934571b496
BLAKE2b-256 5c4eef0dfd35a9cb14750e8d8e6c4bb60b1ba98f5bcb69f29950c97d71384246

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