Templates

Browse and use pre-built templates (presets) for consistent image generation.

GET/v1/presets

List all available templates/presets. Includes both system templates and your custom templates.

Headers

Authorization: Bearer YOUR_API_KEY

Query Parameters

ParameterTypeDefaultDescription
limitinteger50Number of templates to return. Max: 100.
offsetinteger0Number of templates to skip.
categorystringallFilter by category: lifestyle, studio, seasonal, custom
typestringallFilter by type: system, user

Example Request

curl "https://api.productai.photo/v1/presets?category=lifestyle&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success Response (200 OK)

{
  "presets": [
    {
      "preset_id": "preset_marble_table",
      "name": "Marble Table",
      "description": "Product on elegant marble surface with soft lighting",
      "category": "lifestyle",
      "type": "system",
      "thumbnail_url": "https://cdn.productai.photo/presets/marble_table_thumb.jpg",
      "prompt": "Place the product on a white marble table with soft natural lighting, minimalist background",
      "recommended_models": ["nanobanana2", "nanobananapro"],
      "created_at": "2024-01-01T00:00:00Z"
    },
    {
      "preset_id": "preset_outdoor_nature",
      "name": "Outdoor Nature",
      "description": "Natural outdoor setting with greenery",
      "category": "lifestyle",
      "type": "system",
      "thumbnail_url": "https://cdn.productai.photo/presets/outdoor_nature_thumb.jpg",
      "prompt": "Product in a natural outdoor setting with green plants and soft sunlight",
      "recommended_models": ["nanobanana2", "kontext-pro"],
      "created_at": "2024-01-01T00:00:00Z"
    }
  ],
  "total": 45,
  "limit": 10,
  "offset": 0,
  "has_more": true
}

Response Fields

FieldTypeDescription
preset_idstringUnique identifier. Use this in the generate endpoint.
namestringDisplay name of the template.
descriptionstringBrief description of the template style.
categorystringTemplate category.
typestringsystem (built-in) or user (custom).
promptstringThe prompt used by this template.
recommended_modelsstring[]Models that work best with this template.
GET/v1/presets/{preset_id}

Get details for a specific template.

Example Request

curl "https://api.productai.photo/v1/presets/preset_marble_table" \
  -H "Authorization: Bearer YOUR_API_KEY"

Success Response (200 OK)

{
  "preset_id": "preset_marble_table",
  "name": "Marble Table",
  "description": "Product on elegant marble surface with soft lighting",
  "category": "lifestyle",
  "type": "system",
  "thumbnail_url": "https://cdn.productai.photo/presets/marble_table_thumb.jpg",
  "preview_images": [
    "https://cdn.productai.photo/presets/marble_table_preview_1.jpg",
    "https://cdn.productai.photo/presets/marble_table_preview_2.jpg"
  ],
  "prompt": "Place the product on a white marble table with soft natural lighting, minimalist background",
  "recommended_models": ["nanobanana2", "nanobananapro"],
  "usage_count": 15420,
  "created_at": "2024-01-01T00:00:00Z"
}

Using Templates with Generate API

Pass the preset_id to the generate endpoint instead of a custom prompt:

curl -X POST "https://api.productai.photo/v1/generate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nanobanana2",
    "image_url": "https://example.com/product.jpg",
    "preset_id": "preset_marble_table"
  }'

You can also combine a template with additional prompt instructions:

{
  "model": "nanobanana2",
  "image_url": "https://example.com/product.jpg",
  "preset_id": "preset_marble_table",
  "prompt": "Add a small plant in the background"
}

Code Examples

Python

import requests

# List templates
response = requests.get(
    "https://api.productai.photo/v1/presets",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={"category": "lifestyle", "limit": 10}
)
presets = response.json()["presets"]

# Generate with template
response = requests.post(
    "https://api.productai.photo/v1/generate",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "model": "nanobanana2",
        "image_url": "https://example.com/product.jpg",
        "preset_id": presets[0]["preset_id"]
    }
)
print(response.json())

JavaScript

// List templates
const presetsResponse = await fetch(
  "https://api.productai.photo/v1/presets?category=lifestyle&limit=10",
  { headers: { "Authorization": "Bearer YOUR_API_KEY" } }
);
const { presets } = await presetsResponse.json();

// Generate with template
const generateResponse = await fetch("https://api.productai.photo/v1/generate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "nanobanana2",
    image_url: "https://example.com/product.jpg",
    preset_id: presets[0].preset_id
  })
});
console.log(await generateResponse.json());

Related