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

# Generate AI Template

> Generate prompt-based copy for a public template and export the rendered result.



## OpenAPI

````yaml /openapi.yaml post /api/v1/{designId}/generate-ai
openapi: 3.1.0
info:
  title: Pixy Public API
  version: 1.0.0
  description: >
    Public API for validating bearer API keys, browsing and duplicating saved

    designs, and generating rendered design output from a Pixy design or
    template.


    The first endpoint in this reference is the API key validation endpoint used
    by

    integrations such as Zapier. Design, template, duplicate, and generate
    endpoints

    follow after it.


    This specification documents the currently exposed public endpoints in

    `apps/pixy-web/app/api/(public)`.
servers:
  - url: https://app.pixy.art
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Auth
    description: Resolve the current user for a Pixy bearer API key.
  - name: Generate
    description: Render design output from a Pixy design or template.
  - name: Templates
    description: Browse public Pixy templates.
  - name: Designs
    description: Browse designs saved in your Pixy organization.
paths:
  /api/v1/{designId}/generate-ai:
    post:
      tags:
        - Generate
      summary: Create AI-generated template exports
      description: >
        Generates customer-ready copy from a prompt, applies it to a public Pixy

        template, renders all pages, and returns generated file metadata.


        This endpoint only accepts public template IDs. Pixy uses the template

        thumbnails plus text object layout metadata to keep headlines, body
        copy,

        calls to action, prices, dates, and captions in the correct places.
      operationId: generateAiTemplate
      parameters:
        - in: path
          name: designId
          required: true
          schema:
            type: string
          description: Public Pixy template identifier.
          example: clr123exampletemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateAiRequest'
            examples:
              default:
                summary: AI export with prompt
                value:
                  prompt: Black Friday sale for a minimalist skincare brand
                  format: jpeg
              pdf:
                summary: AI export as PDFs
                value:
                  prompt: Invite designers to a portfolio review night
                  format: pdf
      responses:
        '200':
          description: Successfully generated copy and rendered one or more output files.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateAiSuccessResponse'
              examples:
                success:
                  value:
                    id: run_123
                    designId: tpl_123
                    duration: 1842
                    files:
                      - url: >-
                          https://assets.example.com/generated/template-output-1.jpeg
                        previewUrl: null
                        size: 182441
                        width: 1080
                        height: 1920
                        mimetype: image/jpeg
                    ai:
                      prompt: Black Friday sale for a minimalist skincare brand
                      thumbnailUrls:
                        - >-
                          https://assets.example.com/templates/template-preview.jpeg
                      modifications:
                        - id: title-text
                          text: Glow More This Black Friday
                          autoFitText: true
        '400':
          description: The request path or body is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingPrompt:
                  value:
                    message: Prompt is required.
                invalidFormat:
                  value:
                    message: Invalid format. Supported values are png, jpeg, and pdf.
        '401':
          description: The bearer token is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  value:
                    message: Unauthorized
        '404':
          description: The requested public template could not be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notFound:
                  value:
                    message: >-
                      Public template does not exist or is not available for AI
                      export.
        '500':
          description: Pixy failed to generate, render, or export the template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                genericFailure:
                  value:
                    message: Something went wrong
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: javascript
          label: fetch
          source: >
            const response = await
            fetch('https://app.pixy.art/api/v1/YOUR_TEMPLATE_ID/generate-ai', {
              method: 'POST',
              headers: {
                Authorization: 'Bearer YOUR_API_KEY',
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                prompt: 'Black Friday sale for a minimalist skincare brand',
                format: 'jpeg',
              }),
            })


            const result = await response.json()


            console.log(result.files)
components:
  schemas:
    GenerateAiRequest:
      type: object
      additionalProperties: false
      required:
        - prompt
      properties:
        prompt:
          type: string
          minLength: 1
          description: >-
            Prompt describing the campaign, offer, audience, product, or message
            to generate into the public template.
          example: Black Friday sale for a minimalist skincare brand
        format:
          type: string
          enum:
            - png
            - jpeg
            - pdf
          default: jpeg
          description: >-
            Output format. Defaults to `jpeg`. `jpg` is also accepted and
            normalized to `jpeg`.
    GenerateAiSuccessResponse:
      type: object
      additionalProperties: false
      required:
        - id
        - designId
        - files
        - duration
        - ai
      properties:
        id:
          type: string
          description: Render run identifier.
        designId:
          type: string
          description: Public template identifier used for the render.
        duration:
          type: integer
          description: Total AI generation and render duration in milliseconds.
        files:
          type: array
          description: >-
            Rendered output files, one per generated page. When `format` is
            `pdf`, each page is returned as a separate PDF file.
          items:
            type: object
            additionalProperties: false
            required:
              - url
              - previewUrl
              - size
              - width
              - height
              - mimetype
            properties:
              url:
                type: string
                format: uri
              previewUrl:
                type:
                  - string
                  - 'null'
                format: uri
              size:
                type: integer
              width:
                type:
                  - integer
                  - 'null'
              height:
                type:
                  - integer
                  - 'null'
              mimetype:
                type: string
        ai:
          type: object
          additionalProperties: false
          required:
            - prompt
            - modifications
            - thumbnailUrls
          properties:
            prompt:
              type: string
            thumbnailUrls:
              type: array
              items:
                type: string
                format: uri
            modifications:
              type: array
              items:
                type: object
                additionalProperties: false
                required:
                  - id
                  - text
                  - autoFitText
                properties:
                  id:
                    type: string
                  text:
                    type: string
                  autoFitText:
                    type: boolean
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: Organization API key passed as a bearer token.

````