Add an AIGen-only generate API for external tools.

Cursor and similar clients can enqueue Studio 2 stills with the same steps and CFG the bench uses, through session or AIGEN_API_KEY.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-26 19:05:28 -05:00
co-authored by Cursor
parent 68469d9c71
commit 2b603b1d58
12 changed files with 399 additions and 9 deletions
+9 -3
View File
@@ -4,6 +4,7 @@ import { sectionsFrom, compileSections } from './prompt.mjs'
import { QWEN21_ASPECT_IDS, resolveQwen21Size } from './qwen21-size.mjs'
import { QWEN21_TURBO_CFG, QWEN21_TURBO_LORA, QWEN21_TURBO_SIGMAS, QWEN21_TURBO_STEPS } from './qwen21-turbo.mjs'
import { applyPhotosToRequest } from './photos.mjs'
import { studio2EngineDefaults } from './engine-defaults.mjs'
export { sectionsFrom } from './prompt.mjs'
export const cameraFamilies = ['static','dolly in','dolly out','pan left','pan right','tilt up','tilt down','zoom in','zoom out','orbit left','orbit right']
export const identityLock = '<Picture 1> / hero is identity for face, hair, glasses, body, and wardrobe. Keep the person and clothes fully preserved. Start frame is composition, pose, place, and camera only. Do not copy facial drift from the start frame.'
@@ -56,9 +57,14 @@ export function validateRequest(raw, xaigen = false) {
const number=(key, fallback, min, max) => { const n=Number(raw.settings?.[key] ?? fallback); if (!Number.isFinite(n)||n<min||n>max) fail(`Invalid ${key}.`); return n }
const qwen = engine === 'qwen21'
const moss = engine === 'moss'
const defaultSteps = video ? 8 : qwen || moss ? 25 : 24
const defaultCfg = video ? 1.5 : qwen ? 1 : moss ? 2.5 : 4
const aspect = QWEN21_ASPECT_IDS.has(raw.settings?.aspect) ? raw.settings.aspect : 'auto'
const imageDefaults = studio2EngineDefaults(engine)
const defaultSteps = video ? 8 : imageDefaults.steps
const defaultCfg = video ? 1.5 : imageDefaults.cfg
const requestedAspect = raw.settings?.aspect == null || raw.settings?.aspect === ''
? imageDefaults.aspect
: raw.settings.aspect
const aspect = QWEN21_ASPECT_IDS.has(requestedAspect) ? requestedAspect : 'auto'
const qwenSize = qwen && mode === 'generate' ? resolveQwen21Size(aspect) : null
const defaultWidth = qwenSize ? qwenSize.width : qwen || moss ? 1024 : 1344
const defaultHeight = qwenSize ? qwenSize.height : qwen || moss ? 1024 : 768