Image generation (Premium)

$0.15 per callUSDC via x402POST /api/image-gen-premium

Generate a larger image from a text prompt using GPT Image 2 (medium quality): 1536x1024 landscape by default, 1024x1536 portrait or 1024x1024 square via orientation. Send POST /api/image-gen-premium with the required field prompt and pay $0.15 per call over x402 with USDC on an EVM chain or MPP. It returns a JSON object with model, provider, quality, size, image and 1 more.

No API key needed; pay per call via x402. Returns base64 PNG. Prompt capped at 4000 chars. A render takes 25 to 50 s; use a client timeout of at least 75 s. Takes up to 75 seconds to answer: send the paid call with "Prefer: respond-async" to get a job link at once and collect the answer from it (payment still settles only on a delivered result), or with "Prefer: wait=75" and keep the connection open for at least 105 seconds, because a client that disconnects first loses the answer. A paid call with neither header is answered 400 before any payment is taken.

Category: AI & computeTags: image ai generation openai text-to-image gpt-image-2 premium

Try in playground →

Parameters

NameTypeRequiredDescription
promptstringyesText description of the desired image (max 4000 chars) Also accepted as text, input, description, q, query.
orientationstring (one of: landscape, portrait, square)nolandscape 1536x1024 (default), portrait 1024x1536, square 1024x1024

Example request

curl -i -X POST https://agent402.tools/api/image-gen-premium \
  -H "Content-Type: application/json" \
  -d '{"prompt":"A single red apple on a white background"}'

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

Example response

{
  "model": "gpt-image-2",
  "provider": "openai",
  "quality": "medium",
  "size": "1536x1024",
  "image": "<base64-encoded PNG>",
  "revised_prompt": "A single red apple on a white background"
}
FieldTypeAlways presentIn the example
modelstringyesgpt-image-2
providerstringyesopenai
qualitystringyesmedium
sizestringyes1536x1024
imagestringyes<base64-encoded PNG>
revised_promptstringyesA single red apple on a white background

From an MCP client

catalog.call {
  "slug": "image-gen-premium",
  "params": {
    "prompt": "A single red apple on a white background"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for image-gen-premium; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].

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?.({ maxAmountPerPayment: "$0.15" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/image-gen-premium", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "prompt": "A single red apple on a white background"
  }),
});

Related tools

Image generation

$0.03 · POST /api/image-gen

Generate an image from a text prompt using GPT Image 2 (low quality, 1024x1024).

Image generation (HD)

$0.10 · POST /api/image-gen-hd

Generate a higher-quality image from a text prompt using GPT Image 2 (medium quality, 1024x1024).

Decisions (OpenAI wire)

$0.001 · POST /v1/decisions

OpenAI's Decisions API on its own wire: point an OpenAI SDK's base URL here and client.decisions.create works unchanged.

Locate in image (preview)

$0.002 · POST /v1/judge/locate

Find up to 4 things in one image: each comes back with whether it is there (a probability) and its box, as edges from 0.

Judge images (preview)

$0.003 · POST /v1/judge/vision

Ask typed questions about up to 4 images (PNG or JPEG) and get answers your code can branch on: noul (yes/no.

LLM inference

$0.01 · POST /api/llm

LLM inference proxy - send an OpenAI-format chat/completions request and get a response from GPT-4o-mini (or gpt-6-luna.