create-python-x402-client

Create Python HTTP clients that automatically handle x402 payments on Algorand.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-python-x402-client-rudhrakoushik10
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-python-x402-client
Source: https://github.com/Rudhrakoushik10/RootNode/tree/main/projects/.opencode/skill/create-python-x402-client
Command: npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-python-x402-client-rudhrakoushik10

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires x402-avm, py-algorand-sdk, httpx, requests, and includes references (resource) components.

What problem does it solve? Building HTTP clients that pay for API access requires manually detecting 402 Payment Required responses, constructing Algorand USDC payment transactions, signing them, and retrying requests with payment headers. This Skill guides you through wiring that entire flow into httpx or requests so payments happen automatically. ## Core Features & Use Cases - Automatic 402 Handling: Wrap httpx (async) or requests (sync) transports so 402 responses trigger payment creation, signing, and retry with the X-PAYMENT header. - ClientAvmSigner Implementation: Provides a complete Algorand signer class handling the raw-bytes-to-base64 encoding boundaries required by py-algorand-sdk. - Flexible Setup Options: Choose between convenience clients (x402HttpxClient, x402_requests), wrapping existing sessions, low-level transports/adapters, or config-based registration with specific networks and custom algod endpoints. - Use Case: You are building a Python service that consumes a paid API protected by x402 middleware on Algorand. Use this Skill to set up an httpx client that pays in USDC per request without writing payment logic yourself. ## Quick Start Ask the AI to create a Python x402 client using httpx that automatically pays for requests to a protected endpoint with my Algorand key from the AVM_PRIVATE_KEY environment variable.

Frequently Asked Questions about create-python-x402-client

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Python x402 client that pays for API access on Algorand?

Install x402-avm with the httpx or requests extra, implement a ClientAvmSigner with your Algorand key, call register_exact_avm_client on an x402Client, then wrap your HTTP calls with x402HttpxClient or x402_requests. The client automatically handles 402 responses and retries with payment headers.

Should I use httpx or requests for x402 payments in Python?

Use httpx with x402Client for async applications and requests with x402ClientSync for synchronous code. Mixing them causes a TypeError, since the requests adapter performs a runtime check requiring the sync client.

What format must the AVM_PRIVATE_KEY environment variable be in?

AVM_PRIVATE_KEY must be a Base64-encoded 64-byte key consisting of the 32-byte Ed25519 seed followed by the 32-byte public key. The Algorand address is derived from the last 32 bytes using encoding.encode_address.

Why does my x402 request still return 402 after payment?

The transport retries at most once and passes through a second 402 to avoid infinite loops. Common causes are insufficient USDC balance, missing USDC opt-in on the paying address, or registering the wrong Algorand network.

Can I add x402 payments to an existing requests session?

Yes, call wrapRequestsWithPayment with your existing session and x402ClientSync instance. It mounts the payment adapter for http and https in place, preserving any headers or authentication already configured on the session.

How do I register the x402 client for a specific Algorand network?

Pass the networks parameter to register_exact_avm_client with a CAIP-2 network identifier such as the testnet or mainnet genesis hash string. By default it registers an algorand wildcard plus legacy V1 network names.