Skip to main content

attestify-sdk — Python

Add governed lane execution to any Python codebase in a few lines.

Install

pip install attestify-sdk

Or directly from the repo while the package is in early access:

pip install "git+https://github.com/attestifyagent/attestify-os.git#subdirectory=sdk/python"

Quick start

import os
from attestify import create_client

client = create_client(api_key=os.environ["ATTESTIFY_API_KEY"])

result = client.run_lane(
    input="Summarise the latest advances in quantum error correction.",
    lane_id="researcher-v2",
    session_id="my-session-001",
    options={"verify": True, "write_memory": True},
)

print(result.output)             # lane response text
print(result.receipt.run_id)     # unique run identifier
print(result.receipt.evidence)   # full EvidenceBundle dataclass
print(result.receipt.pricing)    # cost breakdown

Features

  • create_client(api_key) — configure once, use anywhere
  • client.run_lane(input, ...) — single call handles sessions, retries, idempotency
  • Typed receipts — RunReceipt and EvidenceBundle dataclasses with full field coverage
  • Auto-routing — omit lane_id and Attestify picks the best lane for the task
  • Idempotency — pass idempotency_key to guarantee exactly-once execution
  • Budget controls — pass constraints={"max_cost_usdc": 0.05} to cap spend per run
  • Webhook support — pass options={"webhook_url": "..."} for async delivery
  • Zero dependencies — stdlib only (urllib, json, uuid)

API Reference

create_client(api_key, base_url?, max_retries?, timeout_s?)

Parameter Type Default Description
api_key str required Your Attestify API key (ATTESTIFY_API_KEY)
base_url str https://attestifyos.com Override the endpoint
max_retries int 2 Retries on transient 5xx errors
timeout_s float 60.0 Per-attempt timeout in seconds

client.run_lane(input, ...)

Parameter Type Description
input str Required. The task or intent
lane_id str Optional — omit to auto-route
session_id str Memory / conversation continuity ID
idempotency_key str Prevents duplicate charges for the same key
context dict Freeform context forwarded to the lane
constraints dict Budget / SLA constraints (see below)
options dict Runtime flags (see below)

Returns RunLaneResult(output, receipt, raw).

constraints fields:

constraints={
    "max_cost_usdc": 0.05,    # abort if estimated cost exceeds this
    "max_latency_ms": 10000,  # abort if estimated latency exceeds this
    "budget_id": "proj-abc",  # link to a named budget envelope
}

options fields:

options={
    "verify": True,                    # run output verification (default False)
    "write_memory": True,              # persist session memory (default False)
    "include_memory": True,            # inject prior memory into context
    "webhook_url": "https://...",      # async result delivery
}

client.authorize(...) — authority envelopes

Request a signed, server-enforced authority envelope before running one or more governed actions. run_lane(envelope=...) attaches it; /api/run verifies the signature, tenant/agent binding, expiry, live-policy epoch, and remaining action count / spend cap before every run, and atomically consumes one action.

envelope = client.authorize(
    agent_id="analyst-v1",
    intent="batch-report-generation",
    risk_class="low",
    max_spend_usd=0.50,
    action_count=20,     # this envelope authorises up to 20 actions
    expiry_window_s=300, # capped at 3600s server-side
)

result = client.run_lane(
    lane_id="analyst-v1",
    input="Summarise Q2 revenue trends.",
    envelope=envelope,
)

The client caches non-Enterprise envelopes locally and reuses them until the action count or expiry window is exhausted. If the agent's policy has per_action_mode enabled, the server forces action_count=1 and expiry_window_s=0 and the SDK never caches the result — every action gets a fresh envelope. A stale envelope (policy changed since issue) is rejected with HTTP 409; call authorize() again to obtain a fresh one.

client.get_receipt(loop_id)

Fetch a stored receipt by its loop_id.

receipt = client.get_receipt("loop_abc123")
print(receipt.verification)   # grade, score, output_hash
print(receipt.settlement)     # on-chain tx hash if x402 used

Returns RunReceipt.


RunReceipt fields

Field Type Description
run_id str Unique run identifier
loop_id str Persistent loop/session receipt ID
lane_id str Lane that handled the run
lane_name str Human-readable lane name
output str Lane response text
paid bool Whether x402 payment was used
subscription_used bool Whether an API key subscription covered this run
evidence EvidenceBundle Full governance evidence bundle
verification dict | None Verification grade, score, output hash
pricing dict Cost breakdown in USDC
settlement dict | None On-chain settlement details
receipt_url str Shareable receipt permalink

Available lanes

lane_id Description
researcher-v2 Deep research and synthesis
analyst-v1 Data analysis and structured output
coder-v1 Code generation and review
writer-v1 Long-form and structured writing
strategist-v1 Strategic planning and frameworks
support-v1 Customer support and triage
comedian-v1 Creative and entertainment tasks

Omit lane_id entirely to let Attestify auto-route based on your input.

Environment variables

ATTESTIFY_API_KEY=atst_live_...

Async usage

The client is synchronous by design (zero dependencies). For async workflows:

import asyncio
from attestify import create_client

client = create_client(api_key=os.environ["ATTESTIFY_API_KEY"])

async def main():
    result = await asyncio.to_thread(
        client.run_lane,
        input="Analyse Q2 revenue trends",
        lane_id="analyst-v1",
    )
    print(result.output)

asyncio.run(main())

Metadata

Release files for attestify-sdk 0.1.7

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

Source distribution (sdist)

Source distribution for attestify-sdk 0.1.7
File Size Uploaded
attestify_sdk-0.1.7.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for attestify-sdk 0.1.7
File Interpreter ABI Platform
attestify_sdk-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / attestify_sdk-0.1.7.tar.gz

Download URL attestify_sdk-0.1.7.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c7b9d35015d81682eb27575097161526a70b13d883aeff50f9609af72dcc8a4c
BLAKE2b-256 checksum
How to use checksums
67dbd702b1a46f18e3204f080dc87ba238b4e5248e0274765de0a3244ff131a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / attestify_sdk-0.1.7-py3-none-any.whl

Download URL attestify_sdk-0.1.7-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c245c75a02ae68d9afd8ec40de9fb835234b01ea4096e78f365b0b9eea5d0cf
BLAKE2b-256 checksum
How to use checksums
bd6fc231b82621a055beb2fc0f7bdd6bd74d3fea1a10f8d266b464b526751e7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.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