Images · Text to image · Image to image
Grok Imagine Image 2.0 API
Grok Imagine Image 2.0 by xAI. Top-ranked image generation and editing with strong text rendering, up to 2K.
- Price
- From $0.04 per run from $0.04/image
- Typical time
- ~20 s
- Model id
grok_imagine_image_2
Grok Imagine Image 2.0 runs on one varg API key and one credit balance, the same as every other model here. You pay the provider's price, with no markup.
curl -X POST https://api.varg.ai/v2/tools/image/call \
-H "Authorization: Bearer $VARG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS."
}'Grok Imagine Image 2.0 pricing
From $0.04 per run. Prices are in US dollars and are the provider's own, with no markup. Grok Imagine Image 2.0 has 2 routes: "model": "grok_imagine_image_2" picks one automatically, or pass a route key as "model" to pin it. For the exact price of a request, send the same body to POST https://api.varg.ai/v2/estimate.
- fal from $0.04/image
fal:xai/grok-imagine-image/v2.0/text-to-imageText to image Grok Imagine Image 2.0 text-to-image — strong text rendering, 1k/2k, 13 aspect ratios, quality low/medium.
- Resolution 2k
- $0.08/image
- Quality low
- $0.04/image
- Other
- $0.06/image
- Minimum charge
- $0.04
- Most one request can cost
- $0.32
- Typical time
- ~20 s
- fal from $0.05/image
fal:xai/grok-imagine-image/v2.0/editImage to image Grok Imagine Image 2.0 editing — targeted edits and compositions from reference images, 1k/2k.
- Resolution 2k
- $0.09/image
- Quality low
- $0.05/image
- Other
- $0.07/image
- Minimum charge
- $0.05
- Most one request can cost
- $0.36
- Typical time
- ~20 s
Grok Imagine Image 2.0 inputs
The JSON body of the request. Media inputs are URLs: upload a local file with POST /v2/files and pass the URL it returns. Full JSON Schema, no key needed: api.varg.ai/v2/tools/image?model=grok_imagine_image_2
| Field | What it does |
|---|---|
model string required | grok_imagine_image_2 picks a route automatically. To pin one, pass a route key from Pricing above. |
prompt string | — |
files array of { url } | — |
aspect_ratio string | Allowed e.g. 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 21:9 | auto |
Provider options
Optional, under provider_options.<provider>. Only the options of the provider that runs the job apply; pin a route to choose it.
provider_options.fal
| Field | What it does |
|---|---|
prompt string | Text description of the desired image. |
image_urls array of URL strings | — |
quality string | Allowed low | medium |
sync_mode boolean | If `True`, the media will be returned as a data URI and the output data won't be available in the request history. |
num_images integer | Number of images to generate. Allowed 1–4 |
resolution string | Allowed 1k | 2k |
aspect_ratio string | Allowed 2:1 | 20:9 | 19.5:9 | 16:9 | 4:3 | 3:2 | 1:1 | 2:3 | 3:4 | 9:16 | 9:19.5 | 9:20 | 1:2 | auto |
output_format string | Allowed jpeg | png | webp |
Call the Grok Imagine Image 2.0 API
POST https://api.varg.ai/v2/tools/image/call with Authorization: Bearer $VARG_API_KEY. It answers 202 with a job right away.
1. Send the request
curl -X POST https://api.varg.ai/v2/tools/image/call \
-H "Authorization: Bearer $VARG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS."
}'JavaScript
const headers = {
Authorization: `Bearer ${process.env.VARG_API_KEY}`,
'Content-Type': 'application/json',
}
const res = await fetch('https://api.varg.ai/v2/tools/image/call', {
method: 'POST',
headers,
body: JSON.stringify({
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS."
}),
})
const job = await res.json() // { id: "job_…", status: "queued" }Python
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['VARG_API_KEY']}"}
job = requests.post(
"https://api.varg.ai/v2/tools/image/call",
headers=headers,
json={
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS."
},
).json() # {"id": "job_…", "status": "queued"}2. Get the result
Poll the job until its status is completed, failed or cancelled; Grok Imagine Image 2.0 typically takes about 20 s. The result is at output.outputs[0].url.
curl https://api.varg.ai/v2/jobs/$JOB_ID \
-H "Authorization: Bearer $VARG_API_KEY"
# Poll until "status" is completed, failed or cancelled.
# The result is in output.outputs[0].urlJavaScript
let current = job
while (!['completed', 'failed', 'cancelled'].includes(current.status)) {
await new Promise((resolve) => setTimeout(resolve, 3000))
current = await (await fetch(`https://api.varg.ai/v2/jobs/${current.id}`, { headers })).json()
}
console.log(current.output?.outputs?.[0]?.url)Python
import time
while job["status"] not in ("completed", "failed", "cancelled"):
time.sleep(3)
job = requests.get(f"https://api.varg.ai/v2/jobs/{job['id']}", headers=headers).json()
print(job["output"]["outputs"][0]["url"])Or take a webhook instead of polling
Add options.webhook_url and varg POSTs the finished job to it.
{
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS.",
"options": {
"webhook_url": "https://your-app.com/varg-webhook"
}
}From Claude, ChatGPT or Cursor (MCP)
The varg MCP server, https://mcp.varg.ai/mcp, runs Grok Imagine Image 2.0 with call_tool. Sign in with varg, no API key to paste. How to connect it
{
"tool": "image",
"input": {
"model": "grok_imagine_image_2",
"prompt": "A vintage travel poster for Mars with the headline VISIT OLYMPUS MONS."
},
"wait": true
}Grok Imagine Image 2.0 API: questions
- How much does Grok Imagine Image 2.0 cost on varg?
- Grok Imagine Image 2.0 costs from $0.04 per run on varg (from $0.04/image on the cheapest route). varg charges the provider's price with no markup, from one credit balance. For the exact price of a request before you run it, send the same body to POST https://api.varg.ai/v2/estimate.
- How do I call the Grok Imagine Image 2.0 API?
- Send POST https://api.varg.ai/v2/tools/image/call with the header "Authorization: Bearer $VARG_API_KEY" and a JSON body that includes "model": "grok_imagine_image_2". The call answers 202 with a job right away. Poll GET https://api.varg.ai/v2/jobs/{id} until "status" is "completed", then read output.outputs[0].url, or pass options.webhook_url to be called back.
- Can I use Grok Imagine Image 2.0 from Claude, ChatGPT or Cursor?
- Yes. Add the varg MCP server (https://mcp.varg.ai/mcp) to Claude, ChatGPT, Cursor or any other MCP client and sign in with varg, with no API key to paste. The agent runs Grok Imagine Image 2.0 with call_tool, passing tool "image" and "model": "grok_imagine_image_2".
- How long does a Grok Imagine Image 2.0 request take?
- Typically about 20 s on the fastest route, by the catalog's estimate. The API answers at once with a job id, so nothing waits on an open connection while it runs.
For AI agents: this page as Markdown is varg.ai/models/grok_imagine_image_2.md, and every model is listed in varg.ai/models/llms.txt.