ANML 1.0 Server SDK for Python — Build and serve ANML duckuments with a fluent builder API.
pip install anml-serverfrom anml_server import AnmlDocumentBuilder, negotiate_content_type, serialize
doc = (
AnmlDocumentBuilder()
.title("Acme Electronics — Checkout")
.ttl(300)
.persona(tone="helpful", instructions="Confirm total before payment.", brand_color="#4F46E5")
.disclosure("payment-credential", requires="explicit-consent")
.disclosure("shipping-address", requires="explicit-consent")
.flow([
{"id": "cart", "label": "Cart", "status": "completed"},
{"id": "checkout", "label": "Checkout", "status": "current", "action": "pay"},
{"id": "confirm", "label": "Confirmed", "status": "pending"},
])
.action("pay", method="POST", endpoint="/api/orders", auth="required", confirm=True)
.inform("Free shipping on orders over $75. 30-day returns.", ttl=3600)
.ask("email", action="pay", required=True, purpose="receipt")
.rights("cache")
.body("4K Monitor x1 — $599.00")
.build()
)
# Serialize based on Accept header
content_type = negotiate_content_type(request_accept_header)
response_body = serialize(doc, content_type)- Document Builder — Fluent, type-safe API for constructing valid ANML duckuments
- Serialization —
to_json()andto_xml()with content negotiation - Validation — Pydantic models ensure spec compliance at construction time
- Framework Agnostic — Works with FastAPI, Flask, Django, or any Python web framework
ISC
