AI Template Generation
Tag: AI ยท Version: v1 ยท Stability: ๐ Experimental (v0)
Generate an editable template draft from a reference image and/or a text description. The model returns a structured element list; the platform loads it into the designer as a fresh draft you refine and save โ so AI is just another template author, never a new render path.
:::warning Experimental โ v0
This endpoint is feature-flagged (Ai:Enabled) and its behaviour and
response shape may change without a major-version bump. Prototype with it; don't
build production dependencies on its output yet. Generations are metered under
the ai source.
:::
:::note Free-tier quota
The free tier allows 25 AI generations per month per workspace. Exceeding
the quota returns 402 Payment Required. The count resets on the 1st of
each calendar month.
:::
Generate a templateโ
POST /api/ai/generate-template ยท JWT
Accepts an optional image and/or optional prompt (multipart, like the base-PDF upload). The image carries the layout in one shot; the prompt refines it ("like this, but a blue accent + add a discount row"). The combination is the most powerful input.
Returns a suggested name and an element list that the designer expands
onto a new draft via its normal createElement path.
curl -X POST http://localhost:5110/api/ai/generate-template \
-H "Authorization: Bearer <jwt>" \
-F "prompt=A modern invoice with a logo top-left and a totals table" \
-F "image=@reference.png"
Honest expectationsโ
Image โ layout is a draft, not a pixel-perfect clone. The model nails structure and placement; coordinates, fonts, and colours come out approximate. Treat it as "80% of the layout in seconds โ finish in the designer."
Data handlingโ
The image and/or prompt are sent to the model provider (Anthropic) for generation. Fine for typical use; a no-retention / on-prem path is planned for high-compliance tiers.