Skip to main content
POST
Reference-image generation: create a 2K/4K image from references and a prompt
The interactive Playground on the right supports live testing. The images field accepts public image URLs or data:image/...;base64,...; it does not upload local files. Convert local files to data URIs with the examples below.
When to use this page: generate an image from one or more reference images — style transfer, composition preservation, multi-image fusion, or reference-guided redrawing. For pure text-to-image, use the text-to-image API.
⚠️ Three reference styles with different output sizes
  • images array (recommended): fixed 2048×2048 (-2k) or 4096×4096 (-4k); an explicit size is overridden.
  • Legacy image field: outputs only 1536×1536 without size; pass size explicitly for 2K/4K, but billing remains the model’s flat price.
  • /v1/images/edits multipart: works, but outputs only 1536×1536 and does not use the 2K/4K override. Not recommended.
prompt is required: an image without a prompt returns 400 prompt is required.

Comparing the Three Approaches

Price does not depend on output size. All three styles bill at the selected model’s flat price. The legacy image field and multipart edits may return only 1536×1536 while still charging the -2k / -4k price. Use images for all new integrations.

Code Examples

Python (OpenAI SDK + extra_body)

Python (raw requests with a data URI)

cURL (URL reference)

Node.js (multiple references)

Legacy image field (explicit size for 2K/4K)

Multipart /v1/images/edits outputs only 1536×1536 and does not apply the 2K/4K size override. It exists for compatibility with older code and is not recommended for new projects.

Parameters

Reference count does not affect the price. The official docs list ≤20MB per image and ≤20 input images total. With multiple references, refer to them as “image 1 / image 2” in the prompt.

Preparing References

  • Formats: PNG, JPEG, or WebP; each image ≤20MB.
  • URLs: must be publicly reachable direct links. Login-protected, hotlink-protected, or expired signed URLs fail to download.
  • Data URIs: convert local files to data:image/png;base64,... and put them in the images array. Good for small files and private networks.
  • Compression: resize the long edge to 2048px and use quality 0.9; keep the combined size under about 6MB to reduce transfer and processing time.
  • Order: references are numbered in images array order (image 1, image 2, …). Refer to them explicitly in the prompt.

Response Format

Response notes
  • b64_json is plain base64 without a data: prefix. Decode it directly to a PNG.
  • With response_format: "url", the image is in data[0].url on hdcdn.agisuitepro.com.
  • usage is a placeholder and cannot be used for billing reconciliation.
  • A 2K reference output is about 3–7 MB and a 4K output about 18–19 MB; a 4K base64 response can reach 26 MB.
usage is not billable data: prompt_tokens is always 1000 and output_tokens is always 0. This series bills a flat price per image; use the APIYI console bill for actual charges.

Authorizations

Authorization
string
header
required

API key created in the APIYI console

Body

application/json
model
enum<string>
default:hy-image-v3.5-preview-2k
required

Model ID. -2k is fixed at 2048×2048; -4k is fixed at 4096×4096

Available options:
hy-image-v3.5-preview-2k,
hy-image-v3.5-preview-4k
prompt
string
required

Edit/generation instruction. State what to keep and what to change

Example:

"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place"

images
string[]
required

Reference images. Items can be public URLs or data:image/...;base64,.... This is the recommended field; output is fixed at the model's 2K/4K resolution.

Required array length: 1 - 20 elements
Example:
image
string

Legacy field, not recommended. Routed through the edit path: outputs 1536×1536 without size; pass size explicitly for 2K/4K. Billing is still the model's flat price.

Example:

"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"

size
string

Only applies to the legacy image field; ignored when using images. Common values: 2048x2048 (2K) or 4096x4096 (4K).

Example:

"2048x2048"

response_format
enum<string>
default:b64_json

Response format. Defaults to b64_json; url returns a stable platform CDN URL

Available options:
b64_json,
url
n
enum<integer>
default:1

Fixed at 1. This model always returns exactly one image

Available options:
1

Response

Image generated successfully

created
integer

Unix timestamp

Example:

1795534600

id
string

Task ID for this request

Example:

"tsk_01m8736tvsqp2t27p0k53hjn7z"

data
object[]

Image result array, always exactly one item

usage
object

Placeholder values; do not use for billing reconciliation. prompt_tokens is always 1000 and output_tokens is always 0. Actual charges are flat per image and come from the console bill.