Add asset-pack Image v2 API for Family Board stickers.

POST /api/assets/generate wraps Flux/Krea generate with sticker/panel/icon presets; GET /api/assets/{id} returns status and PNG URLs using the existing poll path.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-06 19:06:14 -05:00
co-authored by Cursor
parent f6c5ef8af5
commit 26a3bfb797
6 changed files with 530 additions and 0 deletions
+128
View File
@@ -0,0 +1,128 @@
# Asset pack API (Family Board stickers)
Thin HTTP wrapper around **Image v2 generate** for kid-UI stickers, panel backgrounds, and icons. Same Comfy queue, same auth, same poll pattern as Studio 2.
## Auth / LAN
Uses the same trust model as Image v2 (`POST /api/v2/generate`):
- If `NUXT_PUBLIC_AUTH_ENABLED=true`, send a logged-in session cookie (or log in first via `/login`).
- On the LAN, call the same Studio 2 base URL you already use (Coolify / thebeast host). Example: `https://aigen.<your-host>` or whatever Coolify publishes for this app.
- Do not invent a second token. If Image v2 works from thebeast, this works with the same credentials.
## Endpoints
| Method | Path | Purpose |
|--------|------|---------|
| `POST` | `/api/assets/generate` | Queue a sticker / panel / icon job |
| `GET` | `/api/assets/{id}` | Status + PNG URL when complete |
| `GET` | `/api/generate/{id}` | Same job (Image v2 poll) |
| `GET` | `/api/generate/{id}/stream` | SSE progress (Image v2) |
## Request body
```json
{
"prompt": "cheerful hedgehog-speed runner mascot with sneakers, original character",
"negative_prompt": "optional extra negatives",
"engine": "flux",
"width": 1024,
"height": 1024,
"transparent_friendly": true,
"style": "sticker",
"seed": null
}
```
| Field | Notes |
|-------|--------|
| `prompt` | Required. Your subject description (original characters — not trademarked IP). |
| `engine` | `flux` (default) or `krea`. Flux Klein / Krea turbo defaults from Image v2. |
| `style` | `sticker` (default), `panel_bg`, or `icon`. Expands into strong prompt prefixes/suffixes. |
| `width` / `height` | Snapped to 768 / 1024 / 1280. Defaults: sticker 1024², icon 768², panel_bg 1280². |
| `transparent_friendly` | Bias toward a plain / chroma-friendly background (default on for sticker/icon). |
| `negative_prompt` | Merged with a strong default (photoreal, watermark, Sonic/Mario/Minecraft/Nintendo/Sega/Mojang, NSFW, …). |
| `seed` | Number or `null` / omit for random. |
## Curl: sticker + poll
```bash
BASE='https://YOUR-AIGEN-HOST' # Studio 2 LAN / Coolify URL
# If auth is on, attach your session cookie: -H "Cookie: …"
JOB=$(curl -sS -X POST "$BASE/api/assets/generate" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "cheerful hedgehog-speed runner mascot with sneakers, original character",
"engine": "flux",
"style": "sticker",
"transparent_friendly": true,
"width": 1024,
"height": 1024
}')
echo "$JOB"
ID=$(echo "$JOB" | jq -r '.jobId')
# Poll until complete (or use /api/generate/$ID/stream)
while true; do
STATE=$(curl -sS "$BASE/api/assets/$ID")
STATUS=$(echo "$STATE" | jq -r '.status')
echo "$STATUS"
if [ "$STATUS" = "complete" ] || [ "$STATUS" = "error" ] || [ "$STATUS" = "cancelled" ]; then
echo "$STATE" | jq .
break
fi
sleep 2
done
# Download PNG (same auth cookie)
PNG=$(echo "$STATE" | jq -r '.pngUrl // .url')
curl -sS -o sticker.png "$BASE$PNG"
```
Krea turbo:
```bash
curl -sS -X POST "$BASE/api/assets/generate" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "blocky explorer buddy with pickaxe vibes, original character, cute",
"engine": "krea",
"style": "sticker"
}'
```
## Response (queue)
```json
{
"jobId": "…",
"studioJobId": "…",
"queued": true,
"pollUrl": "/api/assets/…",
"generatePollUrl": "/api/generate/…",
"streamUrl": "/api/generate/…/stream",
"engine": "flux",
"style": "sticker",
"width": 1024,
"height": 1024,
"prompt": "…expanded…",
"negative": "…"
}
```
## Response (complete)
`GET /api/assets/{id}` includes Image v2 snapshot fields plus:
- `pngUrl` / `url` — `/api/library/stills/{stillId}` (downloadable PNG)
- `urls` — array of the same
- `thumbUrl` — `?thumb=1`
- `complete` — `true` when `status === "complete"`
Files land in the existing library / artifacts layout (same as Image v2 generate).
## Out of scope (v1)
No rembg/alpha matte step required. No Studio 2 UI changes. No video / YuE changes. Do not prompt copyrighted character sheets by name.