Tools / AI

Generate an image

Generates a 1024x1024 image from a text prompt with the FLUX.1 [schnell] model. Returns a JPEG directly, or base64 JSON with format=json.

Price per call
$0.02 USDC
Endpoint
POST https://x402-tools.com/v1/image
Also accepts
GET with query parameters
Payment
x402, exact scheme, USDC on Base
Returns
image/jpeg

Parameters

NameTypeDescription
prompt requiredstringWhat to draw (max 2000 characters).
stepsnumberDiffusion steps, 1 to 8 (default 4). More steps, more detail.
formatstring'jpeg' (default, raw image) or 'json' (base64).

Call it from an agent

import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY);
const paidFetch = wrapFetchWithPayment(fetch, account);

const res = await paidFetch("https://x402-tools.com/v1/image", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    "prompt": "A friendly robot paying at a vending machine with a coin, flat illustration",
    "steps": 4,
    "format": "json"
  }),
});
// costs $0.02 in USDC on Base

Without a payment the endpoint answers 402 with the price, so you can inspect it first:

curl -i -X POST "https://x402-tools.com/v1/image" -H "content-type: application/json" -d '{"prompt":"A friendly robot paying at a vending machine with a coin, flat illustration","steps":4,"format":"json"}'

Example response

{
  "note": "Raw JPEG bytes, or with format=json:",
  "prompt": "A friendly robot…",
  "mime_type": "image/jpeg",
  "image_base64": "/9j/4AAQSkZJRg…"
}

If the tool fails or your input is invalid, the payment is not settled.

Other tools