images

generate an image with AI

Changed on

Generate an image from a text prompt and get back a URL hosted by this Forem.

The image follows this Forem's cover image style and, unless aspect_ratio is given, is sized for its cover images. Use the URL in body_markdown or as an article's main_image, just like an uploaded image.

Limits:

  • prompt is required and may be up to 1000 characters.
  • Rate limited per user to a configurable number of generations per configurable window (by default 3 per day). Every attempt counts, including failed ones. Exceeding it returns 429 with a Retry-After header. Forem admins can change both values, or set the limit to 0 to disable this endpoint.
  • Returns 503 if AI image generation is not configured on this Forem.
post/api/images/generate

Request

  • Base URL
    https://dev.to
  • Auth
    • API key in header api-key
    • or HTTP bearer

Request body

promptstring required

A description of the image to generate.

aspect_ratio'1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9'

Aspect ratio of the image. Defaults to this Forem's cover image shape.

Response

created

urlstring url required

Changes