Docs/Image Generation

User Guide · 2.4.1 Release

How do I design a good image recipe?

Pick an onboarding path, then tune parameters, sizes, reference images, and async polling

Read Markdown
On this page

What is AI Image Recipe onboarding? covers the workflow for connecting a model to the workspace; this guide focuses on designing the recipe itself—how to declare clean parameters and when to use asynchronous tasks. It applies equally to AI-assisted onboarding and manual editing.

Choosing among the three onboarding paths#

  • AI onboarding: Best when you have official API documentation or a working cURL command. The AI reads the spec, runs real test generations, and saves after verification; if the provider is not configured yet, it creates the provider and saves the key securely first.
  • Built-in preset starting point: When a model already has a built-in adapter (gpt-image, Images API, Grok, Imagen, Gemini Image, chat image) and you only want to tweak or add parameters, choose Built-in preset in the recipe editor—the app generates an equivalent starting recipe using your provider's endpoint so you can make quick edits and save.
  • Manual template: When the API is unusual or you are comfortable editing JSON, start from the five starter templates (Chat Image / Native Bailian / Images API / Image-to-Image / Async Task) and rely on Validate and Test in the editor.

Parameter panel: turn settings into taps#

Parameters declared in a recipe render directly as controls in the workspace. Pick the control type that matches each parameter's values:

  • Fixed enumerations (sizes, quality levels, style presets): use selectable chips so users do not have to type error-prone strings.
  • Bounded numbers: use a stepper or slider.
  • Yes/no options: use a toggle switch; freeform text (seeds, style notes): use a text input.
  • Parameters support conditional visibility: for instance, only showing a secondary option when a primary parameter has a specific value.

For endpoints supporting arbitrary pixel dimensions, declare customSize with width/height mappings and constraints (multiples, min/max pixels) so the workspace can generate custom sizes freely without enumerating dozens of preset options.

Reference images: one recipe for two modes#

An image parameter (up to 4 images) unlocks image-to-image in the workspace. Declaring it as optional (required: false) automatically omits the injection point in the request body whenever no image is attached—letting a single recipe handle text-to-image without images and image-to-image with images, without failing due to empty fields. For APIs that split MIME type and data into separate fields, use the .mime and .base64 sub-keys.

Async tasks: the fix for slow models#

If generations repeatedly fail after one or two minutes with a message like "gateway closed the connection early," an intermediate relay or proxy is likely cutting off long-lived HTTP connections—the image may already be finishing on the server even though the response never arrives. Switch to an async recipe to split a single long wait into two steps:

  1. Submit: Send the initial request and extract the job ID (taskIdPath) from the response.
  2. Poll: Query the job status periodically via pollUrlTemplate, and extract the final image once a success status is returned.

The default polling budget is about 10 minutes with adaptive intervals and automatic backoff on rate limits (HTTP 429); if it times out, the app notes that the job may still be running server-side. Start from the Async Task template in the editor; any API that returns a task ID first and requires polling for results fits this pattern.

Image count & queuing#

A recipe declares the maximum images per request (1–4 images). Pro users can additionally configure concurrency and queue length to keep queueing while generations run, with automatic rescheduling on HTTP 429 rate limits so prompts are never lost.

FAQ#

  • Does saving a recipe break built-in adapters? — A saved recipe takes over that model; deleting the recipe restores the app's built-in auto-detection while keeping the model and API key intact.
  • Is image-to-image a Pro feature? — Text-to-image, image-to-image, and recipe generation all require no Pro; free users can run 1 task at a time, while multi-task submission, queuing, and concurrency are Pro features. Model API usage is billed by your provider.
  • Want to reuse a recipe across providers? — Ask the AI to copy the recipe onto the same model under another provider; only recipes using the relative {{baseUrl}} URL template can be reused across providers.