Reference-image generation: create a 2K/4K image from references and a prompt
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "hy-image-v3.5-preview-2k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": [
"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"
]
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "hy-image-v3.5-preview-2k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": ["https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'hy-image-v3.5-preview-2k',
prompt: 'Turn the reference image into a watercolor painting while keeping the red circle and blue square in place',
images: ['https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png']
})
};
fetch('https://api.apiyi.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'hy-image-v3.5-preview-2k',
'prompt' => 'Turn the reference image into a watercolor painting while keeping the red circle and blue square in place',
'images' => [
'https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1795534600,
"id": "tsk_01m8736tvsqp2t27p0k53hjn7z",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"url": "https://hdcdn.agisuitepro.com/o/2026/11/24/example.png"
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}Tencent Hunyuan Hy-Image 3.5 이미지 생성
참조 이미지 API 레퍼런스
Tencent Hunyuan Hy-Image 3.5 Preview 참조 이미지 API 레퍼런스 및 플레이그라운드 — images 배열은 2K/4K로 고정되고, 레거시 image 필드의 기본값은 1536이며, 멀티파트 편집은 1536만 출력합니다
POST
/
v1
/
images
/
generations
Reference-image generation: create a 2K/4K image from references and a prompt
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "hy-image-v3.5-preview-2k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": [
"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"
]
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "hy-image-v3.5-preview-2k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": ["https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'hy-image-v3.5-preview-2k',
prompt: 'Turn the reference image into a watercolor painting while keeping the red circle and blue square in place',
images: ['https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png']
})
};
fetch('https://api.apiyi.com/v1/images/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/v1/images/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'hy-image-v3.5-preview-2k',
'prompt' => 'Turn the reference image into a watercolor painting while keeping the red circle and blue square in place',
'images' => [
'https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/v1/images/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"hy-image-v3.5-preview-2k\",\n \"prompt\": \"Turn the reference image into a watercolor painting while keeping the red circle and blue square in place\",\n \"images\": [\n \"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1795534600,
"id": "tsk_01m8736tvsqp2t27p0k53hjn7z",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"url": "https://hdcdn.agisuitepro.com/o/2026/11/24/example.png"
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}오른쪽의 대화형 Playground에서는 실시간 테스트를 지원합니다.
images 필드에는 공개 이미지 URL 또는 data:image/...;base64,...을 입력할 수 있으며, 로컬 파일은 업로드하지 않습니다. 아래 예제를 사용하여 로컬 파일을 데이터 URI로 변환하십시오.이 페이지를 사용해야 하는 경우: 하나 이상의 참조 이미지에서 이미지를 생성하는 경우에 사용합니다. 예를 들어 스타일 전이, 구도 유지, 다중 이미지 융합 또는 참조 이미지 기반 다시 그리기 등에 사용할 수 있습니다. 순수한 텍스트-이미지 생성에는 텍스트-이미지 API를 사용하십시오.
⚠️ 출력 크기가 서로 다른 세 가지 참조 스타일
images배열(권장): 2048×2048(-2k) 또는 4096×4096(-4k)으로 고정됩니다. 명시적인size은 무시됩니다.- 기존
image필드:size없이 1536×1536으로만 출력됩니다. 2K/4K에는size을 명시적으로 전달하십시오. 단, 과금은 모델의 고정 요금으로 유지됩니다. /v1/images/edits멀티파트: 작동하지만 1536×1536으로만 출력되며 2K/4K 재정의를 사용하지 않습니다. 권장하지 않습니다.
prompt이 필요합니다: 프롬프트가 없는 이미지를 요청하면 400 prompt is required이 반환됩니다.세 가지 접근 방식 비교
| 접근 방식 | 요청 형식 | 기본 출력 | 명시적 size | 권장 사항 |
|---|---|---|---|---|
images 배열 | JSON, POST /v1/images/generations | 2048×2048 / 4096×4096 | 재정의됨 | ✅ 권장 |
레거시 image | JSON, POST /v1/images/generations | 1536×1536 | 적용됨: 2K/4K | ⚠️ 레거시 |
| 멀티파트 | POST /v1/images/edits, multipart/form-data | 1536×1536 | 무시됨 | ❌ 권장하지 않음 |
가격은 출력 크기에 따라 달라지지 않습니다. 세 가지 방식 모두 선택한 모델의 고정 요금으로 과금됩니다. 레거시
image 필드와 멀티파트 수정은 -2k / -4k 요금이 부과되는 동안에도 1536×1536만 반환할 수 있습니다. 새로운 모든 통합에는 images을 사용하십시오.코드 예시
Python (OpenAI SDK + extra_body)
from openai import OpenAI
import base64
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1",
timeout=120.0 # 120s for 2K; use 240s for 4K
)
resp = client.images.generate(
model="hy-image-v3.5-preview-2k",
prompt="Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
extra_body={
# Data URIs such as "data:image/png;base64,..." also work
"images": [
"https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"
]
}
)
with open("out.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Python (데이터 URI를 사용하는 원시 요청)
import base64
import os
import requests
with open("reference.png", "rb") as f:
data_uri = "data:image/png;base64," + base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={"Authorization": f"Bearer {os.environ['APIYI_API_KEY']}"},
json={
"model": "hy-image-v3.5-preview-2k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": [data_uri],
"response_format": "b64_json",
},
timeout=120,
)
response.raise_for_status()
with open("out.png", "wb") as f:
f.write(base64.b64decode(response.json()["data"][0]["b64_json"]))
cURL (URL 참조)
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "hy-image-v3.5-preview-4k",
"prompt": "Turn the reference image into a watercolor painting while keeping the red circle and blue square in place",
"images": ["https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"],
"response_format": "b64_json"
}' | python3 -c "import sys,json,base64; open('out.png','wb').write(base64.b64decode(json.load(sys.stdin)['data'][0]['b64_json']))"
Node.js (여러 참조)
import fs from 'node:fs';
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.APIYI_API_KEY}`
},
body: JSON.stringify({
model: 'hy-image-v3.5-preview-2k',
prompt: 'Place the person from image 1 into the scene from image 2, keeping the clothing color from image 1',
images: [
'https://your-domain.com/person.png',
'https://your-domain.com/scene.png'
],
response_format: 'b64_json'
}),
signal: AbortSignal.timeout(120000)
});
const { data } = await resp.json();
fs.writeFileSync('out.png', Buffer.from(data[0].b64_json, 'base64'));
레거시 image 필드 (2K/4K의 명시적 크기)
resp = client.images.generate(
model="hy-image-v3.5-preview-2k",
prompt="Turn the reference image into a watercolor painting while keeping the composition",
extra_body={
"image": ["https://docs.apiyi.com/images/hunyuan-image-v35-reference-input.png"],
"size": "2048x2048" # Legacy field: without size, output is only 1536×1536
}
)
멀티파트 편집 (권장하지 않음)
curl -X POST "https://api.apiyi.com/v1/images/edits" \
-H "Authorization: Bearer sk-your-api-key" \
-F "model=hy-image-v3.5-preview-2k" \
-F "prompt=Turn the reference image into a watercolor painting while keeping the composition" \
-F "[email protected]"
멀티파트
/v1/images/edits 출력은 1536×1536만 지원하며 2K/4K size 재정의를 적용하지 않습니다. 이전 코드와의 호환성을 위해 존재하며 새 프로젝트에는 권장하지 않습니다.매개변수
| 매개변수 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|
model | string | 예 | — | hy-image-v3.5-preview-2k (2048×2048) 또는 hy-image-v3.5-preview-4k (4096×4096) |
prompt | string | 예 | — | 생성/편집 지침입니다. 유지할 항목과 변경할 항목을 명시합니다 |
images | string[] | 예 (권장) | — | 공개 URL 또는 데이터 URI 형식의 참조 이미지입니다. 출력은 2K/4K로 고정됩니다 |
image | string / string[] | 아니요 (레거시) | — | 편집 경로입니다. size 없이 1536×1536 출력만 지원합니다 |
size | string | 아니요 | — | 레거시 image 필드에만 적용되며, images에서는 재정의됩니다 |
response_format | string | 아니요 | b64_json | b64_json 또는 url |
n | — | — | — | 1로 고정됩니다 |
참조 이미지 수는 가격에 영향을 주지 않습니다. 공식 문서에는 이미지당 20MB 이하, 입력 이미지 총 20개 이하로 명시되어 있습니다. 여러 참조 이미지를 사용하는 경우 프롬프트에서 “이미지 1 / 이미지 2”와 같이 지칭합니다.
참조 이미지 준비
- 형식: PNG, JPEG 또는 WebP이며, 각 이미지는 20MB 이하여야 합니다.
- URL: 공개적으로 접근할 수 있는 직접 링크여야 합니다. 로그인이 필요하거나 핫링크 방지가 적용된 URL 또는 만료된 서명 URL은 다운로드할 수 없습니다.
- 데이터 URI: 로컬 파일을
data:image/png;base64,...로 변환하여images배열에 넣습니다. 작은 파일과 사설 네트워크에 적합합니다. - 압축: 긴 변을 2048px로 조정하고 품질을 0.9로 설정합니다. 전송 및 처리 시간을 줄이려면 전체 크기를 약 6MB 미만으로 유지합니다.
- 순서: 참조 이미지에는
images배열 순서대로 번호가 지정됩니다(이미지 1, 이미지 2, …). prompt에서 해당 이미지를 명시적으로 지칭합니다.
응답 형식
{
"created": 1795534600,
"id": "tsk_01m8736tvsqp2t27p0k53hjn7z",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zU..."
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}
응답 참고 사항
b64_json는data:접두사가 없는 일반 base64입니다. 직접 디코딩하여 PNG로 변환하십시오.response_format: "url"을 사용하면 이미지는hdcdn.agisuitepro.com의data[0].url에 있습니다.usage은 플레이스홀더이며 과금 대사에 사용할 수 없습니다.- 2K 참조 출력은 약 3–7 MB이고 4K 출력은 약 18–19 MB입니다. 4K base64 응답은 최대 26 MB에 달할 수 있습니다.
usage은 과금 데이터가 아닙니다: prompt_tokens는 항상 1000이고 output_tokens은 항상 0입니다. 이 시리즈는 이미지당 고정 요금으로 과금됩니다. 실제 요금은 APIYI 콘솔의 청구 내역을 확인하십시오.관련 문서
본문
application/json
응답
Image generated successfully
이 페이지가 도움이 되었나요?