Orshot Logo
OrshotDocs

POST: Generate Template Variants

Generate multiple size variants of a template using AI

Enterprise Only

This is an Enterprise only private endpoint. Checkout the Enterprise Pricing to get access.

Generate multiple size variants of an existing studio template using AI-powered layout adaptation. The AI intelligently repositions and resizes elements to fit new dimensions while maintaining visual hierarchy and design integrity.

By default, generated variants are added as new pages to the source template. You can also create them as separate templates using the output parameter.

AI Credits

Each variant generated consumes 1 AI credit from your plan. Credits are validated before generation and deducted after successful completion.

Endpoint

https://api.orshot.com/v1/studio/templates/:templateId/generate-variants

Request

// Add variants as new pages to the same template
await fetch("https://api.orshot.com/v1/studio/templates/12345/generate-variants", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <ORSHOT_API_KEY>",
  },
  body: JSON.stringify({
    variants: [
      { width: 1080, height: 1080 },
      { width: 1080, height: 1920 }
    ],
    output: "pages"
  }),
});
// Create new templates for each variant
await fetch("https://api.orshot.com/v1/studio/templates/12345/generate-variants", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <ORSHOT_API_KEY>",
  },
  body: JSON.stringify({
    variants: [
      { width: 1080, height: 1080 },
      { width: 1080, height: 1920 },
      { width: 1200, height: 628 }
    ],
    output: "templates"
  }),
});
{
  "success": true,
  "source_template_id": 12345,
  "source_page": 1,
  "output_mode": "pages",
  "variants": [
    {
      "variant_index": 0,
      "width": 1080,
      "height": 1080,
      "page_index": 1,
      "page_id": "generated-page-uuid-1",
      "page_name": "Square"
    },
    {
      "variant_index": 1,
      "width": 1080,
      "height": 1920,
      "page_index": 2,
      "page_id": "generated-page-uuid-2",
      "page_name": "Story"
    }
  ]
}
{
  "success": true,
  "source_template_id": 12345,
  "source_page": 1,
  "output_mode": "templates",
  "variants": [
    {
      "variant_index": 0,
      "width": 1080,
      "height": 1080,
      "template_id": 12346,
      "template_name": "Square"
    },
    {
      "variant_index": 1,
      "width": 1080,
      "height": 1920,
      "template_id": 12347,
      "template_name": "Story"
    },
    {
      "variant_index": 2,
      "width": 1200,
      "height": 628,
      "template_id": 12348,
      "template_name": "OG Image"
    }
  ]
}

Rate Limits

LimitValue
Requests per minute30
Max variants per request10

URL Parameters

ParameterTypeRequiredDescription
templateIdIntegerYesThe ID of the source template to generate variants from

Request Body Parameters

ParameterTypeRequiredDefaultDescription
variantsArrayYes-Array of target dimensions for variants
page_numberIntegerNo1Which page of the template to use as source
outputStringNo"pages"Output mode: "pages" or "templates"

Variant Object Structure

Each variant in the variants array should include:

FieldTypeRequiredDescription
widthIntegerYesTarget width in pixels (1-5000)
heightIntegerYesTarget height in pixels (1-5000)
nameStringNoCustom name for the generated page or template

Output Modes

ModeDescription
pagesAdds each variant as a new page to the source template
templatesCreates a new template for each variant in the same workspace

Response Fields

Common Fields

FieldTypeDescription
successBooleanWhether the operation was successful
source_template_idIntegerID of the source template
source_pageIntegerPage number used as source
output_modeStringThe output mode used
variantsArrayArray of generated variant results

Variant Result Fields (varies by output mode)

FieldOutput ModeTypeDescription
variant_indexAllIntegerIndex of this variant in the request
widthAllIntegerWidth of the variant
heightAllIntegerHeight of the variant
page_indexpagesIntegerIndex of the new page in the template
page_idpagesStringUUID of the new page
page_namepagesStringName of the new page
template_idtemplatesIntegerID of the newly created template
template_nametemplatesStringName of the newly created template
errorAllStringError message if this variant failed

How AI Variant Generation Works

The AI analyzes your source design and intelligently adapts it to new dimensions:

  1. Element Analysis: Identifies element types, positions, and relationships
  2. Hierarchy Detection: Understands which elements are backgrounds, headlines, images, etc.
  3. Layout Adaptation: Repositions and resizes elements to fit new dimensions
  4. Proportion Preservation: Maintains relative sizes and spacing relationships
  5. Text Handling: Adjusts text box sizes and font sizes to prevent overflow

Supported Transformations

FromToBehavior
LandscapeSquareStacks elements vertically, enlarges hero images
LandscapePortraitVertical stacking, maximizes vertical space usage
SquareLandscapeHorizontal arrangement, side-by-side layout
PortraitSquareRedistributes vertical space

Error Responses

Status CodeErrorDescription
400Validation failedInvalid variants array or dimensions
400Invalid page_numberSpecified page doesn't exist in template
403Insufficient AI creditsNot enough AI credits available
403Access ForbiddenInvalid API key or template not in workspace
404Template not foundTemplate ID doesn't exist
429Rate limit exceededToo many requests (max 30/min)
500Internal server errorAI generation or server error

Best Practices

  1. Source Quality: Use a well-designed source template for best AI results
  2. Batch Sizes: Generate up to 10 variants per request for optimal performance
  3. Output Selection:
    • Use pages to keep all variants in one template (carousels)
    • Use templates for independent templates that render separately
  4. Page Selection: For multi-page templates, specify which page to use as source
  5. Dimensions: AI works best when aspect ratio changes aren't too extreme

On this page