---
title: "AI IMAGE GENERATION — POST {prompt} and get back a PNG, base64 in JSON (?raw=1 for raw bytes)"
method: POST
path: "/api/generate-image"
tags: ["AI Utilities"]
---

# AI IMAGE GENERATION — POST {prompt} and get back a PNG, base64 in JSON (?raw=1 for raw bytes)

`POST /api/generate-image`

## Request

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

AI IMAGE GENERATION — POST {prompt} and get back a PNG, base64 in JSON (?raw=1 for raw bytes). Gemini 2.5 Flash Image (nano-banana): photoreal scenes, illustrations, product shots, UI mockups — renders text in images well. Optional {aspect_ratio}: 1:1 (default), 16:9, 9:16, 4:3 + 6 more. Reference images: pass {url} or {image_base64}, or up to 3 in {reference_images}, to edit, restyle, or compose ('put this product on this beach'). The x402 payment IS the auth.

Price: $0.07 per call, paid in USDC via the x402 protocol (see the x402 security scheme).

## Request body

- object
  - `prompt` string, required: What to generate, up to 2,000 chars — subject, style, composition, lighting
  - `aspect_ratio` string: 1:1 (default), 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, or 21:9
  - `url` string: Optional public URL of a reference image to edit/restyle instead of generating from scratch (png, jpeg, gif, webp; max 5 MB)
  - `image_base64` string: Alternative to url: a reference image as base64 (data URI accepted)
  - `reference_images` unknown[]: Up to 3 reference images (URLs or base64 strings, 6 MB combined) to compose — product placement, style transfer, character consistency
    - unknown

## Response `200`

Success

- object
  - `image_base64` string: the generated image as base64 — decode and save
  - `content_type` string
  - `bytes` number
  - `mode` string: generate or edit
  - `model` string
  - `usage` object

## Other responses

- `402`: Payment required — the response body lists accepted payment methods (amount, asset, network, pay-to address). Retry the request with a signed X-PAYMENT header.

---

[API](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api.md) · [All operations](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api/llms.txt) · [OpenAPI document](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api/revisions/c14a76c67a94?raw)
