Generation API
Generate templates, backgrounds, resolved brand-element briefs, and apply-ready Design Lab sequences with the versioned JSON contract.
POST /api/generate accepts application/json. The request kind selects one of four generators.
Output selection
output: "json"is the default for SVG generators. The response contains metadata andartifact.content.output: "raw"returnsimage/svg+xmldirectly.element-briefalways returns JSON.design-sequencereturns an apply-ready Design Lab document, its resolved shader timeline, and browser API commands.
Design sequence
Design sequence creates the same versioned composition used by Design Lab. It supports an identity-aware brand mark, multiple text layers, a Bayer/ASCII/halftone/posterize converter, any material returned by /api/materials, 8–12 cuts, and a 3–6 second final hold.
{
"kind": "design-sequence",
"identity": { "preset": "gt" },
"ratio": "wide",
"backgroundColor": "#111216",
"shader": {
"materialId": "paper-gem-smoke",
"shaderSize": 1
},
"sequence": {
"cutCount": 10,
"finalHoldMs": 5000,
"pace": "accelerating"
},
"effect": {
"kind": "bayer",
"opacity": 0.76,
"foreground": "#F5F5F2",
"background": "#111216"
},
"texts": [{ "value": "Open Source", "weight": 500 }],
"export": { "width": 1920, "fps": 30, "quality": "best" }
}The response is JSON with:
schemaVersion: 1: the HTTP response-envelope version.document: an apply-ready Design Lab compatibility source withversion: 3.sequence.timeline: resolved material IDs and cut boundaries.automation: the stable browser global and exact apply/export commands.
document.version is not the active canvas schema. applySource(response.document) validates and migrates the compact compatibility source, then the Design Lab adapter exposes the normalized result as CanvasDocument schema 2 with Design Lab source metadata version 4. Re-read source after application before making targeted CanvasDocument edits.
Apply and render inside /studio:
await window.glyphfield.studio.applySource(response.document);
const artifact = await window.glyphfield.studio.invoke(
'design.export',
{ format: 'mp4', mode: 'shader-sequence', download: true }
);Choose png, jpg, gif, or mp4. Shader-sequence mode is available for GIF and MP4. The export action resolves to the real UI artifact object and uses the authentic shader canvases, composition effects, text, marks, layer order, and output settings; download: true also saves it.
Template
Template generates slides, blog covers, and partnership lockups.
{
"kind": "template",
"template": "slides",
"slideLayout": "agenda",
"texture": "white",
"title": "One system, every market.",
"body": "Foundation\nExpression\nApplication\nDelivery",
"identity": { "preset": "gt" },
"output": "raw"
}Template enums
template:slides | blog | partnershiptexture:white | dark | grid | noiseslideLayout:title | section | agenda | split | metrics | quote | timeline | statement | comparison | process | chart | team | image | closing
Fixed output sizes are 1600 × 900 for slides, 1200 × 630 for blog, and 1200 × 600 for partnership.
Background
Background generates gradient, grain-gradient, dither, and pattern SVGs.
{
"kind": "background",
"identity": { "preset": "gt" },
"settings": {
"width": 1200,
"height": 630,
"style": "grain-gradient",
"gradient": "mesh",
"angle": 32,
"colorA": "#FFFFFF",
"colorB": "#181818",
"colorC": "#737373",
"focalX": 42,
"focalY": 38,
"relief": 24,
"grain": 18,
"pattern": "dots",
"patternOpacity": 14,
"spacing": 24,
"logoTone": "black",
"logoScale": 24,
"logoOpacity": 100,
"logoX": 0,
"logoY": 0
},
"output": "raw"
}Width and height must each be 64–4096, and the total may not exceed 12,000,000 pixels.
Element brief
Element brief resolves a stable record from /api/elements against an identity.
{
"kind": "element-brief",
"elementId": "email-signature",
"identity": {
"preset": "custom",
"name": "Acme",
"website": "acme.test",
"tagline": "Tools for careful teams."
}
}The response describes the element, dimensions, format, keywords, resolved identity, settings, and preview family. It does not rasterize an image.
JSON artifact envelope
{
"schemaVersion": 1,
"artifact": {
"content": "<svg ...>...</svg>",
"filename": "gt-slides-agenda.svg",
"mimeType": "image/svg+xml",
"width": 1600,
"height": 900
}
}Check schemaVersion, mimeType, and dimensions before storing the content.
Studio source is a separate contract
The Code drawer inside /studio serializes the active browser tool. It supports exact edits for identities, boards, Animation, Lottie, Design Lab, templates, foundations, and components. Design Lab uses CanvasDocument schema 2 with Design Lab metadata source version 4. Browser documents are intentionally shaped around each interactive tool and are not interchangeable with the POST /api/generate request body.
Use the HTTP contract on this page for deterministic remote generation. design-sequence is deliberately a bridge: it emits a compact, apply-ready compatibility document for programmatic browser rendering, and the browser normalizes it to current Studio source. For every other tool, use the active window.glyphfield.studio API to read/apply source or operate visible controls.