Image generation (OpenAI-compatible)

$0.080 per call · USDC via x402 · POST /v1/images/generations

OpenAI-compatible image generation over x402 - point any OpenAI SDK's images.generate() at base_url https://agent402.tools/v1 and pay $0.08 per image in USDC, no API key, no signup. Send POST /v1/images/generations with the required field prompt and pay $0.080 per call over x402 or MPP (there is no free tier). It returns a JSON object with created, model, data and usage.

Served by FLUX.2 Pro with GPT-5 Image Mini as the failover; prompt in (up to 4k chars), one 1024x1024 PNG out as inline base64 (response_format b64_json). One image per call (n locked to 1). Optional zdr:true routes only to zero-data-retention providers.

Category: LLM gateway · Tags: image-generation images text-to-image flux png llm ai inference · Also found as: image-generation-openai-compatible image-generation

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
promptstringyesText description of the image to generate (up to 4,000 chars) Also accepted as text, input, description, q, query.
zdrbooleannoOptional - true routes only to zero-data-retention providers

Example request

curl -i -X POST https://agent402.tools/v1/images/generations \
  -H "Content-Type: application/json" \
  -d '{"prompt":"A minimalist watercolor of a fox reading a newspaper in a forest clearing"}'

Without payment this returns HTTP 402 Payment Required with the exact price for v1-images; any x402 v2 or MPP client pays it and retries.

Example response

{
  "created": 1750000000,
  "model": "black-forest-labs/flux.2-pro",
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA…",
      "media_type": "image/png"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 4096,
    "total_tokens": 4110
  }
}
FieldTypeAlways presentIn the example
creatednumberyes1750000000
modelstringyesblack-forest-labs/flux.2-pro
dataarray of objectsyes1 item in the example
usageobjectyes3 fields: prompt_tokens, completion_tokens, total_tokens

From an MCP client

catalog.call {
  "slug": "v1-images",
  "params": {
    "prompt": "A minimalist watercolor of a fox reading a newspaper in a forest clearing"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for v1-images; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/v1/images/generations", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "prompt": "A minimalist watercolor of a fox reading a newspaper in a forest clearing"
  }),
});

Related tools

Fast image generation (OpenAI-compatible, budget)

$0.020 · POST /v1/images/fast

Budget text-to-image over x402 - OpenAI images wire (prompt in, inline base64 out) at $0.02 per picture, a quarter of th…

Pro image generation (OpenAI-compatible)

$0.050 · POST /v1/images/pro

Higher-fidelity text-to-image over x402 - OpenAI images wire (prompt in, inline base64 out) at $0.05 per picture. Served…

Text-to-speech (OpenAI-compatible)

$0.060 · POST /v1/audio/speech

OpenAI-compatible text-to-speech over x402 - point any OpenAI SDK's audio.speech.create() at base_url https://agent402.t…

Chat completions (OpenAI-compatible)

$0.02 · POST /v1/chat/completions

OpenAI-compatible chat completions, base tier: point any OpenAI SDK at base_url https://agent402.tools/v1 and pay per ca…

Chat completions - auto tier (eval-ranked routing)

$0.01 · POST /v1/auto/chat/completions

OpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…

Grounded chat (web search, OpenAI-compatible)

$0.03 · POST /v1/grounded/chat/completions

OpenAI-compatible chat completions GROUNDED in a live web search on every call: the gateway runs an Exa search (up to 5 …