Biến ý tưởng của bạn thành những hình ảnh và video tuyệt đẹp với các mô hình AI mạnh mẽ của chúng tôi
Kiểm tra và khám phá API Tạo Ảnh với nhiều mô hình và định dạng đầu ra
fetch('https://api.imagegpt.online/generate/text-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
"prompt": "Photorealistic portrait of the same person (keep his real face unchanged). A man with medium curly brown hair, light skin, and soft features sits relaxed, forearms on a light blue table, holding a small white puppy with a red collar. He wears a cozy color-block knitted sweater (beige, tan, light blue, black) with ribbed neck and cuffs, a silver watch, and a turquoise-beaded bracelet. Soft diffused lighting, smooth steel-blue background, slightly elevated front angle warm, intimate, digital photo",
"width": 512,
"height": 512,
"model": "FLUX-SCHNELL",
"outputType": "binary",
"outputFormat": "png"
})
})
.then(response => response.blob())
.then(blob => {
const imageUrl = URL.createObjectURL(blob);
console.log('Image URL:', imageUrl);
// Display in img tag: document.getElementById('myImg').src = imageUrl;
})
.catch(error => console.error('Error:', error));API REST thống nhất để tạo hình ảnh với 15+ mô hình AI — văn bản sang hình và hình sang hình, nhiều định dạng, hệ thống tín dụng.
https://api.imagegpt.online/generate/text-imageTất cả yêu cầu phải chứa khóa API trong header. Giữ bí mật.
x-api-key: YOUR_API_KEYKhóa API thiếu hoặc không hợp lệ trả về 401 Unauthorized .
Gửi JSON với các trường:
| Tham số | Kiểu | Mặc định | Mô tả |
|---|---|---|---|
model* | string | — | ID mô hình để tạo. |
prompt* | string | — | Mô tả văn bản của hình ảnh muốn tạo. |
width | number | 512 | Chiều rộng hình (pixel). |
height | number | 512 | Chiều cao hình (pixel). |
outputType | string | "binary" | Định dạng: "binary", "url" hoặc "base64". |
outputFormat | string | "png" | Định dạng file: "png" hoặc "jpg". |
image | string[] | — | Mảng URL hình (tối đa 3). Chỉ cho hình sang hình. |
* Trường bắt buộc.
Hình dạng phản hồi phụ thuộc vào outputType đã chọn:
outputType: "binary"
const blob = await response.blob();
const url = URL.createObjectURL(blob);outputType: "url"
{
"success": true,
"taskId": "imagegpt_img-...",
"url": "https://...",
"creditsDeducted": 3
}outputType: "base64"
{
"success": true,
"taskId": "imagegpt_img-...",
"base64": "/9j/4QWm...",
"creditsDeducted": 3
}Yêu cầu tối thiểu văn bản sang hình với fetch API:
fetch('https://api.imagegpt.online/generate/text-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
model: 'FLUX-SCHNELL',
prompt: 'A futuristic city at sunset, photorealistic',
width: 512,
height: 512,
outputType: 'url',
outputFormat: 'png'
})
})
.then(res => res.json())
.then(data => console.log('Image URL:', data.url));Cho hình sang hình, thêm image mảng:
body: JSON.stringify({
model: 'FLUX-KONTEXT',
prompt: 'Same person, wearing a red jacket',
image: ['https://example.com/input.jpg'],
width: 512,
height: 512,
outputType: 'url',
outputFormat: 'png'
})Tín dụng tính theo mỗi hình được tạo:
Mô hình nhanh và nhẹ cho bản nháp.
e.g. Flux Schnell, Z Image Turbo
Chất lượng cân bằng cho sử dụng hàng ngày.
e.g. GPT Image 1.0, Seedream, Nova Canvas
Độ trung thực cao nhất cho sản xuất.
e.g. Nano Banana Pro, Seedream 4.0, Ideogram
ImageGPT cấm nội dung NSFW, khiêu dâm, người lớn, bóc lột, lừa đảo hoặc gây hại được tạo bởi AI. Kiểm duyệt nội dung được áp dụng cho việc tạo ảnh và video được hỗ trợ.