Agentity Protocol Python SDK — identity, signer, LangChain integration
Project description
agentity-sdk-python
Python SDK for the Agentity Protocol. Create agent identities, sign HTTP requests, verify tokens, integrate with LangChain and CrewAI.
Installation
pip install agentity-sdk-python
Usage
Create an agent identity
from agentity_sdk import AgentKeyPair
kp = AgentKeyPair()
aid = kp.create_identity(
owner_did="did:agentity:human:alice",
scopes=["stripe:payments:read", "calendar:events:write"],
ttl_days=30,
)
print(f"DID: {aid.did}")
print(f"Signature valid: {aid.verify_signature()}")
Sign HTTP requests
from agentity_sdk import RequestSigner
signer = RequestSigner(kp, aid)
headers = signer.sign_request("GET", "/api/v1/payments")
# {
# "Agentity-Token": "<base64(AID)>.<base64(sig)>",
# "Agentity-Nonce": "<uuid-v4>",
# "Agentity-Timestamp": "<ISO-8601>",
# }
Verify on the server side
from agentity_sdk import RequestVerifier
verifier = RequestVerifier()
used_nonces = set()
aid = verifier.verify_request(
headers, "GET", "/api/v1/payments",
used_nonces=used_nonces,
)
Rotate keys
new_aid = kp.rotate(aid, ttl_days=90)
print(f"Version: {new_aid.version}") # 2
print(f"Previous AID: {new_aid.previousAid}")
LangChain integration
from agentity_sdk.integrations.langchain import AgentityLangChainMixin
class MyAgent(AgentityLangChainMixin):
def run(self):
headers = self._agentity_sign_headers("POST", "https://api.example.com/data")
print(f"Agent DID: {self.agentity_did()}")
Provider manifest
from agentity_sdk import ProviderManifest, ScopeEntry, ScopeRisk
manifest = ProviderManifest(
provider="did:agentity:provider:stripe",
name="Stripe",
description="Payment processing API",
scopes=[
ScopeEntry(id="payments:read", description="Read payments", risk=ScopeRisk.LOW),
ScopeEntry(id="payments:write", description="Create payments", risk=ScopeRisk.HIGH),
],
)
Public API
| Export | Description |
|---|---|
AgentKeyPair |
Ed25519 keypair + create_identity() + rotate() |
AgentIdentity |
Pydantic model — DID, scopes, proof, status |
AgentDid |
DID string builder |
RequestSigner |
Sign HTTP requests with Agentity headers |
RequestVerifier |
Verify tokens server-side |
ProviderManifest |
Publish service scope definitions |
AgentityLangChainMixin |
Mixin for LangChain agents |
Tests
pip install -e .[dev]
pytest tests/
License: Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 agentity_sdk_python-0.1.2.tar.gz.
File metadata
- Download URL: agentity_sdk_python-0.1.2.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6b90a464e73da22ab9233d4ffe69daeb07d5e89d6b13d41ae4e95eb50b20709
|
|
| MD5 |
92367e0990059f48f2d476066111530b
|
|
| BLAKE2b-256 |
532ca54b91ab5cab721c24e756ed3edbc98b5b2f68effbd30960357d2f67c9ae
|
File details
Details for the file agentity_sdk_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: agentity_sdk_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3803120572c116efb1a48a46ce7afffcbbae2939b3326973b0bf12c5289dc89
|
|
| MD5 |
885ad67582850826e1b6a3ef1e7e8945
|
|
| BLAKE2b-256 |
0a6138ac6657ac1d9fe8f7729e831ebf423f10c1f61d0e64b5bbf71a13a9a934
|