Skip to content

Image Generation

/v1/images/generations calls image generation models from the LLMTR catalog through one JSON endpoint. For OpenAI, openai/gpt-image-2 is supported for text-to-image. For Recraft, V2, V3, and V4 raster/vector models are available for text-to-image. 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 doEndpointSupported providersKey fields
Generate an image from scratch (text-to-image)/v1/images/generationsOpenAI, Google, Recraft, Krea, xAIprompt
Generate from a reference image (image-to-image, try-on, image merging)/v1/images/generationsGoogle Gemini image modelsfile_ids, image_urls
Edit an image (xAI image edits)/v1/images/editsxAI 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 from the catalog: GET /api/models?operation=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
}'
FieldValuesNotes
modelrecraft/recraft-v4, recraft/recraft-v4-vector, recraft/recraft-v4-pro, recraft/recraft-v4-pro-vector, recraft/recraft-v3, recraft/recraft-v3-vector, recraft/recraft-v2, recraft/recraft-v2-vectorCanonical LLMTR model ID.
size1:1, 16:9, 9:16, and other Recraft-supported aspect ratios; supported explicit sizes for raster modelsVector models use aspect ratios rather than explicit pixel sizes.
response_formaturl, b64_jsonDefaults to url.
n1-6Number of images to generate in one request.

For Recraft, this first version accepts text-to-image JSON requests only. image_url, image_urls, file_id, file_ids, mask, stream, partial_images, style, style_id, negative_prompt, text_layout, and controls are rejected on this endpoint.

Krea 2 is a foundation image model trained for full creative control. On LLMTR the request appears synchronous: the gateway starts the upstream job, polls it until completion, and returns 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"
}'
FieldValuesNotes
modelkrea/krea-2-medium, krea/krea-2-largeCanonical LLMTR model ID.
aspect_ratio1:1, 4:3, 3:2, 16:9, 2.35:1, 4:5, 2:3, 9:16Defaults to 1:1.
resolution1KKrea 2 currently supports only 1K.
creativityraw, low, medium, highControls how much the model expands your prompt. Uses the provider default (medium) when omitted.
seedintegerReuse the same seed + prompt to reproduce a generation.
response_formaturl, b64_jsonDefaults 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": "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
}'
FieldValuesNotes
size1024x1024, 1024x1536, 1536x1024Defaults to 1024x1024.
qualitylow, medium, highDefaults to medium.
output_formatpng, jpeg, webpDefaults to png.
output_compression0-100Only valid with jpeg and webp.
backgroundopaque, autotransparent is not supported by gpt-image-2.
moderationauto, lowUses the provider default when omitted.
n1-4Number 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
}
}
}

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: V4 $0.04, V4 Vector $0.08, V4 Pro $0.25, V4 Pro Vector $0.30, V3 $0.04, V3 Vector $0.08, V2 $0.022, and V2 Vector $0.044. xAI grok-imagine-image is cataloged at $0.02 per image, and grok-imagine-image-quality at $0.04 per image. If xAI returns usage.cost_in_usd_ticks, settlement uses the real provider cost; otherwise the official per-image price is used as a deterministic fallback. Image edit fallback counts both input images and generated output images. Krea models are billed per image: krea/krea-2-medium $0.030, krea/krea-2-large $0.060. Because the Krea response does not return a provider cost, settlement uses this static per-image price. LLMTR does not add platform margin to model prices; the 6% platform margin only applies when credits are topped up.