---
title: "Generate an AI meme image (paid, agent rail)"
method: POST
path: "/v1/agent/generate"
tags: ["Agent payments"]
---

# Generate an AI meme image (paid, agent rail)

`POST /v1/agent/generate`

## Request

- Base URL: `https://api.memestack.ai`
- URL: `https://api.memestack.ai/v1/agent/generate`
- Auth: none declared

Generate an image from a text prompt via Grok Imagine. PAID endpoint (agent payment rails — no account needed; the payment is the auth). Attach proof via PAYMENT-SIGNATURE or X-PAYMENT header (base64 JSON x402 payload, USDC on Base) or Authorization: L402 <macaroon>:<preimage> (Lightning sats). Without proof the response is 402 with a dual-rail offer. Rate limited 30/min/IP. Returns 404 while payments are disabled. Prices: $0.08 standard / $0.20 quality (paid in sats over Lightning at the current BTC/USD rate, or in USDC on Base). Long-polls up to ~90s; on 202, retry with the SAME payment proof to resume — one payment delivers at most one image.

## Request body

- object
  - `prompt` string, required
  - `mode` 'standard' | 'quality'
  - `aspect_ratio` '1:1' | '3:4' | '16:9'

## Response `200`

Image generated and delivered.

- object
  - `image_id` string, uuid
  - `url` string
  - `image_url` string
  - `thumbnail_url` string
  - `caption` string
  - `tags` object[]

## Other responses

- `202`: Still generating at the poll budget — claim stays open; retry with the SAME payment proof to collect.
- `400`: Invalid body or malformed payment header (INVALID_PAYMENT_HEADER).
- `402`: Payment required. Body is the x402 v2 PaymentRequired envelope; the same envelope is base64-encoded in the PAYMENT-REQUIRED header, and WWW-Authenticate carries the L402 challenge (macaroon + bolt11 invoice). Pay on either rail and retry with proof.
- `410`: The generated image was removed; payment recorded for reconciliation (terminal).
- `422`: Rejected by content moderation (nsfw/gore/spam) — payment retained per policy (POLICY_REJECTED).
- `429`: Rate limit exceeded (30/min/IP).
- `502`: Generation failed before output (GENERATION_FAILED) — claim stays open, retry with the same proof (prompt change allowed).
- `503`: Payment rails temporarily unavailable (PAYMENT_UNAVAILABLE).

---

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