API Nano Banana: $0.01$0.04(GIẢM 75%)
Menu
ImageGPT AI API

Tài Liệu API

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

Sân Chơi API Tạo Ảnh Trực Tiếp

Kiểm tra và khám phá API Tạo Ảnh với nhiều mô hình và định dạng đầu ra

Chọn Mô Hình

Điểm Cuối

POSThttps://api.imagegpt.online/generate/text-image

Tiêu Đề

Nội Dung Yêu Cầu

Mẫu Code

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));
Tài liệu API

API Tạo Hình Ảnh

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.

POSThttps://api.imagegpt.online/generate/text-image

Tất cả yêu cầu phải chứa khóa API trong header. Giữ bí mật.

http header
x-api-key: YOUR_API_KEY

Khó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ểuMặc địnhMô 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
number512Chiều rộng hình (pixel).
height
number512Chiề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:

binary

outputType: "binary"

js
const blob = await response.blob();
const url = URL.createObjectURL(blob);
url

outputType: "url"

json
{
  "success": true,
  "taskId": "imagegpt_img-...",
  "url": "https://...",
  "creditsDeducted": 3
}
base64

outputType: "base64"

json
{
  "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:

javascript
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:

javascript
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:

Tiết kiệm
3 tín dụng / hình

Mô hình nhanh và nhẹ cho bản nháp.

e.g. Flux Schnell, Z Image Turbo

Tiêu chuẩn
10–30 tín dụng / hình

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

Cao cấp
35–100 tín dụng / hình

Độ 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ợ.