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
The most common use case is adding agent authentication headers to outbound requests:
from agent_id import sign_agent_auth
headers = sign_agent_auth(
"did:oaid:base:0x1234567890abcdef1234567890abcdef12345678",
private_key, # 32-byte Ed25519 seed
)
# Returns dict with:
# "X-Agent-DID": "did:oaid:base:0x1234..."
# "X-Agent-Timestamp": "1708123456"
# "X-Agent-Nonce": "a3f1b2c4d5e6f7089012abcd"
# "X-Agent-Signature": "<base64url signature>"
import httpx
resp = httpx.post("https://api.example.com/v1/tasks", headers=headers, json={"task": "search"})
Registry Client
from agent_id import RegistryClient
client = RegistryClient() # defaults to https://api.openagentid.org
All methods
| Method | Auth required | Description |
|---|---|---|
client.request_challenge(wallet_address) |
No | Request a wallet auth challenge |
client.verify_wallet(wallet_address, challenge_id, signature) |
No | Verify wallet signature, returns auth token |
client.register_agent(token, name, public_key, capabilities=None) |
Yes | Register a new agent |
client.get_agent(did) |
No | Look up an agent by DID |
client.list_agents(token, limit=20, cursor=None) |
Yes | List agents owned by the authenticated wallet |
client.update_agent(did, token=None, agent_signer=None, **updates) |
Yes | Update agent metadata |
client.revoke_agent(did, token) |
Yes | Revoke an agent identity |
client.rotate_key(did, token, public_key) |
Yes | Rotate an agent's public key |
client.deploy_wallet(did, token) |
Yes | Deploy an on-chain smart wallet for an agent |
client.get_credit(did) |
No | Look up an agent's credit score |
client.verify_signature(did, domain, payload, signature) |
No | Verify a signature against the agent's registered key |
Wallet auth flow
# 1. Request challenge
challenge = await client.request_challenge(wallet_address)
# 2. Sign the challenge text with your wallet (e.g. via web3.py)
# wallet_signature = ...
# 3. Verify and get auth token
token = await client.verify_wallet(wallet_address, challenge["challenge_id"], wallet_signature)
Register an agent
agent = await client.register_agent(
token,
name="my-agent",
public_key=base64url_public_key,
capabilities=["search", "summarize"],
)
Look up and list agents
info = await client.get_agent("did:oaid:base:0x1234...")
agents = await client.list_agents(token)
Manage agents
await client.update_agent(did, token=token, name="new-name")
await client.rotate_key(did, token, new_public_key)
await client.revoke_agent(did, token)
await client.deploy_wallet(did, token)
Credit Score
credit = await client.get_credit("did:oaid:base:0x1234567890abcdef1234567890abcdef12345678")
print(credit["credit_score"]) # 300
print(credit["level"]) # "verified"
HTTP Signing
Sign an HTTP request
from agent_id import sign_http_request, verify_http_signature
headers = sign_http_request(
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
Verify an HTTP signature
valid = verify_http_signature(
public_key, method="POST", url=url, body=body,
timestamp=timestamp, nonce=nonce, signature=signature,
)
Async signing with the Signer daemon
from agent_id import sign_http_request_async, Signer
signer = Signer(socket_path="/tmp/oaid-signer.sock")
headers = await sign_http_request_async(
signer, method="GET", url="https://api.example.com/data", body=None, key_id="key-1"
)
Message Signing
Sign a P2P message
from agent_id import sign_message, verify_message_signature
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 message signing
from agent_id import sign_message_async
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",
)
E2E Encryption
from agent_id import encrypt_for, decrypt_from
# Encrypt a message for another agent (NaCl box: X25519-XSalsa20-Poly1305)
ciphertext = encrypt_for(
b"secret message",
recipient_public_key, # 32-byte Ed25519 public key
sender_private_key, # 32-byte Ed25519 seed
)
# Recipient decrypts
plaintext = decrypt_from(ciphertext, sender_public_key, recipient_private_key)
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")
Testing
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
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 open_agent_id-0.3.1.tar.gz.
File metadata
- Download URL: open_agent_id-0.3.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8167383c31f3e0ddcfaf7463a5b3c8c134560312d6ef81d06a542e75a54354b
|
|
| MD5 |
9f198e01b1335f3f95de0f88ad17297c
|
|
| BLAKE2b-256 |
ed9733db12e46307e3911c94ea9387b6899ce59c5b4c5869fa55d8617569567b
|
File details
Details for the file open_agent_id-0.3.1-py3-none-any.whl.
File metadata
- Download URL: open_agent_id-0.3.1-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
516e6e058fdc3e6db98199909da6b3933511b4e609a901b435ab6c2d1cef6930
|
|
| MD5 |
f18d6bfcb1e0dca848717e072255878c
|
|
| BLAKE2b-256 |
7f81f0d8ab5f2d33c6a04c0b1cb81dc9305f322e4edc5360b2af30be67cf6132
|