Python SDK for the Pylon Agent Gateway — one endpoint for every tool an agent needs.
20+ capabilities (screenshot, web scrape, OCR, PDF parse, email validate, DNS lookup, translate, and more) accessible through a single API. Payments handled automatically via the x402 protocol using USDC on Base.
pip install pylonapiimportpylonapipylon=pylonapi.Pylon(private_key="0x...")
# Natural language — the gateway picks the right toolresult=pylon.do("take a screenshot of stripe.com")
# Explicit capabilityresult=pylon.screenshot("https://stripe.com", full_page=True)
# Check the resultprint(result["result"]) # screenshot data, extracted text, etc.- You call
pylon.do(...)or a convenience method - The gateway returns
402 Payment Requiredwith USDC cost - The SDK signs an x402 payment authorization (EIP-712)
- The request is retried with the payment proof
- You get your result
All payment happens automatically. You just need a funded wallet on Base.
The SDK uses an Ethereum private key to sign x402 micropayments. Your wallet needs USDC on Base (mainnet).
# From a private keypylon=pylonapi.Pylon(private_key="0xabc123...")
# Or use environment variableimportospylon=pylonapi.Pylon(private_key=os.environ["PYLON_PRIVATE_KEY"])
# Without payment (will raise PaymentRequired on 402)pylon=pylonapi.Pylon()| Method | Capability | Cost |
|---|---|---|
pylon.screenshot(url) | Screenshot | $0.01 |
pylon.web_scrape(url) | Web Scrape | $0.01 |
pylon.web_extract(url) | Web Extract | $0.005 |
pylon.pdf_parse(url) | PDF Parse | $0.02 |
pylon.ocr(url) | OCR | $0.03 |
pylon.email_validate(email) | Email Validate | $0.005 |
pylon.domain_intel(domain) | Domain Intel | $0.01 |
pylon.qr_code(data) | QR Code | $0.005 |
pylon.image_resize(url) | Image Resize | $0.01 |
pylon.md_to_pdf(markdown) | Markdown to PDF | $0.02 |
pylon.html_to_pdf(html=...) | HTML to PDF | $0.02 |
pylon.search(query) | Web Search | $0.003 |
pylon.translate(text, target) | Translate | $0.005 |
pylon.dns_lookup(domain) | DNS Lookup | $0.002 |
pylon.ip_geo(ip) | IP Geolocation | $0.002 |
pylon.url_shorten(url) | URL Shortener | $0.002 |
pylon.data_format(input, from_fmt, to_fmt) | Data Formatter | $0.002 |
pylon.doc_gen(data, template=...) | Document Gen | $0.02 |
pylon.email_send(to, subject, body) | Email Send | $0.01 |
pylon.file_upload(file_url) | File Storage | $0.005 |
# Natural languageresult=pylon.do("validate test@example.com")
# Explicit capability + paramsresult=pylon.do(
capability="screenshot",
params={"url": "https://example.com", "fullPage": True}
)
# With budget capresult=pylon.do("screenshot stripe.com", budget="$0.02")result=pylon.chain([
{"capability": "web-extract", "params": {"url": "https://example.com"}},
{"capability": "translate", "params": {"text": "{{step_0.content}}", "target": "es"}},
])importasyncioimportpylonapiasyncdefmain():
asyncwithpylonapi.AsyncPylon(private_key="0x...") aspylon:
# Run tasks concurrentlyresults=awaitasyncio.gather(
pylon.screenshot("https://stripe.com"),
pylon.domain_intel("stripe.com"),
pylon.dns_lookup("stripe.com"),
)
asyncio.run(main())importpylonapitry:
result=pylon.do("screenshot https://example.com")
exceptpylonapi.PaymentRequiredase:
print("Need to configure payment:", e.body)
exceptpylonapi.TaskNotFoundase:
print("No matching capability:", e)
exceptpylonapi.APIErrorase:
print(f"API error {e.status_code}: {e}")pylon=pylonapi.Pylon(
private_key="0x...", # Wallet key for x402 paymentsbase_url="https://api.pylonapi.com", # Gateway URLauto_pay=True, # Auto-handle 402 flow (default: True)timeout=60, # Request timeout in seconds
)Pylon uses the x402 payment protocol. When you make a request:
- The gateway returns
402with payment requirements (amount, asset, payee) - The SDK signs a USDC
TransferWithAuthorization(EIP-712) on Base - The signed proof is sent as the
X-PAYMENTheader - The x402 facilitator verifies and settles the payment
No API keys. No subscriptions. Just pay-per-request with USDC.
MIT