Grok Imagine Image 2.0 API — Generation and Reference Images
Use grok-imagine-image-2.0 through APIMaster for 1K and 2K image generation with optional reference images.
Grok Imagine Image 2.0
Use model grok-imagine-image-2.0 with the synchronous POST https://apimaster.ai/v1/images/generations endpoint. APIMaster submits the request to the configured Grok route, polls the upstream task, and returns all generated images in data[].
This guide applies to the APIMaster model ID. Use image_urls for reference images; do not send reference files to /images/edits for this model.
Quick start
curl --fail-with-body --max-time 300 "https://apimaster.ai/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "A blue ceramic teapot and a small orange sphere on a clean white table, soft studio lighting",
"resolution": "1k",
"quality": "low",
"aspect_ratio": "1:1",
"n": 1
}'
A successful response contains one entry for each output. The URL below illustrates the response format; use the actual returned URLs:
{
"created": 1790147540,
"data": [{ "url": "https://apimaster.ai/imgs/example-result.jpg" }]
}
Download returned URLs promptly. Usage-log previews follow the current 3-day media retention period and are not permanent storage.
Parameters
| Field | Type | Required | Values and notes |
|---|---|---|---|
model |
string | yes | grok-imagine-image-2.0 |
prompt |
string | yes | Description of the desired image |
resolution |
string | no | 1k or 2k; default 1k |
quality |
string | no | low, medium, or auto |
aspect_ratio |
string | no | Ratio such as 1:1, 16:9; use this instead of pixel dimensions |
size |
string | no | A ratio such as 1:1 is accepted and converted to aspect_ratio; pixel sizes are rejected |
n |
integer | no | 1–10; default 1 |
image_urls |
string[] | no | Up to 5 public reference-image URLs; every URL must be unique and non-empty |
auto is pinned before the request is priced and forwarded: it becomes low without references and medium when one or more references are present. This makes the billing tier explicit.
Reference images
Reference images are sent as URLs in the same JSON request. The output count is controlled by n, not by the number of references.
curl --fail-with-body --max-time 300 "https://apimaster.ai/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-2.0",
"prompt": "Create two polished product variations while preserving the teapot shape and colors from the reference",
"resolution": "2k",
"quality": "medium",
"aspect_ratio": "1:1",
"n": 2,
"image_urls": ["https://your-public-host.example/reference.png"]
}'
The reference URL must be reachable by the configured route. Repeating the same URL is rejected with HTTP 400. A request can contain up to five different references and up to ten generated outputs.
Python example
Install requests and set the APIMASTER_API_KEY environment variable:
import os
import requests
response = requests.post(
"https://apimaster.ai/v1/images/generations",
headers={"Authorization": "Bearer " + os.environ["APIMASTER_API_KEY"]},
json={
"model": "grok-imagine-image-2.0",
"prompt": "A blue ceramic teapot on a white table, soft studio lighting",
"resolution": "2k",
"quality": "medium",
"aspect_ratio": "1:1",
"n": 1,
},
timeout=(20, 300),
)
response.raise_for_status()
for item in response.json()["data"]:
print(item["url"])
Add image_urls to the JSON body when using references. A timeout does not mean the task was cancelled; check usage logs before resubmitting.
Base pricing
The following official base rates were configured on September 23, 2026, under admin Model Pricing → Image. Final charge = (actual outputs × tier price + references × $0.01) × channel multiplier × recharge coefficient × platform multiplier × user/group coefficient:
| Tier | Base price |
|---|---|
| 1K low | $0.04/image |
| 1K medium | $0.06/image |
| 2K low | $0.06/image |
| 2K medium | $0.08/image |
| Reference input | $0.01/image |
The reference charge is applied once per reference in the request, regardless of n. For example, two 2K medium outputs with one reference have a base amount of $0.08 × 2 + $0.01 = $0.17 before channel and group multipliers. The final charge uses the actual number of images returned, so settlement uses the returned count rather than the requested maximum.
Check the current channel price in the model marketplace and the settled breakdown in usage logs. Prices can vary by channel and account group.
Endpoint and error behavior
- Use
/images/generations; this model does not accept/images/generations/asyncor/images/editsfrom clients. - Allow at least 180 seconds for a normal request and longer for multiple 2K outputs.
- HTTP 400 means the request parameters are invalid, such as an unsupported resolution, quality,
n, pixel size, or duplicate reference URL. Correct the request before retrying. - For authentication or balance errors, check the API key, model access and available balance.
- A synchronous timeout does not prove cancellation: the task may complete and settle later. Check usage logs before submitting again.
Usage logs let you preview and switch between generated images. They record the effective tier, reference count, actual output count, base-price snapshot, all result URLs, and the calculated charge. This lets you audit the image preview and the amount charged after each request.
