1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const axios = require('axios');
const fs = require('fs');
const path = require('path');
async function toB64(imgPath) {
const data = fs.readFileSync(path.resolve(imgPath));
return Buffer.from(data).toString('base64');
}
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/grok-imagine-image";
const data = {
"prompt": "A majestic snow leopard perched on a rocky cliff at dawn, golden sunlight catching its thick fur, breath visible in the cold air, sweeping Himalayan mountain range in the background, ultra-detailed wildlife photography, sharp focus, dramatic natural lighting",
"mode": "standard",
"aspect_ratio": "16:9",
"resolution": "2k",
"n": 1,
"output_format": "png",
"image_urls": "toB64('undefined')"
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();Text prompt describing the image to generate or the edit to apply. Be specific about subject, lighting, camera, and style.
Generation mode: standard is fast and economical, quality maximizes fidelity and text rendering. Use quality for final renders.
Allowed values:
Output aspect ratio, ignored when an input image sets the size. Use 16:9 landscape, 9:16 social, 1:1 square.
Allowed values:
Output resolution, 1k or 2k. Use 1k for fast drafts, 2k for detailed final renders.
Allowed values:
Number of images per request, 1 to 4. Use 2-3 to compare prompt variations, 1 once dialed in.
min : 1,
max : 4
Output file format. Use jpeg for small files, png for lossless, webp for a balance.
Allowed values:
Optional source images (URLs or base64) to edit. Maximum 3 images — any beyond the first 3 are ignored. Provide one image for a standard edit, or several and reference them in the prompt as <IMAGE_0>, <IMAGE_1>, <IMAGE_2>. Providing any image switches from text-to-image generation to image editing and edit pricing. Omit for pure text-to-image.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Grok Imagine Image is xAI's text-to-image and image-editing model, part of the Grok Imagine family powered by the Aurora engine. Describe a scene in plain language to generate a new image, or supply a source image and describe the change to run image-to-image edits — both workflows live in one model. A standard mode delivers fast, economical generations for rapid iteration, while a quality mode targets maximum fidelity, sharper detail, more natural lighting, and stronger prompt adherence. Outputs scale up to 2K resolution across a wide set of aspect ratios, making the model a practical default for everything from quick social concepts to polished hero visuals.
standard and quality modes to trade speed for fidelityGrok Imagine Image is built for fast ideation and creative experimentation. It shines for social media graphics, marketing concepts, product mockups, and posters where readable brand names, slogans, or signage need to sit inside the frame. Photographers and designers use the editing mode to restyle a photo, swap backgrounds, or add objects with a single instruction. Concept artists rely on the model to explore characters, environments, and moodboards quickly, then switch to quality mode for final, presentation-ready renders.
The model rewards natural-language scene descriptions over keyword stacks. Lead with the subject, keep prompts roughly 30 to 80 words, and describe light behavior, camera language, and film stock instead of vague adjectives like "8K" or "stunning." It does not use negative prompts, so phrase constraints positively (for example, "sharp focus, clean composition"). To place text, spell the exact wording in quotes; quality mode renders typography most reliably. Generate a small batch first, then iterate one element at a time.
Does Grok Imagine Image support image editing? Yes. Provide a source image as a URL or base64 and describe the change; the model edits instead of generating from scratch.
What is the difference between standard and quality mode?
standard is fast and economical for iteration. quality uses the premium model for higher fidelity, sharper detail, and stronger text rendering.
Can it render text inside images?
Yes. Put the exact words in quotes in the prompt. Text rendering is strongest in quality mode and supports multiple languages.
What resolutions and aspect ratios are supported? Resolution is 1k or 2k, with aspect ratios spanning 1:1, 16:9, 9:16, 4:3, 3:2, 2:1, and more.
How many images can I generate at once?
Set n from 1 to 4 to produce multiple variations in a single request.
Is Grok Imagine Image good for brand work? It is strong for fast concepts, mockups, and social assets; review brand-sensitive output, as commercial safety is lower than some rivals.