Skip to main content

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


Download files

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

Source Distribution

agentity_sdk_python-0.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

agentity_sdk_python-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file agentity_sdk_python-0.1.1.tar.gz.

File metadata

  • Download URL: agentity_sdk_python-0.1.1.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

Hashes for agentity_sdk_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ec5e981bbe267a70d4e60236ed5bc1390de932f453897eafa3f77fc391a37188
MD5 f4967414b76618042cea1fdec14da12a
BLAKE2b-256 b828a99be8ee4deb7d8808cf01db60ee71203d852bcd272c8ce8442e8916575e

See more details on using hashes here.

File details

Details for the file agentity_sdk_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agentity_sdk_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c221a25e6af228c2ae3d3d59d7bf1790db311d3dcdc1c994711740c8e1babb33
MD5 a1241c7f8e74bb12c46979ef03d634fb
BLAKE2b-256 56a741f531bd7675e48f411b679abaca78cf0a0422eee582158f069479f9b076

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