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

# Generate Featured Image

> Generate Featured Image.



## OpenAPI

````yaml POST /ai/generateImage
openapi: 3.1.0
info:
  title: Blog API
  version: 1.0.0
servers:
  - url: https://api.octaviatech.app/cms
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Tags
    description: Tag management endpoints
paths:
  /ai/generateImage:
    post:
      tags:
        - AI
      summary: Generate a featured image
      description: >-
        Either `prompt` or `articleId` must be provided. When `articleId` is
        given and `prompt` is omitted, the prompt is derived from the article's
        title, summary, tags and a content excerpt. `setAsThumbnail` stores the
        generated image as the article thumbnail.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              oneOf:
                - required:
                    - prompt
                - required:
                    - articleId
              properties:
                prompt:
                  type: string
                  description: Text description of the desired image
                articleId:
                  type: string
                  description: Article whose content is used to build the prompt
                  example: '{{objectId}}'
                size:
                  type: string
                  description: Output dimensions
                  enum:
                    - 1024x1024
                    - 1024x1536
                    - 1536x1024
                    - auto
                  default: 1024x1024
                quality:
                  type: string
                  description: Rendering quality
                  enum:
                    - low
                    - medium
                    - high
                    - auto
                style:
                  type: string
                  description: Art direction
                  enum:
                    - vivid
                    - natural
                setAsThumbnail:
                  type: boolean
                  description: >-
                    If true, sets the article thumbnail to the generated image
                    (requires articleId)
            examples:
              From Prompt:
                value:
                  prompt: Editorial photo of a home-cooked keto meal on a wooden table
                  size: 1024x1024
                  style: natural
                  quality: high
              From Article:
                value:
                  articleId: '{{objectId}}'
                  setAsThumbnail: true
      responses:
        '200':
          description: OK (image generated)
          content:
            application/json:
              example:
                success: true
                statusCode: 200
                message: Image generated successfully
                data:
                  imageUrl: data:image/png;base64,…
                  imageBase64: iVBORw0KGgo…
                  imageMimeType: image/png
                  articleId: null
                  tokens:
                    used: 300
        '400':
          description: No usable prompt (neither prompt nor a resolvable article)
        '401':
          description: Unauthorized
        '403':
          description: Forbidden (role not allowed)
        '404':
          description: Article not found
        '406':
          description: Validation failed
        '426':
          description: Upgrade required (ai_tokens limit exceeded)
        '500':
          description: Failed to generate image
        '502':
          description: Upstream image model failed
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````