Skip to main content

Python SDK for Open Agent ID — register, sign, and verify AI agent identities

Project description

open-agent-id

Python SDK for Open Agent ID -- sign and verify AI agent identities using the V2 protocol.

Installation

pip install open-agent-id

Or for development:

pip install -e ".[dev]"

Quick start

Create an Agent and sign an HTTP request

from agent_id import Agent, sign_http_request, verify_http_signature

# Load an agent from a private key
agent = Agent(
    did="did:oaid:base:0x1234567890abcdef1234567890abcdef12345678",
    private_key=b"...",  # 32-byte Ed25519 seed
)

# Sign an HTTP request (oaid-http/v1 domain)
headers = sign_http_request(
    agent.private_key,
    method="POST",
    url="https://api.example.com/v1/tasks",
    body=b'{"task":"search"}',
)
# headers: X-Agent-Timestamp, X-Agent-Nonce, X-Agent-Signature

Sign a message (agent-to-agent)

from agent_id import sign_message, verify_message_signature

# Sign a P2P message (oaid-msg/v1 domain)
signature = sign_message(
    private_key,
    msg_type="request",
    msg_id="msg-001",
    from_did="did:oaid:base:0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    to_dids=["did:oaid:base:0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],
    ref=None,
    timestamp=None,  # auto-generated
    expires_at=None,
    body={"task": "summarize", "url": "https://example.com"},
)

Async signing with the Signer daemon

from agent_id import sign_http_request_async, sign_message_async, Signer

signer = Signer(socket_path="/tmp/oaid-signer.sock")

# Async HTTP request signing
headers = await sign_http_request_async(
    signer, method="GET", url="https://api.example.com/data", body=None, key_id="key-1"
)

# Async message signing
sig = await sign_message_async(
    signer, msg_type="request", msg_id="msg-002",
    from_did="did:oaid:base:0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    to_dids=["did:oaid:base:0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],
    ref=None, timestamp=None, expires_at=None, body={"hello": "world"}, key_id="key-1",
)

DID utilities

from agent_id import validate_did, parse_did, format_did

validate_did("did:oaid:base-sepolia:0x1234567890abcdef1234567890abcdef12345678")  # True

method, chain, address = parse_did("did:oaid:base:0x1234567890abcdef1234567890abcdef12345678")
# ("oaid", "base", "0x1234...")

did = format_did("base", "0x1234567890abcdef1234567890abcdef12345678")

Registry client

from agent_id import RegistryClient

client = RegistryClient()  # defaults to https://api.openagentid.org

Running tests

pip install -e ".[dev]"
pytest

License

Apache 2.0 -- see LICENSE.

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

open_agent_id-0.2.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

open_agent_id-0.2.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file open_agent_id-0.2.1.tar.gz.

File metadata

  • Download URL: open_agent_id-0.2.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for open_agent_id-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d5f2815408c891f4f685f83f3599dc7ae5c44f658527c9ed762820e521e294f5
MD5 4d1440be909b959b1235e42842f10f39
BLAKE2b-256 8b412768853d541949ed755086bcf6ad84b596ad9fd8a2b8ce2e9ceb0f907220

See more details on using hashes here.

File details

Details for the file open_agent_id-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: open_agent_id-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for open_agent_id-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a3060621167388d284a1775d234763a157b576947d3eb7432cff8f98de2f2ae
MD5 f3b250b40c30228ceb928aa4db46c6de
BLAKE2b-256 9ee70b312864acdd96a5d97174598e6af129b3887da7abf8fdfde19888596d2a

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