Skip to Content
API ReferenceDirect USDC Generate

Direct USDC Generate

POST /api/proxy-generate

Generate AI content by submitting proof of a direct USDC transfer on Base. Use this when you can’t use the X402 protocol (e.g., from Python or environments without x402-fetch).

Flow

  1. Transfer USDC to the gateway wallet on Base
  2. Submit the transaction hash with your generation request
  3. The server verifies the on-chain payment
  4. Generation starts and you get a task ID to poll

Request Body

{ "slug": "nano-banana", "prompt": "A photorealistic sunset over the ocean", "txHash": "0xabc123def456...", "aspect_ratio": "16:9", "output_format": "webp" }
FieldTypeRequiredDescription
slugstringYesEndpoint identifier
promptstringConditionalGeneration prompt (1–10,000 chars). Required unless fileBase64 is provided.
txHashstringYesTransaction hash (0x + 64 hex characters)
fileBase64stringNoBase64-encoded file for document parsing (max ~7.5 MB)
fileNamestringNoOriginal filename (required if fileBase64 is provided)
aspect_ratiostringNoImage ratio: 1:1, 4:3, 3:4, 16:9, 9:16
output_formatstringNoOutput format: png, jpg, webp
resolutionstringNoOutput resolution (provider-dependent)

Response — 200 Success

{ "success": true, "taskId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "statusUrl": "/api/task/a1b2c3d4-e5f6-7890-abcd-ef1234567890", "paidAmount": 0.05, "message": "Generation started. Poll statusUrl for results." }

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid request body (missing fields, bad format)
400TX_NOT_FOUNDTransaction hash not found on Base network
400TX_FAILEDTransaction failed on-chain
400INVALID_PAYMENTNo USDC transfer to gateway wallet in the transaction
400INSUFFICIENT_PAYMENTAmount transferred is less than endpoint price
400TX_ALREADY_USEDThis transaction hash has already been submitted
404NOT_FOUNDEndpoint slug does not exist
429Rate limited (5 req/min)
500INTERNAL_ERRORFailed to create task record
500EXECUTION_ERRORGeneration failed server-side

Payment Verification

The server verifies your transaction on-chain:

  1. Fetches the transaction receipt from Base
  2. Looks for a USDC Transfer event where the recipient matches the gateway wallet
  3. Checks the transferred amount is at least the endpoint price
  4. Ensures the transaction hash hasn’t been used before (replay protection)

USDC Contract on Base: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (6 decimals)

Example

# After transferring 0.05 USDC to the gateway wallet on Base: curl -X POST https://402claw.cloud/api/proxy-generate \ -H "Content-Type: application/json" \ -d '{ "slug": "nano-banana", "prompt": "A beautiful mountain landscape at golden hour", "txHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" }'

File Upload Example

# Base64-encode a PDF and submit for parsing: FILE_B64=$(base64 -i document.pdf) curl -X POST https://402claw.cloud/api/proxy-generate \ -H "Content-Type: application/json" \ -d "{ \"slug\": \"llamaparse\", \"fileBase64\": \"$FILE_B64\", \"fileName\": \"document.pdf\", \"txHash\": \"0x...\" }"
Last updated on