Skip to main content

Official Python SDK for Attestify OS — governed agent execution in a few lines.

Project description

attestify-sdk — Python

Add governed agent 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_agent(
    input="Summarise the latest advances in quantum error correction.",
    agent_id="researcher-v2",
    session_id="my-session-001",
    options={"verify": True, "write_memory": True},
)

print(result.output)             # agent 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_agent(input, ...) — single call handles sessions, retries, idempotency
  • Typed receiptsRunReceipt and EvidenceBundle dataclasses with full field coverage
  • Auto-routing — omit agent_id and Attestify picks the best agent 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://attestify-os.vercel.app Override the endpoint
max_retries int 2 Retries on transient 5xx errors
timeout_s float 60.0 Per-attempt timeout in seconds

client.run_agent(input, ...)

Parameter Type Description
input str Required. The task or intent
agent_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 agent
constraints dict Budget / SLA constraints (see below)
options dict Runtime flags (see below)

Returns RunAgentResult(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.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
agent_id str Agent that handled the run
output str Agent 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 agents

agent_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 agent_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_agent,
        input="Analyse Q2 revenue trends",
        agent_id="analyst-v1",
    )
    print(result.output)

asyncio.run(main())

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

attestify_sdk-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

attestify_sdk-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file attestify_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: attestify_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for attestify_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ebb0adeffc35802ef048f7a320ff159e7b1c792e7acd08b257457becf66f3dbc
MD5 8a5725db8b1dfa9c2095b60c6f7598a8
BLAKE2b-256 f94be47f8078f3fc49db4e6c1b6dcfa19c07ea3ee7a4cc1f3a02280677c6bd3b

See more details on using hashes here.

File details

Details for the file attestify_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: attestify_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for attestify_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8804d8cb32900e3736381c4824e957245a58f8b7c6b7e0fc8822c206de2ef5cc
MD5 3260be30bbb6ffe33b9810b4ea24895f
BLAKE2b-256 417e73657e56e956fed52f31d93a45ee41f059a78f6183c094f1e66111ed72ba

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