Docs/Image Generation

User Guide · 2.4.1 Release

Connect your own image model

Step-by-step setup, including Alibaba Cloud Bailian

Read Markdown
On this page

Have your own image API key? Here is how to connect it#

For models that use image APIs already built into Cube Agent, configure your API key under Settings → Models & usage → Provider Management, enable the model, turn on its Image Generation capability, and select it in the Image Generation workspace. For native non-standard APIs—such as Alibaba Cloud Bailian (Model Studio)—use Add Model via AI so the AI can build and test an image recipe directly from official documentation.

A "recipe" is simply the declarative calling configuration for that model. You do not need to know how to write JSON beforehand—just provide the provider, exact model ID, region, and API documentation. Simply enabling the "Image Generation" capability toggle only adds the model to the picker; it does not automatically convert a chat API into an image generation API.

Step 1: Prepare your provider and model#

Configure your API key in Provider Management; if it is already configured, reuse it directly without pasting it into chat again. If you have not set up the provider yet, you can also use Save a Key inside the AI onboarding session and let the AI create the provider for you.

For Alibaba Cloud Bailian users, prepare:

  • Your model-calling API Key from the Bailian console—do not use an Alibaba Cloud AccessKey ID / Secret instead. See Get an Alibaba Cloud Bailian API Key.
  • The exact Model ID, such as wan2.6-t2i; make sure the model is enabled and callable in your region according to the console and model docs.
  • Your region and API Host. Your key, model, and endpoint URL must match; if a workspace domain in the docs contains {WorkspaceId}, replace it with your own workspace ID. Your existing Bailian chat configuration can stay as-is—the image endpoint lives inside that model's recipe.

Step 2: Choose an AI model to assist with setup#

On first use, go to Settings → Models & usage → Provider Management → Let AI help configure it, select a working text chat model that supports tool calling, enter the management session, and then return.

This is the "assistant AI that reads documentation and configures the API"—it can be completely different from the "image model that draws pictures." Image-only models cannot act as the setup assistant.

Step 3: Open AI image onboarding, read docs, and build the recipe#

Open Image Generation workspace → top model selector (shows "Image Model" when none is selected) → Add Model via AI. The workspace can also be opened from Settings → Assistant capabilities → Image Generation.

AI image onboarding enables web research by default, independent of your regular chat web search toggle. It prioritizes any configured search service and falls back to key-free basic search and webpage reading if none is configured. You can switch search services or disable web research from the input bar; turning it off is remembered.

You can simply ask the AI to "look up the official Bailian documentation for this model," or paste documentation links directly. The AI should inspect the full request and response documentation before writing the recipe—search snippets alone are not reliable enough to confirm API fields. If a webpage cannot be fetched, paste the official request example, response example, and parameter reference into chat.

Copy the template below into AI Image Recipe onboarding and fill in the bracketed fields:

Please connect my Alibaba Cloud Bailian image generation model to the Image Generation workspace.
Provider name: [Provider name already configured in the app]
Model ID: [Exact model ID]
Region & API Host: [Region and actual endpoint URL from the console]
Goal: Start with text-to-image, 1 image per request.
First read my existing configuration, then look up and read the official API documentation for this model to confirm the endpoint URL, required headers, size parameters, and response format; if it is an asynchronous API, configure task polling as well.
Test the recipe using the API key already configured on this provider—do not ask me to paste the key again.
Show me the generated test image before asking me to confirm saving, and tell me how to select it back in the workspace.

Official Bailian references: Qwen-Image, Wan Text-to-Image. Different models and versions may use different API formats—never blindly reuse another model's endpoint, dimensions, or recipe. Bailian's compatible-mode chat endpoint cannot be used directly to call these native image generation APIs.

Step 4: Confirm saving only after seeing a real test image#

The AI's recipe test runs locally on your device using the target provider's active API key; the plaintext key is never returned to the AI in tool output. Test images appear in an artifact card inside the session—getting a task ID, passing a connection check, or hearing the AI say "it's configured" is no substitute for seeing an actual generated image.

After verifying the test image, check the provider and model in the recipe save confirmation panel. Both the management model chat and the image test may consume quota on their respective providers—start by testing 1 image, and scale up only after it succeeds.

Step 5: Use it back in the workspace#

Return to the Image Generation workspace, open the model picker, choose your newly saved model under Custom Recipes, enter a prompt, and generate. You can refine it anytime via Edit Recipe in Generation Settings; if generation fails later, copy the error from the workspace and return to AI Recipe Session History to troubleshoot.

Troubleshooting#

  • Tapping Add Model via AI opens the manual editor instead: No usable AI management model has been selected yet. Complete Step 2 first, then return to the workspace.
  • No web search tool or lookup fails: Check the web search toggle in the input area; enable or switch search services, or paste the complete API documentation directly. Even with web research off, you can still test existing recipes using saved keys, but the AI should not guess fields when documentation is missing.
  • Model does not appear in the workspace: Verify that the recipe was actually saved to the target provider/model and that the model is enabled; saving a valid recipe automatically adds image-output capability. Saving only a provider API key does not complete image onboarding.
  • Chat works, but image generation errors out: Check the native image endpoint URL, model ID, region, and response extraction paths. Do not fix image generation by changing the entire provider's chat path.
  • Error says synchronous calls are unsupported, or only a task_id is returned: Ask the AI to check the model's async API docs. Recipes support non-auth request headers (such as X-DashScope-Async: enable) and task polling; the recipe must wait for task completion and extract the final image.
  • Want to use reference images: Confirm first that the specific model supports image editing, then ask the AI to configure reference image parameters; a text-to-image recipe does not automatically become an image-to-image recipe. Image-to-image recipes do not require Pro.

Users familiar with the API can also edit recipes manually. The DashScope and Async templates in the editor are starting points—adjust the URL, parameters, headers, and extraction paths according to the actual model documentation and run a test before relying on them; they are not universal one-click presets for every Bailian model.