> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useotto.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# AI image generation and editing with x402

> Generate an image or edit a public image URL through Otto's generate-meme API, with model selection and expiring PNG delivery.

Otto's `/generate-meme` API creates images from text and edits images supplied by public URL. Despite the route name, it also handles illustrations, product concepts and other image-generation tasks; one paid request returns one generated image.

## Choose a request

Use `POST /generate-meme` with a JSON body. Read the [current input schema and indicative price](https://x402.ottoai.services/service-detail?path=/generate-meme) before preparing a call; the [payment challenge](/acp-swarm/x402#inspect-the-challenge) is the price authority.

| Field          | How to use it                                                                                                          |
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `prompt`       | Required description, 10 to 2,000 characters. Specify subject, composition, style and any exact text you want visible. |
| `model`        | Optional: `gpt-image-2` is the default; `nano-banana-pro` is the alternative. Use only values in the current schema.   |
| `aspect_ratio` | Optional: `1:1` by default, or `16:9` / `9:16`. Match the intended placement.                                          |
| `image_url`    | Optional public HTTPS URL of an image to edit or remix. Omit it for a new image.                                       |

The endpoint uses fal.ai to run the selected model. Model choice affects the result; use a clear scene-level prompt and inspect the generated image before incorporating it into a finished artifact.

## Inspect a generation request

This example requests a price challenge for an illustration:

```bash theme={null}
curl -i 'https://x402.ottoai.services/generate-meme' \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "An editorial illustration of an otter reading a newspaper at a sunny cafe, clean geometric shapes, warm blue and cream palette, no lettering, square composition.",
    "model": "gpt-image-2",
    "aspect_ratio": "1:1"
  }'
```

This unpaid call returns `402` and does not generate an image. Inspect the [current OpenAPI](https://x402.ottoai.services/openapi.json) and [declared output](/acp-swarm/x402-examples#inspect-the-payment-and-declared-output), then use the [HTTP payment client](/acp-swarm/x402#make-a-paid-request) with an approved per-call cap and the same JSON body.

For an edit, add your image's public HTTPS URL as `image_url` and describe what to change in `prompt`. The service fetches that URL and passes the image to its generation provider. A local file path or a page that requires your browser login cannot substitute for a publicly accessible image.

## Save and verify the image

A successful HTTP response has these top-level fields:

| Field       | Meaning                                                                              |
| ----------- | ------------------------------------------------------------------------------------ |
| `status`    | `success` for a delivered image; inspect failure bodies separately                   |
| `imageUrl`  | Download URL for the generated PNG                                                   |
| `model`     | The model used for this request                                                      |
| `expiresAt` | When this hosted image expires; use the returned timestamp to decide when to save it |

Download the image before `expiresAt` if you want to keep it. Preserve the original request, result URL, model and payment receipt, then check the actual image for composition, spelling and whether the requested edit was followed. A returned URL alone does not establish visual quality.

The ACP [`image_and_meme_gen` offering](/acp-swarm/tools-agent#image-generation) uses a different job envelope and requires `does_this_prompt_meet_safety_guidelines: true`; the HTTP body above does not require that ACP confirmation field. ACP also names the model in `model_used`, while this HTTP response uses `model`.

## Limits and failures

Image requests must meet the selected model's content policy. A policy block returns a failed result; check the HTTP status and payment receipt to establish whether a charge occurred. Invalid model values or unsafe/unreachable image URLs can fail; a price challenge alone does not validate the request.

Keep the exact request and any receipt if a paid call times out or returns an error. Follow [HTTP failure handling](/acp-swarm/x402#handle-failures) before submitting a replacement request, which may incur another charge. Images use a flat per-image price, without an unspent-budget refund step; video generation has a different [pricing and delivery contract](/acp-swarm/tools-agent#video-generation).
