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.0.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.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: open_agent_id-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 07206dfd5011301501aa9118079d2734082ab26ab9be450bf8c31076210197c5
MD5 2a28daa9836c1c94cef7a88e9d1ca3d6
BLAKE2b-256 0e718ca6c36154b2da4e1d753cdeb18fdbef9298bc893947d492f7398c4ce119

See more details on using hashes here.

File details

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

File metadata

  • Download URL: open_agent_id-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bf9e259aca5ce48dbb13f9fcecb2ef93434996369d6d6ed9278a60b32468aa2
MD5 4f53b9b4064afd32f1f31497ffbcf686
BLAKE2b-256 27a535782cdb58c85cd336b5ce96bff24280da4db722c9f4c891bf2138decbbc

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