Skip to content

Image Generation

/v1/images/generations calls image generation models from the LLMTR catalog through one JSON endpoint. For Meta, meta/muse-image-1.0 performs text-to-image. For OpenAI, openai/gpt-image-2 is supported for text-to-image. For Recraft, V3, V4, V4.1, V4.1 Flash, and V4 Styles raster/vector models perform text-to-image; the V4.1 and V4 Styles models also apply a style from reference images. For Krea, krea/krea-2-medium and krea/krea-2-large perform text-to-image. For Google, Imagen 4 (fast/generate/ultra) text-to-image remains available until August 17, 2026; after that date those model IDs are rejected. Gemini image models support both text-to-image and reference-image generation (image-to-image, try-on, image merging). For xAI, xai/grok-imagine-image and xai/grok-imagine-image-quality perform text-to-image; xAI's image editing flow lives on the separate /v1/images/edits endpoint.

What you want to do Endpoint Supported providers Key fields
Generate an image from scratch (text-to-image) /v1/images/generations Meta, OpenAI, Google, Recraft, Krea, xAI prompt
Generate from a reference image (image-to-image, try-on, image merging) /v1/images/generations Google Gemini image models file_ids, image_urls
Generate in the style of reference images /v1/images/generations Recraft V4.1 and V4 Styles models style_reference_urls, style_id
Edit an image (xAI image edits) /v1/images/edits xAI only (xai/grok-imagine-image, xai/grok-imagine-image-quality) image

/v1/images/edits is available only for xAI image models. Calling it with a Google or OpenAI model returns 400 unsupported_operation and the response body steers you to the correct endpoint: Google routes to /v1/images/generations with file_ids; OpenAI and Recraft route to text-to-image. To enumerate every image-capable model, use model discovery: the entries in GET /v1/models whose supported_operations includes IMAGES_GENERATIONS.

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "recraft/recraft-v4-pro",
"prompt": "Premium coffee packaging product visual on a white background with soft shadows",
"size": "1:1",
"response_format": "url",
"n": 1
}'
Model Output Price per image Style
recraft/recraft-v4.1 Raster, 1K $0.035 Optional
recraft/recraft-v4.1-vector Vector (SVG) $0.08 Optional
recraft/recraft-v4.1-pro Raster, 2K $0.21 Optional
recraft/recraft-v4.1-pro-vector Vector (SVG) $0.30 Optional
recraft/recraft-v4.1-utility Raster, 1K $0.035 Optional
recraft/recraft-v4.1-utility-vector Vector (SVG) $0.08 Optional
recraft/recraft-v4.1-utility-pro Raster, 2K $0.21 Optional
recraft/recraft-v4.1-utility-pro-vector Vector (SVG) $0.30 Optional
recraft/recraft-v4.1-flash Raster, 1K $0.007 Not supported
recraft/recraft-v4-styles Raster, 1K $0.035 Required
recraft/recraft-v4-styles-vector Vector (SVG) $0.05 Required
recraft/recraft-v4-styles-pro Raster, 2K $0.10 Required
recraft/recraft-v4-styles-pro-vector Vector (SVG) $0.12 Required
recraft/recraft-v4 Raster, 1K $0.04 Not supported
recraft/recraft-v4-vector Vector (SVG) $0.08 Not supported
recraft/recraft-v4-pro Raster, 2K $0.25 Not supported
recraft/recraft-v4-pro-vector Vector (SVG) $0.30 Not supported
recraft/recraft-v3 Raster $0.04 Not supported
recraft/recraft-v3-vector Vector (SVG) $0.08 Not supported

The Utility models produce flatter lighting and simpler, front-facing composition than the main V4.1 models; use them for mockups and product listing images. V4.1 Flash has the lowest unit price and generates 1K raster only.

Field Values Notes
model Model IDs from the table above Canonical LLMTR model ID.
size 1:1, 16:9, 9:16, and other Recraft-supported aspect ratios; explicit sizes that match the model for raster models 1K raster models accept sizes such as 1024x1024 or 1536x768, 2K (Pro) models sizes such as 2048x2048 or 3072x1536; V3 uses its own size table. Vector models take aspect ratios only.
response_format url, b64_json Defaults to url.
output_format png, webp Image format for raster models; WebP when omitted. jpeg is not supported and also returns WebP. Vector models always return SVG. Each image's mime_type states the format returned.
n 1-6 Number of images to generate in one request.
style_reference_urls 1-10 images; https:// URLs or base64 data URLs Only on models with style support. PNG, JPEG, or WebP; at least 256 px on the shortest side, each under 10 MB. The whole request body is capped at 24 MB; use https:// URLs for large images.
style_id A style_id returned by an earlier response Only on models with style support; cannot be sent together with style_reference_urls.
style_match flexible, precise How closely the style is followed; flexible when omitted.

