Text-to-image: generate a 2K/4K image from 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": "A cinematic movie poster with the Chinese title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "hy-image-v3.5-preview-2k",
"prompt": "A cinematic movie poster with the Chinese title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish"
}
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: 'A cinematic movie poster with the Chinese title "Between Mountains and Seas" centered, deep blue night sky and golden mountains, premium finish'
})
};
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' => 'A cinematic movie poster with the Chinese title "Between Mountains and Seas" centered, deep blue night sky and golden mountains, premium finish'
]),
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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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 레퍼런스 및 플레이그라운드 — hy-image-v3.5-preview-2k / -4k, 2048/4096 고정 출력, 기본값은 b64_json이며 선택적으로 CDN URL 지원
POST
/
v1
/
images
/
generations
Text-to-image: generate a 2K/4K image from 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": "A cinematic movie poster with the Chinese title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish"
}
'import requests
url = "https://api.apiyi.com/v1/images/generations"
payload = {
"model": "hy-image-v3.5-preview-2k",
"prompt": "A cinematic movie poster with the Chinese title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish"
}
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: 'A cinematic movie poster with the Chinese title "Between Mountains and Seas" centered, deep blue night sky and golden mountains, premium finish'
})
};
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' => 'A cinematic movie poster with the Chinese title "Between Mountains and Seas" centered, deep blue night sky and golden mountains, premium finish'
]),
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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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\": \"A cinematic movie poster with the Chinese title \\\"Between Mountains and Seas\\\" centered, deep blue night sky and golden mountains, premium finish\"\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
}
}오른쪽의 대화형 플레이그라운드에서는 실시간 테스트를 지원합니다. Authorization에 API 키를 입력하고(형식:
Bearer sk-xxx), model을 선택하고, prompt을 입력한 다음, 필요에 따라 response_format을 선택하여 전송합니다. size은 입력하지 마십시오. 두 모델 모두 출력 크기가 고정되어 있습니다.이 페이지를 사용하는 경우: 순수한 텍스트-이미지 생성입니다. prompt만 있으면 됩니다. 참조 이미지 생성 또는 편집에는 참조 이미지 API를 사용하십시오.
⚠️ 알아야 할 세 가지 사항
size은 모델에 의해 재정의됩니다:-2k은 항상 2048×2048을 반환하고-4k은 항상 4096×4096을 반환합니다.size로 해상도를 변경하려고 하지 마십시오.n은 1로 고정됩니다: 2 또는 3을 전달해도 이미지 한 장만 반환되며 한 번만 과금됩니다. 여러 이미지를 생성하려면 동시 요청을 전송하십시오.- 응답은 기본적으로 base64입니다: 2K 응답은 약 6
8.4MB이고 4K 응답은 17.620MB입니다. 웹에 표시하려면response_format: "url"을 전달하십시오.
코드 예시
Python (OpenAI SDK)
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="A cinematic Chinese movie poster with the title \"Between Mountains and Seas\" centered, deep blue night sky and golden mountains, premium finish",
# Do not pass size; responses default to b64_json
)
with open("out.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Python (원시 요청)
import base64
import os
import requests
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": "An orange cat wearing sunglasses on a wooden windowsill, afternoon sunlight, cinematic shallow depth of field",
"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
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-2k",
"prompt": "A minimalist coffee shop poster with the headline \"Autumn Limited\" at the top, warm brown palette",
"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 (네이티브 fetch)
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-4k',
prompt: 'A serene Japanese garden with cherry blossoms, koi pond, golden hour',
response_format: 'b64_json'
}),
signal: AbortSignal.timeout(240000) // 240s for 4K
});
const { data } = await resp.json();
fs.writeFileSync('out.png', Buffer.from(data[0].b64_json, 'base64'));
브라우저 JavaScript (URL 모드)
{/* Demo only. Use a backend proxy in production to avoid leaking the key. */}
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'hy-image-v3.5-preview-2k',
prompt: 'A cinematic poster with the title "Between Mountains and Seas", deep blue night sky and golden mountains',
response_format: 'url' // Return a CDN URL instead of a 6–26 MB base64 string
})
});
const { data } = await resp.json();
document.getElementById('img').src = data[0].url;
매개변수
| 매개변수 | 유형 | 필수 | 기본값 | 설명 |
|---|---|---|---|---|
model | 문자열 | 예 | — | hy-image-v3.5-preview-2k (2048×2048) 또는 hy-image-v3.5-preview-4k (4096×4096) |
prompt | 문자열 | 예 | — | 중국어 또는 영어로 작성하는 prompt입니다. 이미지에 표시해야 하는 텍스트는 따옴표로 묶습니다 |
response_format | 문자열 | 아니요 | b64_json | b64_json 또는 url입니다. 잘못된 값은 오류 없이 base64로 대체됩니다 |
size | — | — | — | 모델에 의해 재정의됩니다. 전달하지 마십시오 |
n | — | — | — | 1로 고정됩니다. 다른 값을 지정해도 이미지 하나만 반환됩니다 |
images / image | — | — | — | 텍스트-이미지 변환에는 필요하지 않습니다. 참조 이미지 API를 사용하십시오 |
제약 조건 및 허용 값은 플레이그라운드 필드 설명을 참조하십시오.
quality, style 및 output_format은 효과가 없으므로 전송하지 마십시오.응답 형식
기본값response_format: "b64_json":
{
"created": 1795534600,
"id": "tsk_01m8736tvsqp2t27p0k53hjn7z",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zU..."
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}
response_format: "url" 사용 시:
{
"created": 1795534600,
"id": "tsk_01m8736tvsqp2t27p0k53hjn7z",
"data": [
{
"url": "https://hdcdn.agisuitepro.com/o/2026/11/24/example.png"
}
],
"usage": {
"prompt_tokens": 1000,
"total_tokens": 1000,
"input_tokens": 1000,
"output_tokens": 0
}
}
응답 참고 사항
b64_json은data:image/png;base64,접두사가 없는 일반 base64입니다. 직접 디코딩하여 PNG로 변환합니다.- 2K PNG는 약 4.4–5.7MB이고 base64 응답은 6–8.4MB입니다. 4K PNG는 12.6–18.9MB이고 base64 응답은 17.6–20MB입니다.
url은hdcdn.agisuitepro.com에서 안정적인 URL을 반환합니다. HEAD는 200을 반환하고<img>은 작동하지만, CORS 프리플라이트는 403을 반환하므로 브라우저의fetch/ 캔버스 액세스에는 서버 측 프록시가 필요합니다.usage은 플레이스홀더이며 과금 대사에 사용할 수 없습니다.
usage은 과금 대상 데이터가 아닙니다: prompt_tokens은 항상 1000이고 output_tokens은 항상 0입니다. 이 시리즈는 이미지당 고정 가격으로 과금됩니다. 실제 청구 금액은 APIYI 콘솔 청구서를 사용하여 확인합니다.본문
application/json
응답
Image generated successfully
이 페이지가 도움이 되었나요?