Skip to main content

Image-to-Image

hy-image-v3.5-preview supports mixing text and reference images in messages, and feeding back the previous result for further editing.

Model​

Use the hy-image-v3.5-preview model with the cloudbase provider. Requires @cloudbase/js-sdk >= 3.11.0.

Parameters​

On top of the text-to-image parameters, image-to-image adds the following content blocks and parameters:

ParameterTypeRequiredDescription
contentArray<object>YesMix text and image_url content blocks in the same round
image_url{ url: string }NoReference image, public URL or data:image/...;base64,...
resize_max_pixelsintegerNoArea limit for reference images, default 1048576; larger images are scaled down
sessionstringNoKeep the same value for multi-round editing
Reference Image Requirements
  • PNG, JPEG, JPG
  • Up to 20MB per image, at most 20 images
  • Prefer public CDN URLs without authentication

Usage Example​

const imageModel = ai.createImageModel("cloudbase");

const res = await imageModel.generateImage({
model: "hy-image-v3.5-preview",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Draw a cat in the style of this image" },
{ type: "image_url", image_url: { url: "https://example.com/reference.jpg" } },
],
},
],
});

console.log(res.choices[0].delta.image.url);

Multi-Round Editing​

Append the assembled_history from the previous response to messages, then add the new user message:

const firstMessages = [
{
role: "user",
content: [
{ type: "text", text: "Draw a cat in the style of this image" },
{ type: "image_url", image_url: { url: "https://example.com/reference.jpg" } },
],
},
];

const firstRes = await imageModel.generateImage({
model: "hy-image-v3.5-preview",
session: "demo-session-001",
messages: firstMessages,
});

const secondRes = await imageModel.generateImage({
model: "hy-image-v3.5-preview",
session: "demo-session-001",
messages: [
...firstMessages,
...firstRes.assembled_history,
{ role: "user", content: [{ type: "text", text: "Change the cat to a ragdoll and move it next to a fireplace" }] },
],
});

Access Methods​