image_url, image_urls, file_id, file_ids, mask, stream, partial_images, style, negative_prompt, text_layout, and controls are rejected for Recraft models. Sending a style field to a model without style support (V4.1 Flash, V4, V3) returns 400 unsupported_input.

recraft/recraft-v2 and recraft/recraft-v2-vector model IDs are rejected by LLMTR with HTTP 410 model_retired as of 24 August 2026; the provider stopped responding to requests for these two models. Use recraft/recraft-v3 and recraft/recraft-v3-vector instead — pricing rises by about 82% per image (see "Pricing" below).

The V4 Styles models require a style on every request; a request without one is rejected with 400 invalid_request. On the V4.1 models a style is optional. On the first request, send your reference images in style_reference_urls:

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "recraft/recraft-v4-styles",
"prompt": "Product shot on a wooden table, soft studio light",
"style_reference_urls": ["https://example.com/brand-reference.png"],
"style_match": "precise"
}'

The response carries the id of the style that was created, next to the images:

{
"created": 1790193540,
"model": "recraft/recraft-v4-styles",
"data": [
{ "b64_json": null, "url": "https://img.recraft.ai/...", "mime_type": "image/webp" }
],
"style_id": "229b2a75-05e4-4580-85f9-b47ee521a00d"
}

To keep generating in the same style, send the style_id instead of the references again:

{
"model": "recraft/recraft-v4-styles",
"prompt": "A teapot in the same style",
"style_id": "229b2a75-05e4-4580-85f9-b47ee521a00d"
}
  • A style_id can only be used by the LLMTR account that created it. An id that belongs to another account, or is unknown, returns 404 style_not_found.
  • A style is bound to the model it was created with; use the style_id with that same model.
  • A request with style_reference_urls adds a one-time style-creation fee to the image price. Reusing a style_id does not.

Krea 2 is a foundation image model trained for full creative control. The request is synchronous: you do not poll a job status, you get the result in a single response. Krea 2 Medium is fast and cost-effective; Krea 2 Large is stronger for photographic realism and rawer textures.

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "krea/krea-2-medium",
"prompt": "A cinematic glass cabin beside a frozen lake at sunrise",
"aspect_ratio": "16:9",
"resolution": "1K",
"creativity": "medium",
"response_format": "url"
}'
Field Values Notes
model krea/krea-2-medium, krea/krea-2-large Canonical LLMTR model ID.
aspect_ratio 1:1, 4:3, 3:2, 16:9, 2.35:1, 4:5, 2:3, 9:16 Defaults to 1:1.
resolution 1K Krea 2 currently supports only 1K.
creativity raw, low, medium, high Controls how much the model expands your prompt. Uses the provider default (medium) when omitted.
seed integer Reuse the same seed + prompt to reproduce a generation.
response_format url, b64_json Defaults to url.

For Krea, this first version does text-to-image only and returns a single image per request (n may only be 1). image_url, image_urls, file_id, file_ids, mask, size, stream, and partial_images are rejected on this endpoint. Krea returns the output image as a hosted url; if you send response_format: "b64_json", LLMTR downloads the image and responds with base64.

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "meta/muse-image-1.0",
"prompt": "A minimalist product photo of a ceramic coffee mug on a wooden table, natural light",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json",
"output_format": "webp"
}'
Field Values Notes
model meta/muse-image-1.0 Canonical LLMTR model ID.
n 1-6 Number of images to generate in one request. The provider accepts up to 10, but LLMTR's shared image-generation request schema caps this field at 6 across every provider.
size a "WxH" string, e.g. 1024x1536 Sets the aspect ratio, not the exact pixel size; the image is produced at the model's own resolution. Omit for the default aspect ratio.
response_format url, b64_json Defaults to b64_json.
output_format png, jpeg, webp Defaults to webp.

Muse Image is text-to-image only on this endpoint. image_url, image_urls, file_id, file_ids, mask, quality, background, moderation, output_compression, resolution, aspect_ratio, creativity, seed, stream: true, and partial_images are rejected (omitting stream or sending false works normally). Image editing and multi-turn refinement are not available through LLMTR yet.

Muse Image can look up real-world references before it renders (a known place, product, logo, or style; a current fact such as a price or date) — this lookup step is automatic, needs no configuration on your part, and is included in the flat per-image price described below.

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"prompt": "A minimalist product photo of a coffee mug on a white background with natural light",
"size": "1024x1024",
"quality": "medium",
"output_format": "png",
"background": "opaque",
"moderation": "auto",
"n": 1
}'
Field Values Notes
size 1024x1024, 1024x1536, 1536x1024 Defaults to 1024x1024.
quality low, medium, high Defaults to medium.
output_format png, jpeg, webp Defaults to png.
output_compression 0-100 Only valid with jpeg and webp.
background opaque, auto, transparent transparent works with png or webp only; a preview at OpenAI.
moderation auto, low Uses the provider default when omitted.
n 1-4 Number of images to generate in one request.

