Skip to main content

X402 payment protocol client for AceDataCloud APIs. Plugs into the acedatacloud SDK as a payment_handler.

Project description

@acedatacloud/x402-client — Python

X402 payment protocol client for AceDataCloud APIs. Plug-in for the acedatacloud SDK.

Pay-per-request with USDC — no API key, no account, no session. When an AceDataCloud API returns 402 Payment Required, this package signs the payment envelope and returns it as an X-Payment header; the SDK retries transparently.

  • 🟦 Base — USDC (ERC-20) via EIP-3009 TransferWithAuthorization
  • 🟪 Solana — USDC (SPL) via signed TransferChecked
  • 🟨 SKALE — USDC (bridged) via EIP-3009

Install

pip install acedatacloud acedatacloud-x402

Quick start

Base or SKALE (EVM)

from acedatacloud import AceDataCloud
from acedatacloud_x402 import create_x402_payment_handler, EVMAccountSigner

client = AceDataCloud(
    payment_handler=create_x402_payment_handler(
        network="base",                         # or "skale"
        evm_signer=EVMAccountSigner.from_private_key("0x..."),
    ),
)

res = client.openai.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Say hi in 3 words"}],
    max_tokens=10,
)
print(res.choices[0].message.content)

Solana

from acedatacloud import AceDataCloud
from acedatacloud_x402 import create_x402_payment_handler, SolanaKeypairSigner

client = AceDataCloud(
    payment_handler=create_x402_payment_handler(
        network="solana",
        solana_signer=SolanaKeypairSigner.from_base58("..."),
    ),
)

task = client.images.generate(
    provider="nano-banana",
    prompt="a yellow banana on a white background",
)
result = task.wait()

The same handler works with AsyncAceDataCloud:

from acedatacloud import AsyncAceDataCloud

client = AsyncAceDataCloud(
    payment_handler=create_x402_payment_handler(network="base", evm_signer=signer),
)

Low-level signing

If you need to produce an X-Payment envelope without going through the SDK:

from acedatacloud_x402 import sign_evm_payment, sign_solana_payment

envelope = sign_evm_payment(requirement, evm_signer)          # dict
envelope = sign_solana_payment(requirement, solana_signer)    # dict
# base64-encode json(envelope) → X-Payment header value

Development

cd python
pip install -e ".[dev]"
pytest
ruff check .

License

MIT © AceDataCloud

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

acedatacloud_x402-2026.4.20.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

acedatacloud_x402-2026.4.20.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file acedatacloud_x402-2026.4.20.1.tar.gz.

File metadata

  • Download URL: acedatacloud_x402-2026.4.20.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for acedatacloud_x402-2026.4.20.1.tar.gz
Algorithm Hash digest
SHA256 03f0c721f34e7f39caa498b3a580a731858f7a51163fbfec774a9a7ce9b20940
MD5 8c0b50908002c0e744b1276ba10bd2cc
BLAKE2b-256 55a88da375784156aefd46b1be2764a238c880c41094959f5379e1bf94095f34

See more details on using hashes here.

File details

Details for the file acedatacloud_x402-2026.4.20.1-py3-none-any.whl.

File metadata

File hashes

Hashes for acedatacloud_x402-2026.4.20.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28ffea2bc7a4ba2ccbdd792cb02e12b26eecf9331063a4c5fe12830628d6f7cf
MD5 db76879c68cb729fb7568b6ba155b2fa
BLAKE2b-256 254d9ec8709e5254729f3d7bfeb979e52daa1837780f7c291884857508baf5c2

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