Skip to content

Agent Payments (x402 Protocol)

AI agents can pay for API calls directly from their own wallet using the x402 protocol — no API key required. The SDK handles the full payment handshake automatically.

How it works

  1. Agent sends a request without an auth header.
  2. Server returns HTTP 402 with payment requirements (amount, token, chain).
  3. Agent signs an x402 payment with its wallet private key.
  4. Agent resends the request with the PAYMENT-SIGNATURE header.
  5. Server verifies the payment via facilitator and returns the response.

Requirements

A wallet with USDC — choose either supported chain:

  • Base chain — hex private key starting with 0x...
  • Solana — base58 keypair exported from Phantom or Solflare

The SDK detects the chain automatically from the key format — no config flag needed.

Install with agent support

shell
pip install jarvisclaw[agent]
shell
go get github.com/api-jarvisclaw/go-sdk

Example

Initialize any client with a private_key instead of an api_key. The SDK intercepts 402 responses, signs the payment, and retries — all transparently.

python
# pip install jarvisclaw[agent]
from jarvisclaw import ChatClient, ImageClient, VideoClient, AudioClient, SearchClient

# Agent wallet (needs USDC on Base chain)
chat = ChatClient(private_key="0x<agent-wallet-private-key>")
image = ImageClient(private_key="0x<agent-wallet-private-key>")
video = VideoClient(private_key="0x<agent-wallet-private-key>")
audio = AudioClient(private_key="0x<agent-wallet-private-key>")
search = SearchClient(private_key="0x<agent-wallet-private-key>")

# Chat — SDK handles 402 → sign → retry automatically
response = chat.complete("Hello")
print(response)

# Image generation (auto-polls until ready)
img = image.generate("A futuristic city")
print(img.url)

# Video generation (blocks until ready)
job = video.generate("Ocean waves")
print(job.url)

# Text-to-Speech
result = audio.speech("Hello world", voice="alloy")

# Web search
results = search.query("latest AI news")

Pay per call. No subscription. No rate limits.