POST /generate
Generate a draft image with a model's AI clone
Renders a watermarked draft anchored to the model's canonical identity kit. Sparse prompts are automatically enhanced; every prompt receives Mirai's editorial house style and passes a safety scan before delivery.
Streaming transport: generation takes 1-5 minutes, so once it starts the HTTP status is ALWAYS 200 and the body streams heartbeat whitespace until the final JSON. Read the full body, then JSON.parse it (leading whitespace is valid JSON) and check for an error field before treating it as success. Pre-flight failures (auth, validation, entitlement) return real 4xx statuses with JSON bodies.
Supports the Idempotency-Key header.
Parameters
- Idempotency-Keyheader
- Any string unique to this logical request. Retries with the same key replay the stored result instead of re-rendering.
Request body · application/json
- model_idrequired
- uuidModel id from GET /models.
- promptrequired
- string · ≤4000 charsCreative direction. Sparse prompts are auto-enhanced; Mirai's house style is always applied.
- formatoptional
- portrait | landscape | square | portrait_4_3 | portrait_16_9 | landscape_4_3 | landscape_16_9 | square_hd · default portrait_4_3Output aspect preset (friendly aliases accepted: portrait, landscape, square).
- rendereroptional
- openai/gpt-image-2/edit | fal-ai/nano-banana-2/edit | bytedance/seedream/v5/pro/edit | fal-ai/flux-2-pro/editfal endpoint that should make the pixels. Omit for the house default. Selects the PRIMARY only: the fallback still applies, and the response reports what actually ran. Renderers outside this list are refused (code: renderer_not_approved); approved renderers Mirai does not drive itself are refused with the reference path named (code: renderer_not_available_here).
Responses
- 200GenerateImageResult | Error
- Streamed. Heartbeat whitespace followed by ONE JSON document — either GenerateImageResult or Error (in-body error with HTTP 200; see the streaming transport note).
- 400Error
- Missing model_id/prompt, prompt over the length cap, unsupported format (code: invalid_format), or brand country required for a region-restricted model (code: brand_country_missing).
- 401Error
- Missing, malformed, or revoked API key. Repeated failures are rate limited per IP.
- 402Error
- No active subscription / no remaining credits, or the subscription is past_due.
- 403Error
- Key missing the generate scope, model outside a trial's allow-list, or region restriction (code: region_restricted).
- 404Error
- Model not found or not on the bookable roster.
- 409Error
- Model not ready for generation (no reference photos), or a request with this Idempotency-Key is already in progress.
- 429Error
- Rate limit exceeded — 20 requests/minute per key, 40/minute per brand across all keys.