---
title: "Generate an image"
method: POST
path: "/generate-image/v1"
tags: ["Image"]
---

# Generate an image

`POST /generate-image/v1`

## Request

- Base URL: `https://api.run402.com`
- URL: `https://api.run402.com/generate-image/v1`
- Auth: API key in header `X-PAYMENT`

Generates an image via AI. Requires payment: x402 (USDC on Base mainnet or Base Sepolia, or, while Run402's Lightning Hub is issuing, sats on Bitcoin Lightning via the `exact` scheme on `lnbtc:000000000019d6689c085ae165831e93`, where the paid retry carries the invoice preimage) or MPP. Not included in any tier — per-call cost.

## Headers

- `Idempotency-Key` string

## Request body

- object
  - `prompt` string, required: Image generation prompt

## Response `200`

Image generated

- object

## Other responses

- `402`: Payment or SIWX authentication required. Existing routes return x402 discovery fields. On a priced route, when the caller was identified and its allowance was checked first, the body also carries `allowance: { allowance_usd_micros, price_usd_micros, shortfall_usd_micros }` and `redeem_voucher` / `top_up` next actions: the shortfall, not the whole price, is what a voucher or top-up must cover. An explicitly selected MPP Lightning tier request returns exactly one WWW-Authenticate: Payment challenge plus retained intent, attempt, quote, fixed invoice amount, and expiry metadata; the response is no-store.
- `409`: `IDEMPOTENCY_KEY_REUSED`: the Idempotency-Key already answered a different request. Nothing from the first response is returned; next action `new_idempotency_key`.

---

[API](https://skmtc.dev/run402/apis/run402-api.md) · [All operations](https://skmtc.dev/run402/apis/run402-api/llms.txt) · [OpenAPI document](https://skmtc.dev/run402/apis/run402-api/revisions/893607557f50?raw)
