Grok Imagine Image 2.0
xAI's Grok Imagine image model. Text to image, and editing with up to five source images.
- Model id:
xai/grok-imagine-image-2.0 - Type: Image, from xAI
- Modes: Text to image, Image edit
- Prompt: up to 4,000 characters
- Canceling: Only while queued. Generations finish within seconds once submitted.
Parameters
Set these in params. Anything left out takes the default, which is what the price estimate assumes.
| Parameter | Accepted values | Default |
|---|---|---|
resolution | 1k, 1.5k, 2k | 1k |
aspect_ratio | 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 21:9, 5:2, 19.5:9, 9:19.5, 20:9, 9:20 | 1:1 |
num_outputs | 1 to 10 | 1 |
output_format | png, jpeg, webp | provider's |
References
Pass media in references, each with a role and an upload_id or HTTPS url (Uploads). When mode is left out it is inferred from the roles.
| Role | Used as | At most |
|---|---|---|
source_image | Image to edit | 1 |
reference_image | Subject or style reference | 4 |
Pricing
Billed per image delivered. The full price list for your account is on the dashboard's billing page and in pricing from GET /v1/models/xai%2Fgrok-imagine-image-2.0. Each request reserves its maximum price and is charged for what was produced (Pricing and credits).
Examples
Text to image
import { RawFrame } from "@rawframe/sdk";
const rf = new RawFrame();
const generation = await rf.generations.createAndWait({
model: "xai/grok-imagine-image-2.0",
prompt: "A lighthouse on a cliff at dusk, oil painting",
params: { aspect_ratio: "1:1" },
});
console.log(generation.outputs?.[0]?.url);Two variations
import { RawFrame } from "@rawframe/sdk";
const rf = new RawFrame();
const generation = await rf.generations.createAndWait({
model: "xai/grok-imagine-image-2.0",
prompt: "A paper boat drifting down a rain-soaked city gutter, macro lens",
params: { num_outputs: 2, aspect_ratio: "16:9" },
});
console.log(generation.outputs?.[0]?.url);