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

# Generate an image

`POST /v1/content/generate-image`

Generates an image via the Brew AI image pipeline. `text-to-image` (default) creates from a prompt; `image-editing` edits `image1` (required) guided by the prompt. Returns a CDN-hosted URL. Usage-metered: charges the actual image gateway cost (no fixed price).

## Headers

- `Idempotency-Key` string

## Request body

- ContentGenerateImageRequest
  - `prompt` string
  - `mode` 'text-to-image' | 'image-editing'
  - `aspectRatio` '16:9' | '3:2' | '4:3' | '1:1' | '4:5' | '2:3' | '3:4' | '9:16'
  - `image1` string, uri
  - `image2` string, uri
  - `adCreative` object
    - `brandName` string, required
    - `headline` string, required
    - `cta` string, required
    - `format` '1:1' | '4:5' | '9:16' | '16:9', required
    - `archetype` 'product-ui-card' | 'mascot' | 'flat-illustration' | 'abstract-brand' | 'type-led' | 'photo-ui-overlay' | 'conceptual-3d' | 'gradient-field' | 'editorial-photo' | 'collage' | 'isometric-blueprint' | 'data-viz', required
    - `layout` 'split-right' | 'split-left' | 'stacked-center' | 'visual-first' | 'type-poster' | 'immersive-field' | 'layered-collage' | 'badge-offer' | 'diagonal-stage' | 'editorial-grid'
    - `eyebrow` string
    - `subjectImageUrl` string, uri
    - `emailCanvasColor` string
    - `palette` object, required
      - `background` string, required
      - `accent` string, required
      - `headlineColor` string, required
    - `supportingVisual` string
    - `subhead` string

## Response `200`

The operation result.

- ContentImageResponse
  - `url` string, uri, required
  - `prompt` string, required
  - `description` string
  - `warnings` string[]

## Other responses

- `400` — The request body or query string was invalid (unknown key, wrong type, or missing required field). Strict schemas reject unknown keys — including `brandId`, which is always resolved from the API key.
- `401` — The API key was missing, invalid, or revoked.
- `402` — The org's remaining credit balance is below what this operation requires. Credit cost is published PER-OPERATION (see `GET /v1/help`): content/media operations charge a flat cost, while AI generation (email generate/edit/import, image generation) is usage-metered — charged by actual model usage rather than a flat price. `details.cost` carries the amount the runtime required for THIS call. Check your balance up front via `GET /v1/usage`. No `Retry-After` — credits reset at the billing-period boundary.
- `403` — The caller does not have the required `emails` permission.
- `409` — The same `Idempotency-Key` was reused with a different request body.
- `422` — The source image/video could not be processed (unreachable URL, non-decodable media, or upload failure).
- `429` — The request hit the rolling rate limit window.
- `500` — Unexpected internal error.
- `503` — The credit balance could not be verified (a transient billing dependency outage). The gate fails closed rather than do paid work it cannot meter. Retryable — `Retry-After` indicates when.

---

[API](https://skmtc.net/brew/apis/brew-public-api-v1.md) · [All operations](https://skmtc.net/brew/apis/brew-public-api-v1/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/brew/brew-public-api-v1/versions/db96cfedc6c5/schema)
