from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
key = ec.generate_private_key(ec.SECP256R1())
pem = key.private_bytes(
serialization.Encoding.PEM,
serialization.PrivateFormat.PKCS8,
serialization.NoEncryption(),
).decode()
# Use as context manager (auto-closes HTTP connection)
with ATHGatewayClient(
url="http://gateway.example.com",
agent_id="https://your-agent.com/.well-known/agent.json",
private_key=pem,
key_id="my-key-2024", # optional
timeout=60.0, # optional
) as client:
...