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:
| Parameter | Type | Required | Description |
|---|---|---|---|
content | Array<object> | Yes | Mix text and image_url content blocks in the same round |
image_url | { url: string } | No | Reference image, public URL or data:image/...;base64,... |
resize_max_pixels | integer | No | Area limit for reference images, default 1048576; larger images are scaled down |
session | string | No | Keep 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
- JS SDK — Node.js server side
- Hy-Image-3.5-preview — full protocol and parameter reference
- Legacy Models — deprecated HY-Image-3.0 reference-image usage