Docs / image / Grok Imagine Image 2.0 Text to Image
Grok Imagine Image 2.0 Text to Image online
xAI's Grok Imagine 2.0 — fast, characterful image generation from a text prompt.
Rp Rp320 / gambar
grok-imagine-image-2-0/text-to-image model id
1 · Create a task
Kirim permintaan untuk membuat tugas generasi image. Wajib header Idempotency-Key. Saldo direservasi sebesar estimasi; task gagal tidak ditagih.
curl -X POST https://getrun.id/v1/tasks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: my-task-001" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2-0/text-to-image",
"input": {
"prompt": "Design a retro beach club promotional poster in a clean vertical editorial layout, inspired by vintage travel flyers and lifestyle ads, with a warm off-white paper background, subtle grain, lightly distressed print texture, and a teal, black, cream, and sandy beige color palette. Use a bold stacked headline on the left that reads “SALTY DAYS & GOOD VIBES.” in large condensed typography, with strong hierarchy and slightly weathered ink. On the right, show a charming photorealistic raccoon wearing a teal Hawaiian shirt, sitting at a rustic beachside table and happily eating a cheeseburger, with a sunny beach club setting, umbrellas, and soft coastal scenery behind it. Include smaller supporting blocks, icons, and captions in a balanced magazine-style layout, such as a beach club badge, a food special, a small beach-path photo, and a simple bottom section with icons for beach front, good eats, and real vibes. Integrate “Grok Imagine Image 2.0 API” naturally as a small brand/header element near the top, and include “Kie.ai” as a subtle supporting platform mention in a lower callout or footer area. Keep the text limited and visually clean rather than crowded, with a polished but playful lifestyle-branding feel. The overall composition should closely match the reference style: oversized text block on the left, hero animal photo on the upper right, supporting image block on the lower left, structured feature section near the bottom center, and a colored callout panel on the lower right. Make it visually rich, highly readable, stylish, and commercial, with a warm beach mood and strong retro poster appeal, but avoid futuristic, cyberpunk, or abstract aesthetics.",
"aspect_ratio": "1:1"
}
}'const res = await fetch('https://getrun.id/v1/tasks', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Idempotency-Key': 'my-task-001',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"model": "grok-imagine-image-2-0/text-to-image",
"input": {
"prompt": "Design a retro beach club promotional poster in a clean vertical editorial layout, inspired by vintage travel flyers and lifestyle ads, with a warm off-white paper background, subtle grain, lightly distressed print texture, and a teal, black, cream, and sandy beige color palette. Use a bold stacked headline on the left that reads “SALTY DAYS & GOOD VIBES.” in large condensed typography, with strong hierarchy and slightly weathered ink. On the right, show a charming photorealistic raccoon wearing a teal Hawaiian shirt, sitting at a rustic beachside table and happily eating a cheeseburger, with a sunny beach club setting, umbrellas, and soft coastal scenery behind it. Include smaller supporting blocks, icons, and captions in a balanced magazine-style layout, such as a beach club badge, a food special, a small beach-path photo, and a simple bottom section with icons for beach front, good eats, and real vibes. Integrate “Grok Imagine Image 2.0 API” naturally as a small brand/header element near the top, and include “Kie.ai” as a subtle supporting platform mention in a lower callout or footer area. Keep the text limited and visually clean rather than crowded, with a polished but playful lifestyle-branding feel. The overall composition should closely match the reference style: oversized text block on the left, hero animal photo on the upper right, supporting image block on the lower left, structured feature section near the bottom center, and a colored callout panel on the lower right. Make it visually rich, highly readable, stylish, and commercial, with a warm beach mood and strong retro poster appeal, but avoid futuristic, cyberpunk, or abstract aesthetics.",
"aspect_ratio": "1:1"
}
}),
});
const task = await res.json();import requests
res = requests.post(
"https://getrun.id/v1/tasks",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Idempotency-Key": "my-task-001",
},
json={
"model": "grok-imagine-image-2-0/text-to-image",
"input": {
"prompt": "Design a retro beach club promotional poster in a clean vertical editorial layout, inspired by vintage travel flyers and lifestyle ads, with a warm off-white paper background, subtle grain, lightly distressed print texture, and a teal, black, cream, and sandy beige color palette. Use a bold stacked headline on the left that reads “SALTY DAYS & GOOD VIBES.” in large condensed typography, with strong hierarchy and slightly weathered ink. On the right, show a charming photorealistic raccoon wearing a teal Hawaiian shirt, sitting at a rustic beachside table and happily eating a cheeseburger, with a sunny beach club setting, umbrellas, and soft coastal scenery behind it. Include smaller supporting blocks, icons, and captions in a balanced magazine-style layout, such as a beach club badge, a food special, a small beach-path photo, and a simple bottom section with icons for beach front, good eats, and real vibes. Integrate “Grok Imagine Image 2.0 API” naturally as a small brand/header element near the top, and include “Kie.ai” as a subtle supporting platform mention in a lower callout or footer area. Keep the text limited and visually clean rather than crowded, with a polished but playful lifestyle-branding feel. The overall composition should closely match the reference style: oversized text block on the left, hero animal photo on the upper right, supporting image block on the lower left, structured feature section near the bottom center, and a colored callout panel on the lower right. Make it visually rich, highly readable, stylish, and commercial, with a warm beach mood and strong retro poster appeal, but avoid futuristic, cyberpunk, or abstract aesthetics.",
"aspect_ratio": "1:1"
}
},
)
task = res.json()Input parameters
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
prompt |
string | Yes | Text prompt describing the desired image. (max 5000 chars) | Design a retro beach club promotional poster i |
aspect_ratio |
string | Yes | Specifies the width-to-height ratio of the generated image. Controls the aspect ratio of the output. Opsi: 1:1 2:3 3:2 16:9 9:16 |
1:1 |
2 · Poll the result
Ambil status tugas hingga selesai — poll tiap 2–5 detik.
Respons saat sukses:
{
"id": "task_9f2c…",
"status": "succeeded",
"model": "grok-imagine-image-2-0/text-to-image",
"price": {
"currency": "IDR",
"estimated": 320,
"reserved": 320,
"final": 320
},
"output": {
"urls": [
"https://storage.getcore.id/outputs/task_9f2c…/0.png"
],
"expires_at": "(7 hari setelah selesai)"
}
}
Status values
| Status | Keterangan |
|---|---|
queued | Tugas sedang diantrikan. |
processing | Sedang diproses. |
succeeded | Berhasil. |
failed | Gagal — lihat error detail, tidak ditagih. |
image/png, dilayani dari CDN kami dan berlaku 7 hari — salin ke penyimpananmu sendiri untuk jangka panjang.Best practices
Bila generation gagal, task berstatus failed dengan error.code ternormalisasi (mis. moderation_blocked, upstream_error) dan price.final = 0 — saldo dikembalikan otomatis. Daftar lengkap kode error ada di Error handling. Selalu kirim Idempotency-Key unik per tugas agar retry aman.
Coba tanpa kode: jalankan model ini langsung dari Playground atau lihat di API Market.
