Skip to main content

Variants

Variants allow automatic transformations of property values when accessed via the API. Create variants on string or blob properties to generate transformed versions on-demand.

How Variants Work

  1. Create a variant on a property (string or blob)
  2. Define one or more transformation steps
  3. Access the transformed value using $variantName syntax
  4. Results are cached for performance

Available Transformers

TransformerProperty TypeDescription
TranslatestringTranslate text to different languages
Vision AI Image DescriptionblobGenerate AI descriptions of images
Image ResizeblobResize images to specific dimensions
Image GrayscaleblobConvert images to grayscale

Creating Variants

In the Developer Portal

  1. Navigate to your collection
  2. Select a string or blob property
  3. Click Add Variant
  4. Name your variant (e.g., "thumbnail", "spanish")
  5. Add transformation steps
  6. Save

Chaining Transformers

Each variant can have multiple transformation steps applied in sequence:

Original Image → Resize (200x200) → Grayscale → Output

This allows complex transformations like "resize then convert to grayscale" in a single variant.

Accessing Variants

Blob Properties (Images/Files)

Append the variant name to the blob field URL:

GET https://eu.restapi.com/my-api/products/<item-id>/image$thumbnail

Examples:

/products/abc-123/image$thumbnail      # Resized thumbnail
/products/abc-123/photo$grayscale # Grayscale version
/products/abc-123/image$small # Custom "small" variant

String Properties (Text)

Use the select parameter with the variant name:

GET https://eu.restapi.com/my-api/articles/<item-id>?select=description$spanish

Examples:

?select=content$spanish                # Translated to Spanish
?select=description$summary # Summarized version
?select=title,content$translated # Multiple fields with variant

Multiple Variants

Request multiple variants in a single call:

GET https://eu.restapi.com/my-api/articles/abc-123?select=title,content$summary,content$spanish

Returns the title plus both a summarized and translated version of content.

Use Cases

Image Transformations

Use CaseExample Variant
ThumbnailsResize to 150x150
Responsive imagesMultiple size variants (small, medium, large)
Optimized formatsConvert to WebP
Grayscale previewsRemove color

Text Transformations

Use CaseExample Variant
Multilingual contentTranslate to Spanish, French, German
Content previewsSummarize long articles
AccessibilityGenerate image descriptions

Benefits

BenefitDescription
No code requiredConfigure in the portal, no functions needed
Cached resultsTransformed content is cached automatically
On-demandOnly generated when first requested
ScalableRuns on serverless infrastructure

Example: Product Images

Create variants for different image sizes:

Variant NameTransformation
thumbnailResize to 100x100
cardResize to 300x200
detailResize to 800x600
heroResize to 1920x1080

Access them:

/products/abc-123/image              # Original
/products/abc-123/image$thumbnail # 100x100
/products/abc-123/image$card # 300x200
/products/abc-123/image$detail # 800x600

Example: Multilingual Content

Create translation variants for an article's description:

Variant NameTransformation
spanishTranslate to Spanish
frenchTranslate to French
germanTranslate to German

Access them:

?select=description                  # Original language
?select=description$spanish # Spanish translation
?select=description$french # French translation