Skip to main content

Python reader for the pay.json standard — machine-readable pricing for AI agents.

Project description

pay-json (Python)

Python reader for the pay.json standard. Fetches a site's /.well-known/pay.json, validates structure, and resolves the price rule for a given URL path.

Install

pip install pay-json

Usage

from pay_json import PayJson

# Fetch and parse a host's pay.json
doc = PayJson.fetch("example.com")

# Resolve a rule for a given path
rule = doc.match_rule("/api/inference/foo")
if rule:
    print(rule.price_usd)   # Decimal("0.01")
    print(rule.terms)       # {"type": "per_unit", "unit": "1000_tokens"}

Targets pay.json v1.2 (the current spec). v1.2 introduces a facilitators[] array (multi-facilitator failover), an optional verifier endpoint, and drops the pre-1.2 single-string facilitator field. Pre-1.2 documents are not accepted.

License

MIT. See the spec for the (CC-BY-4.0) specification text itself.

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

pay_json-1.2.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

pay_json-1.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pay_json-1.2.0.tar.gz.

File metadata

  • Download URL: pay_json-1.2.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pay_json-1.2.0.tar.gz
Algorithm Hash digest
SHA256 aabd72a603f376a6a7ac2376ed6b398e0dbbadf38c0310ad84c0a71ed4e5ffc0
MD5 7bf23f9ce0416425d95f99060d6c6b3f
BLAKE2b-256 36c1441c187ba8b58ab11c707b83c247bbf4cea2ba221d19014da5c41d78dafa

See more details on using hashes here.

File details

Details for the file pay_json-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pay_json-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pay_json-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13ea4cbaf0856f9ae8dd9b94297676216319f25b817348f11ba1a82a50345635
MD5 80f2cf330c816b19fd7a589a02ea9d75
BLAKE2b-256 e12966016bd62746985c3f70be3352332131f12cb727254116df6d1c62a4f2a6

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