Langsung ke konten utama
POST
/
v1
/
images
/
generations
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "qwen-image-2.0",
    "prompt": "A cute orange cat napping in the sunshine"
  }'
import requests

url = "https://api.apimart.ai/v1/images/generations"

payload = {
    "model": "qwen-image-2.0",
    "prompt": "A cute orange cat napping in the sunshine"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";

const payload = {
  model: "qwen-image-2.0",
  prompt: "A cute orange cat napping in the sunshine",
};

const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01JGXYZ1234567890ABCDEF"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Authentication failed, please check your API key",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance, please top up",
    "type": "payment_required"
  }
}
curl --request POST \
  --url https://api.apimart.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "qwen-image-2.0",
    "prompt": "A cute orange cat napping in the sunshine"
  }'
import requests

url = "https://api.apimart.ai/v1/images/generations"

payload = {
    "model": "qwen-image-2.0",
    "prompt": "A cute orange cat napping in the sunshine"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";

const payload = {
  model: "qwen-image-2.0",
  prompt: "A cute orange cat napping in the sunshine",
};

const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01JGXYZ1234567890ABCDEF"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Authentication failed, please check your API key",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance, please top up",
    "type": "payment_required"
  }
}

Model yang Didukung

ModelDeskripsiGambar MaksHarga
qwen-image-2.0Versi standar, kualitas dan performa seimbang6Harga tetap
qwen-image-2.0-proVersi Pro, rendering teks lebih kuat, tekstur realistis lebih halus6Harga tetap

Otorisasi

Authorization
string
wajib
Semua endpoint memerlukan autentikasi Bearer TokenDapatkan API Key:Kunjungi Manajemen API Key untuk mendapatkan API Key AndaTambahkan ke header permintaan:
Authorization: Bearer YOUR_API_KEY

Body

model
string
wajib
Nama model
  • qwen-image-2.0 - Versi standar, kualitas dan performa seimbang
  • qwen-image-2.0-pro - Versi Pro, rendering teks lebih kuat, tekstur realistis lebih halus
prompt
string
wajib
Deskripsi teks untuk pembuatan gambar, hingga 800 karakter
size
string
default:"1:1"
Rasio aspek gambarRasio aspek yang didukung:
  • 1:1 - Persegi (default)
  • 4:3 - Lanskap 4:3
  • 3:4 - Potret 3:4
  • 16:9 - Lanskap layar lebar
  • 9:16 - Potret vertikal
  • 3:2 - Lanskap 3:2
  • 2:3 - Potret 2:3
resolution
string
default:"1K"
Tier resolusi
  • 1K - Resolusi standar (default)
  • 2K - Resolusi definisi tinggi
n
integer
default:"1"
Jumlah gambar yang akan dibuatRentang: 1-6
negative_prompt
string
Prompt negatif (konten yang tidak ingin ditampilkan), hingga 500 karakter
image_urls
array
Array URL gambar referensi (mode image-to-image)Batasan:
  • Harus berupa URL yang dapat diakses publiks
  • Format Base64 tidak didukung

Tabel Referensi Resolusi

Ukuran output dikendalikan oleh kombinasi size (rasio) + resolution (tier resolusi).
Rasio1K Tier2K Tier
1:11024×10242048×2048
4:31152×8642048×1536
3:4864×11521536×2048
16:91280×7202048×1152
9:16720×12801152×2048
3:21248×8322048×1360
2:3832×12481360×2048
  • Hanya size → default ke tier 1K: {"size": "16:9"} → 1280×720
  • size + resolution → tier yang ditentukan: {"size": "16:9", "resolution": "2K"} → 2048×1152

Contoh Penggunaan

Text-to-Image (permintaan minimal)
{
  "model": "qwen-image-2.0",
  "prompt": "A cute orange cat napping in the sunshine"
}
Tentukan rasio dan jumlah
{
  "model": "qwen-image-2.0-pro",
  "prompt": "Cyberpunk-style futuristic city nightscape with flickering neon lights",
  "size": "16:9",
  "n": 4
}
Definisi tinggi 2K tier
{
  "model": "qwen-image-2.0-pro",
  "prompt": "Exquisite food photography, sushi platter",
  "size": "4:3",
  "resolution": "2K",
  "n": 2
}
Image-to-Image (gambar referensi + deskripsi teks)
{
  "model": "qwen-image-2.0",
  "prompt": "Change the background to a seaside sunset",
  "image_urls": ["https://example.com/my-photo.jpg"]
}

Respons

code
integer
Kode status respons
data
array
Array data respons

Catatan

  1. Pemrosesan Asinkron: Setelah pengiriman, task_id dikembalikan. Polling /v1/tasks/{task_id} untuk mendapatkan hasil
  2. Penyimpanan Gambar: Gambar yang dihasilkan dicerminkan ke CDN platform dan berlaku jangka panjang
  3. Aturan Penagihan: Ditagih per gambar yang berhasil dibuat; tidak ada biaya untuk kegagalan
  4. Persyaratan URL Gambar: Gambar input harus berupa URL yang dapat diakses publik; base64 tidak didukung