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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf8dfb9718c2465ea8820d03597034f00b45a3b79276c384224e2c0ff0ab4d2
|
|
| MD5 |
c787bea8156d77479bd1c774299e71b5
|
|
| BLAKE2b-256 |
e145f6609971baae0334b67e25abb9cc8f17e56b2e52ee394639cf997f57377d
|
Provenance
The following attestation bundles were made for agentcreds-0.1.0-cp38-abi3-win_amd64.whl:
Publisher:
release-python.yml on agentcreds/agentcreds
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentcreds-0.1.0-cp38-abi3-win_amd64.whl -
Subject digest:
dcf8dfb9718c2465ea8820d03597034f00b45a3b79276c384224e2c0ff0ab4d2 - Sigstore transparency entry: 2754458331
- Sigstore integration time:
-
Permalink:
agentcreds/agentcreds@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/agentcreds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7256baab27cccc2c03ddc6daad2cb7f731ab9f5b41e514c8222726e080302f8
|
|
| MD5 |
b4ab135f9d1bd008dd382558280a6d53
|
|
| BLAKE2b-256 |
d298fec7deb4948dbeae5decdfbe50280ef2563ff6f0666fe4c17f3929a8b053
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentcreds-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
f7256baab27cccc2c03ddc6daad2cb7f731ab9f5b41e514c8222726e080302f8 - Sigstore transparency entry: 2754458323
- Sigstore integration time:
-
Permalink:
agentcreds/agentcreds@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/agentcreds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60a3e2fd32b63bcc2f3607acb71f333b9cb69058405871b407ea744e4fd0cd53
|
|
| MD5 |
421c67630fd9c80d62e6552287543059
|
|
| BLAKE2b-256 |
d5aa4862997bf9c311d04e72ae3b1453af8653c2ec2d40f437e3e4d98bb916e5
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentcreds-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
60a3e2fd32b63bcc2f3607acb71f333b9cb69058405871b407ea744e4fd0cd53 - Sigstore transparency entry: 2754458320
- Sigstore integration time:
-
Permalink:
agentcreds/agentcreds@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/agentcreds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Trigger Event:
push
-
Statement type:
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
- Download URL: agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f04edcd1a3e6b931792eb110b0a284906ed40a9a6938c51811f3ac0b5b27b1
|
|
| MD5 |
9dd3e443e3eab465351ced592c50420c
|
|
| BLAKE2b-256 |
26a92dac2de9f701b8e823864b0fae1178cc2e1f6839c99270ba04236cd98c70
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentcreds-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
a7f04edcd1a3e6b931792eb110b0a284906ed40a9a6938c51811f3ac0b5b27b1 - Sigstore transparency entry: 2754458327
- Sigstore integration time:
-
Permalink:
agentcreds/agentcreds@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/agentcreds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@e4c47958fad0fecfe9d5e762736022cf1a6c49d4 -
Trigger Event:
push
-
Statement type: