T2I
T2I(Text to Image) ์๋น์ค๋ ์ฌ์ฉ์๊ฐ ์ ๋ ฅํ๋ ํ์ค์ ๋ฌธ์ฅ๋ง์ผ๋ก๋ ์ํ๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ๋ ์๋น์ค ์ ๋๋ค. ์ฅ๋ฉด, ๊ฐ์ฒด, ์ง๊ฐ ๋ฑ ํ ์คํธ ์ธ๋ฐํ ์๋ฏธ์ /๋งฅ๋ฝ์ ์ ๋ณด๋ฅผ ์ด๋ฏธ์ง๋ก ์์ฝ๊ฒ ๊ตฌํํ ์ ์์ต๋๋ค. ๊ณ ํ์ง์ ์ด๋ฏธ์ง ์ ๊ณต์ ํตํ์ฌ ๋์์ธ ์๋ํ, ์ฝํ ์ธ ์์ฑ ๋ฑ ๋ค์ํ ๋ถ์ผ์์ ํ์ฉํ ์ ์์ต๋๋ค.
vailable Models
t2i-251203
ํ ์คํธ์ ์๋ฏธ์ /๋งฅ๋ฝ์ ์ดํด๊ฐ ๋ฐ์ด๋ ์ธ๋ฐํ ์์ฒญ์์ ๊ณ ํ์ง์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
Request
Request Headers
Content-Type
application/json
x-api-key
UNIVA-API-KEY
curl -X POST 'https://aiplatform-api.rest.univa.co.kr/rest/v1/image/t2i' \
-H 'accept: */*' \
-H 'x-api-key: UNIVA-API-KEY' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"prompt": "'\''hello world'\''๋ผ๊ณ ์ ํ ํ์งํ์ ๋ค๊ณ ์๋ ๊ณ ์์ด",
"max_scale_size": 1024,
"true_cfg_scale": 0,
"num_inference_steps": 9
}
}'async function callImageT2IAPI() {
// API ์ค์
const url = 'https://aiplatform-api.rest.univa.co.kr/rest/v1/image/t2i';
const apiKey = 'UNIVA-API-KEY'; // ์ค์ API ํค๋ก ๋์ฒดํด์ผ ํฉ๋๋ค.
// ์ฌ์ฉ์ ์
๋ ฅ (JSON ๋ณธ๋ฌธ์ ๋ค์ด๊ฐ ๋ฐ์ดํฐ)
const prompt = "'hello world'๋ผ๊ณ ์ ํ ํ์งํ์ ๋ค๊ณ ์๋ ๊ณ ์์ด";
const data = {
data: {
prompt: prompt,
max_scale_size: 1024,
true_cfg_scale: 0,
num_inference_steps: 9,
}
};
// API ํธ์ถ์ ์ํ ์ค์
const options = {
method: 'POST',
headers: {
'x-api-key': apiKey,
'Content-Type': 'application/json', // JSON ๋ณธ๋ฌธ์ ๋ณด๋ผ ๋ ํ์
},
body: JSON.stringify(data), // JavaScript ๊ฐ์ฒด๋ฅผ JSON ๋ฌธ์์ด๋ก ๋ณํ
};
try {
// API ํธ์ถ
const response = await fetch(url, options);
// ์๋ต ์ํ ํ์ธ
if (!response.ok) {
// HTTP ์ํ ์ฝ๋๊ฐ 200 ๋ฒ์๊ฐ ์๋๋ฉด ์๋ฌ๋ฅผ ๋ฐ์
const errorText = await response.text();
throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
}
// ์๋ต ๋ณธ๋ฌธ์ JSON์ผ๋ก ํ์ฑ
const result = await response.json();
console.log('API ํธ์ถ ์ฑ๊ณต!');
// console.log('์๋ต ๋ฐ์ดํฐ:', result); // ์๋ต ๊ฒฐ๊ณผ๋ฅผ ํ์ธํฉ๋๋ค.
// ์๋ต ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ๋ก์ง์ ์ฌ๊ธฐ์ ์ถ๊ฐํ์ธ์ (์: ์ด๋ฏธ์ง ์ฒ๋ฆฌ)
return result;
} catch (error) {
console.error('API ํธ์ถ ์ค ์ค๋ฅ ๋ฐ์:', error.message);
// ์ค๋ฅ ์ฒ๋ฆฌ ๋ก์ง์ ์ฌ๊ธฐ์ ์ถ๊ฐํ์ธ์
}
}
// ํจ์ ์คํ
callImageT2IAPI();Request Body (*required)
prompt*
string
์ด๋ฏธ์ง ์์ฑ ์์ฒญ
max_scale_size
int
์ด๋ฏธ์ง ์ต๋ ํด์๋
true_cfg_scale
floatt
ํ๋กฌํํธ ์ผ์น๋(์ ํ๋)
num_inference_steps
int
์ถ๋ก ์คํ
Response
Last updated