Skip to main content

agentcreds (Python)

Python bindings for AgentCreds - verifiable, attenuable delegation for autonomous AI agents, verified offline.

These bindings wrap the agentcreds-core Rust engine via PyO3/maturin.

A note on async

Every operation in this SDK is synchronous - there is no async/await anywhere in this API. The underlying Rust operations (DID generation, credential issuance/verification, token minting/attenuation/verification, revocation checks) all complete in well under a millisecond, so wrapping them in coroutines would add overhead without benefit. This is a deliberate deviation from async-styled quickstarts you may see elsewhere in the AgentCreds docs.

Installation

pip install agentcreds

(or, building from source: maturin build --release / maturin develop)

Quick start

import agentcreds as ac

# 1. Org trust anchor (in production: keys live in an HSM)
anchor = ac.TrustAnchor.generate()

# 2. Agent enrolled at deploy time
agent = ac.AgentIdentity.create_did_key()

# 3. Issue a capability credential
claims = ac.CapabilityClaims(
    tools=["tool:search", "tool:email"],
    max_delegation_depth=3,
    valid_for_secs=3600,  # valid for 1 hour
)
vc = ac.CapabilityCredential.issue(anchor, agent.did, claims)

# 4. Mint a short-lived runtime token (valid 5 minutes)
scope = ac.Scope(tools=["tool:search"], budget_usd=100, max_depth=2)
token = ac.DelegationToken.mint(vc, scope, 300, agent)

# 5. Verify at every tool call boundary (<1ms)
action = ac.Action("tool:search", "q=agentcreds")
token.verify(action)

# 6. Delegate to a sub-agent (scope can only narrow)
sub_agent = ac.AgentIdentity.create_did_key()
narrow = ac.Scope(tools=["tool:search"], budget_usd=10, max_depth=1)
child_token = token.attenuate(narrow, 60, sub_agent)

Cross-org verification

import agentcreds as ac

# Org B registers Org A's trust anchor (resolved from a TRAIL registry in production)
registry = ac.TrustRegistry()
registry.register(ac.TrustEntry(
    org_a_anchor.did,
    "Organization A",
    org_a_anchor.public_key,
    "verified",
))

# Verify Org A's credential WITHOUT calling back to Org A
entry = registry.verify_credential(vc_from_org_a)
print(f"Verified by {entry.org_name} ({entry.trust_level})")

Revocation

import agentcreds as ac

# Create an OAuth Token Status List (131,072 entries by default)
revocation_list = ac.RevocationList("https://registry.example.com/status/1", anchor)

# Revoke credential at index 42 (propagates in <30s in production)
revocation_list.revoke(42, anchor)

# Check revocation status (<0.1ms, no network call)
assert revocation_list.is_revoked(42)

Error handling

All errors raised by this SDK derive from agentcreds.AgentCredsError:

import agentcreds as ac

try:
    token.verify(ac.Action("tool:delete-everything", ""))
except ac.ActionDeniedError as e:
    print(f"denied: {e}")
except ac.TokenExpiredError as e:
    print(f"expired: {e}")
except ac.AgentCredsError as e:
    print(f"other agentcreds error: {e}")
Exception Raised when
DidError DID resolution, signature, or key-material problems
CredentialError Malformed claims, issuer mismatch, invalid proof
CredentialExpiredError A credential's expiration_date has passed
CredentialRevokedError A credential's index is set in a revocation list
DelegationError Token chain integrity / depth-limit problems
ScopeWideningError An attenuation attempt would widen scope
TokenExpiredError A delegation token (or one of its blocks) has expired
ActionDeniedError The requested tool is not in the leaf block's scope
RevocationError Revocation list index out of bounds / bad signature
SerializationError JSON / CBOR / base64 (de)serialization failure
ValidationError A field value is missing or out of bounds

Type stubs

A agentcreds.pyi stub ships with this package for editor/IDE autocomplete and static type checking (mypy/pyright).

Building

maturin build --release
cargo test --manifest-path ../agentcreds-core/Cargo.toml

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

agentcreds-0.1.0-cp38-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.8+Windows x86-64

agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.2 MB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file agentcreds-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: agentcreds-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agentcreds-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dcf8dfb9718c2465ea8820d03597034f00b45a3b79276c384224e2c0ff0ab4d2
MD5 c787bea8156d77479bd1c774299e71b5
BLAKE2b-256 e145f6609971baae0334b67e25abb9cc8f17e56b2e52ee394639cf997f57377d

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentcreds-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: release-python.yml on agentcreds/agentcreds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7256baab27cccc2c03ddc6daad2cb7f731ab9f5b41e514c8222726e080302f8
MD5 b4ab135f9d1bd008dd382558280a6d53
BLAKE2b-256 d298fec7deb4948dbeae5decdfbe50280ef2563ff6f0666fe4c17f3929a8b053

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yml on agentcreds/agentcreds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 60a3e2fd32b63bcc2f3607acb71f333b9cb69058405871b407ea744e4fd0cd53
MD5 421c67630fd9c80d62e6552287543059
BLAKE2b-256 d5aa4862997bf9c311d04e72ae3b1453af8653c2ec2d40f437e3e4d98bb916e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-python.yml on agentcreds/agentcreds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 a7f04edcd1a3e6b931792eb110b0a284906ed40a9a6938c51811f3ac0b5b27b1
MD5 9dd3e443e3eab465351ced592c50420c
BLAKE2b-256 26a92dac2de9f701b8e823864b0fae1178cc2e1f6839c99270ba04236cd98c70

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release-python.yml on agentcreds/agentcreds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 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