AiPayGen SDK
Python client for AiPayGen APIs with automatic x402 payment handling.
Install
pip install aipaygen-sdk
# With crypto support (auto-pay via USDC)
pip install aipaygen-sdk[crypto]
Quick Start
from aipaygen_sdk import Client
client = Client(api_key="apk_xxx")
# Call tools
result = client.ask("What is quantum computing?")
print(result.result)
result = client.research("AI agent frameworks 2026")
result = client.summarize("Long text here...")
result = client.translate("Hello world", target="es")
result = client.code("def fibonacci(n):", language="python")
# Generic tool call
result = client.call_tool("sentiment", text="I love this product")
# Check balance
balance = client.check_balance()
Auto-Pay (x402)
When your free tier runs out, enable auto-pay to automatically handle 402 responses:
client = Client(
api_key="apk_xxx",
auto_pay=True,
wallet_key="0x...", # Your Ethereum private key
)
# Automatically pays USDC on Base when 402 is returned
result = client.research("detailed analysis of x402 protocol")
print(result.paid) # True
print(result.receipt) # PaymentReceipt(...)
Async
from aipaygen_sdk import AsyncClient
async with AsyncClient(api_key="apk_xxx") as client:
result = await client.ask("Hello")
print(result.result)
Streaming
for chunk in client.stream("research", query="MCP servers"):
print(chunk.data, end="")
Error Handling
from aipaygen_sdk import Client, AuthError, PaymentRequired, RateLimitError
try:
result = client.ask("Hello")
except AuthError:
print("Invalid API key")
except PaymentRequired as e:
print(f"Payment needed: {e.payment_info}")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
Environment Variables
AIPAYGEN_API_KEY— default API key (alternative to passingapi_key=)
License
MIT
Metadata
Release files for aipaygen-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aipaygen_sdk-0.1.0.tar.gz | 11.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aipaygen_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.2 kB
Release files / aipaygen_sdk-0.1.0.tar.gz
| Download URL | aipaygen_sdk-0.1.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b76ab61b292a3e983954b43aa9c707279937e59cee2bd86764ba7a0e105d715
|
|
BLAKE2b-256 checksum How to use checksums |
8abb9f4d93c5ba60c446a6e55e0ccc62b2055bc43784d1a23a4a7aa83169883f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / aipaygen_sdk-0.1.0-py3-none-any.whl
| Download URL | aipaygen_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a52e3e7a0b7ad76ca2a23d21af2e216b09235ecc86a3c6e7dd53956339c11d9
|
|
BLAKE2b-256 checksum How to use checksums |
ea7b97fbc1503a2e436a68555f628879dd22c208f6b6ec4bd4f060d65bc64a87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for aipaygen-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.