# What is AI Image Recipe onboarding?

> Cube Agent 2.4.1 Release (Build 2004105) User Guide.
> Category: Image Generation. Content baseline: 2026-12-05.
> Web page: https://cubeagent.app/en/docs/recipe_onboarding/

## What it can do

The Image Generation workspace includes built-in support for common image API paradigms such as OpenAI Images, Gemini, Imagen, and Grok, but image APIs vary widely across providers (parameter names, request body layouts, and where images live in responses all differ), making it impossible to hardcode every one. **AI Image Recipe onboarding** hands those non-standard models over to AI: paste the API docs or describe what you need in a dedicated management session, and the AI probes the endpoint, iterates on errors, verifies an actual generated image, and saves the result as a **recipe** so the model works in the workspace just like built-in models.

Open it via **Image Generation workspace → top configuration pill → model picker → Add Model via AI**. Like AI Provider Management, it runs in a dedicated management session: the title bar clearly labels the active mode, and the session is saved automatically for resuming without cluttering your normal conversation list.

## What is a recipe

A recipe is a declarative specification describing everything required to call an image generation API:

- **Endpoint & authentication**: A URL template (`{{baseUrl}}` is replaced with the owning provider's Base URL) and auth scheme; API keys are always referenced from the owning provider and never stored inside the recipe.
- **API request headers**: `requestHeaders` declares fixed non-auth headers required by the endpoint (such as Bailian's async header); auth headers are attached automatically from the provider key—never put keys inside a recipe.
- **Request body template**: Any JSON structure with placeholders (`{{prompt}}`, `{{modelId}}`, `{{count}}`, `{{param.<name>}}`), so platform-specific layouts (for example, `content` requiring an array structure) can be represented directly.
- **Parameter schema**: Aspect ratio, size, style, seed, and other parameters with their valid values. The workspace's Generation Settings panel renders dynamically from this schema—undeclared parameters never appear, so each model's settings panel shows only options it genuinely supports. APIs that accept arbitrary pixel dimensions can also declare `customSize`, mapping the workspace's width × height inputs to a combined `size` parameter or separate `width` / `height` parameters with min/max bounds, pixel limits, and multiple constraints; when Custom Size is off, standard preset dimensions from the parameter table remain available.
- **Extraction paths**: Declares where images live in the response (supporting array expansion and field filtering) as well as where error messages appear, backed by an automatic deep-scan fallback if extraction fails.

Each recipe is attached to a specific model; once saved, that model is automatically tagged with image-output capability.

## Things you can say directly

- "Help me connect SiliconFlow's Seedream; I've pasted the API docs below."
- "This new relay uses the same API as Provider A—reuse Provider A's image recipe on the same model here."
- "Image generation failed with: {paste the error copied from the workspace}. Please fix the recipe."

The AI reads your real local configuration before taking action. If the target service is not yet configured as a provider, it creates the provider with its endpoint and key first before testing. **A real test image must be generated and verified before saving**—the test image appears right inside the session. Saving requires your explicit confirmation, and the AI will not claim setup is done beforehand.

## Reusing recipes across providers

When multiple providers expose the same model at different endpoints, a recipe can be reused directly: tell the AI which provider's matching model to copy it to, and it will adapt the recipe, verify image output against the new provider, and save after confirmation. Only recipes whose URL template uses the relative `{{baseUrl}}` form can be reused across providers; recipes with hardcoded full URLs (such as native DashScope official endpoints) cannot be reused across different providers.

## Security & cleanup

- API keys can be stored locally via the **Save a Key** button in the input bar (only a masked reference appears in chat—the model never sees plaintext keys), or reused directly from already configured providers.
- Every recipe save and provider modification requires your confirmation; web search can be toggled and switched right in the input bar.
- Test images generated during probing remain accessible inside that management session and are cleaned up automatically when you delete the session, leaving no stray files behind.

## Workspace integration & one-tap cloud recipes

- **Cloud recipes & zero-config Bailian defaults**: The workspace includes built-in default image recipes for Alibaba Cloud Bailian pay-as-you-go and Token Plan (covering Qwen-Image 2.0/3.0/Plus/Max/Edit, Wan 2.6/2.7, Z-Image, and more)—just configure your provider key and start generating. It also matches cloud-adapted models for one-tap application and further tweaking anytime. Bailian, Gemini, and chat-based image models all support multi-image reference image-to-image.
- Recipe-powered models display a gradient dot badge on the top configuration pill; at the bottom of Generation Settings, open **Request Preview** to inspect the exact request assembled from your current parameters (with keys redacted), making troubleshooting immediate.
- When generation fails, the error row provides two shortcuts: **Copy** (copies full error context including provider and model details to bring into an AI session) and **Edit Recipe** (jumps straight into the recipe editor with the error attached for manual fixes).

## Manual editing

You can also manage recipes without using AI: when a selected model has no recipe yet, Generation Settings shows **Set up a recipe for this model**; when a model already has a built-in adapter (gpt-image, Gemini Image, Imagen, Grok, etc.), the entry reads **Tweak recipe from the builtin preset**, automatically generating an equivalent starting recipe in the editor so you can adjust parameters and save without starting from scratch. The GPT Image preset supports up to 4 reference images and automatically switches to the file-upload edit endpoint once reference images are added; older GPT presets that retained their original name and structure are upgraded on load while keeping existing parameters and saved JSON intact. Gemini Image and chat-image presets support a single reference image. Models that already have a recipe show **Edit Recipe** in Generation Settings. The editor also includes several starter templates (OpenAI-compatible chat image / native DashScope / Images API / image-to-image / async task), complete with JSON validation, live test generation, and saving. Deleting a recipe in the editor clears only the recipe while keeping the model and API key (models with built-in adapters revert to their preset behavior). Switching the target provider or model before saving clones the recipe there. If you have not chosen an AI management model yet, tapping **Add Model via AI** opens the manual editor first; set a management model in Provider Management to enable AI onboarding.

## Best practices for first-try success

1. **Prepare source docs**: Official API documentation text or a working cURL example works best—endpoint URL, request body, and **response example** are all essential because the response example determines image extraction paths. Only fall back to verbal descriptions if no docs exist.
2. **Connect one model at a time**: Onboard and verify on the most reliable official endpoint first, then ask the AI to copy the recipe to relays offering the same model. Remember that only recipes using relative `{{baseUrl}}` templates can be reused across providers.
3. **Close the error loop**: When generation fails in the workspace, use **Copy** on the error row to pass full context to the AI—far more effective than saying "it failed"—or use **Edit Recipe** to fix it yourself.
4. **Verify before batching**: Always confirm a real test image before saving; after saving, inspect **Request Preview** at the bottom of Generation Settings to verify parameters before running batch generations.
5. **Never paste plaintext keys**: Use the **Save a Key** button in the input bar or reuse an already configured provider key.

## Current boundaries

When text-to-image and image-to-image use different endpoints, you can declare `editRequest` (containing `urlTemplate`, `requestEncoding`, and `bodyTemplateJson`): this branch is used when reference images are attached, while the main template is used when no reference images are present; parameters, authentication, and response extraction rules are shared. Image parameters may also be referenced exclusively inside `editRequest`. The built-in GPT Image preset already uses this setup.

Declaring an `image` parameter in the parameter schema unlocks reference images (image-to-image); pure text-to-image recipes without an `image` parameter do not support references. Reference images are injected inline as base64; optional image parameters (`required: false`) automatically omit their injection slot when no reference image is provided, allowing one recipe to cover both text-to-image and image-to-image. Single-image parameters also support `{{param.<key>.mime}}` and `{{param.<key>.base64}}` sub-keys (for endpoints like Gemini's native `inline_data` that separate MIME type and base64 payload). File-upload endpoints (such as OpenAI `images/edits`) can set `requestEncoding` to `multipart/form-data`: describe form fields as a flat top-level object in `bodyTemplateJson` (plain fields as strings, numbers, or booleans; image fields referencing `{{param.<key>}}` directly under the required field name such as `image` or `image[]`). Multiple images upload under the same field name; nested objects, arrays, and `.mime` / `.base64` sub-keys are not supported in multipart mode. Omitting `requestEncoding` preserves standard JSON behavior. For APIs that submit a job and poll for results, use the recipe's `async` section (see **How do I design a good image recipe?**).