For OpenAI, image_url, image_urls, file_id, file_ids, mask, stream, and partial_images are rejected on this endpoint. Those fields belong to edits and streaming flows and require separate security and billing support.

Google image models use the same endpoint. The google/imagen-4.0-generate-001, google/imagen-4.0-ultra-generate-001, and google/imagen-4.0-fast-generate-001 model IDs are rejected by LLMTR with HTTP 410 model_retired starting August 17, 2026 at 00:00 Europe/Istanbul. LLMTR does not automatically forward these Imagen 4 requests to gemini-3.1-flash-image or any other model; your integration must explicitly choose an active Google image model.

Gemini image models accept reference images through file_id, file_ids, image_url, and image_urls. Use the Google image generation page for Google-specific image-to-image and multi-reference examples.

Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-flash-image",
"prompt": "A minimalist modern workspace",
"size": "1K",
"aspect_ratio": "16:9",
"n": 1
}'
Terminal window
curl "$LLMTR_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "xai/grok-imagine-image",
"prompt": "Studio product photo of a matte black mechanical keyboard",
"aspect_ratio": "16:9",
"resolution": "1k",
"response_format": "url",
"n": 1
}'

xAI image edits send one or more reference images in JSON:

Terminal window
curl "$LLMTR_BASE_URL/v1/images/edits" \
-H "Authorization: Bearer llmtr-your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "xai/grok-imagine-image",
"prompt": "Keep the product, replace the background with a clean white studio",
"image": {
"type": "image_url",
"url": "https://example.com/input.png"
},
"response_format": "b64_json"
}'

xAI response url fields (on the imgen.x.ai domain) are short-lived; the TTL is inherited from upstream and LLMTR does not extend it. To display the image persistently in your UI:

  • Use response_format: "b64_json" — the response carries base64-encoded bytes you can store yourself; this is the recommended default shown above.
  • Or, if you received a url, download it as soon as the response comes back and mirror it on your own CDN. Do not surface the imgen.x.ai URL directly to end users.
{
"created": 1773000000,
"model": "openai/gpt-image-2",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"mime_type": "image/png"
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 400,
"total_tokens": 420,
"input_tokens_details": {
"text_tokens": 20
}
}
}

meta/muse-image-1.0 is billed at a flat $0.01 per image; this rate is unaffected by size, output_format, or whether the model used its lookup/reference step, and only images that are successfully generated and returned are charged. gpt-image-2 is billed by tokens: input text, input image, and output image tokens are calculated with separate price rules. Recraft models are billed per image; each model's price is in the "Recraft Models" table above. A request with style_reference_urls adds a one-time $0.005 per request for style creation; reusing a style_id does not. (The retired V2 $0.022 and V2 Vector $0.044 prices no longer apply; these IDs no longer accept requests, see above.) xAI grok-imagine-image is cataloged at $0.02 per image, and grok-imagine-image-quality at $0.05 per image. When xAI reports the actual cost, billing follows that cost; when it does not, the per-image price above applies. Image edit requests count both the images you send and the images produced. Krea models are billed per image: krea/krea-2-medium $0.030, krea/krea-2-large $0.060; Krea is always billed at that per-image price. LLMTR does not add platform margin to model prices; the 8% platform margin only applies when credits are topped up.

xAI API images generations: aspect_ratio, grok-imagine-image-quality and b64_json

Section titled “xAI API images generations: aspect_ratio, grok-imagine-image-quality and b64_json”

Send one POST /v1/images/generations request with model xai/grok-imagine-image-quality, aspect_ratio such as "16:9", resolution "1k" or "2k", and response_format "b64_json". The base64 image is returned in data[0].b64_json; the quality model costs $0.05 per image, while standard xai/grok-imagine-image costs $0.02.

xAI Images API: aspect_ratio, grok-imagine-image-quality, b64_json

xAI Grok Imagine: images generations, aspect_ratio and edits with reference images

Section titled “xAI Grok Imagine: images generations, aspect_ratio and edits with reference images”

Generate xAI Grok Imagine images with POST /v1/images/generations, setting aspect_ratio such as 16:9 and resolution to "1k" or "2k". Edit via POST /v1/images/edits using only xai/grok-imagine-image ($0.02 per image) or xai/grok-imagine-image-quality ($0.05 per image); image accepts an HTTPS URL or a base64 data:image/... URI, and images supports 1 to 5 reference images.

Grok Image Editing: What Is the Image ID Format?

OpenAI gpt-image-2: transparent background is not supported for this model (400)

Section titled “OpenAI gpt-image-2: transparent background is not supported for this model (400)”

This 400 is OpenAI's behaviour from before 20 August 2026; since then gpt-image-2 accepts background: "transparent" as a preview. Transparent backgrounds work with output_format png or webp; with jpeg the request returns 400 invalid_request.

OpenAI gpt-image-2 Transparent Background 400 Error