Images

POST /v1/images/generations — text-to-image across Google Gemini and OpenAI GPT-Image models. Billed per image out of your key's balance.

Endpoint

http
POST https://llm.nimbusapi.net/v1/images/generations

Parameters

nametyperequireddescription
modelstringyesImage model ID. See the model catalog below.
promptstringyesText prompt. Up to 4000 characters. Longer is fine — Nimbus does not truncate silently.
nintegernoNumber of images to generate, 1 to 10. Default 1. Billed per image.
sizestringnoWIDTHxHEIGHT. Model-specific set below. Default 1024x1024.
qualitystringnostandard | high. High costs roughly 2x. Default standard.
stylestringnonatural | vivid. Style modifier. Ignored by models that do not honor it.
response_formatstringnourl | b64_json. Default url — image is served from the Nimbus CDN for 24h. b64_json embeds the PNG inline.
userstringnoStable per-end-user string. Used for abuse tracking and per-user rate limiting.

Model catalog

modelprovidersizesnotescost
google/gemini-2.5-flash-imageGoogle512x512, 1024x1024, 1024x1536, 1536x1024Fastest option. Good for iteration and thumbnails. Style adherence is weaker than 3-pro.$0.02 / image
google/gemini-3-pro-imageGoogle1024x1024, 1024x1536, 1536x1024, 2048x2048Flagship photorealism. Best for hero shots and cinematic scenes. High quality mode unlocks 2048.$0.08 / image standard, $0.14 high
google/gemini-3.1-flash-imageGoogle512x512, 1024x1024, 1024x1536, 1536x1024Successor to 2.5-flash. Better text rendering; still fast. Recommended default for cost-sensitive traffic.$0.03 / image
openai/gpt-5-imageOpenAI1024x1024, 1024x1792, 1792x1024Balanced quality and speed. Strong prompt adherence, especially for compositional constraints.$0.04 / image standard, $0.08 high
openai/gpt-5-image-miniOpenAI512x512, 1024x1024Cheapest OpenAI option. Fine for icons, avatars, small UI illustrations.$0.015 / image
openai/gpt-5.4-image-2OpenAI1024x1024, 1024x1792, 1792x1024, 2048x2048Newest OpenAI model. Best text-in-image rendering and typography. 2x cost of gpt-5-image high.$0.12 / image standard, $0.20 high

Prices are the pass-through cost debited from your key balance. Nimbus does not mark up image generation.

Request body

json
{
  "model": "google/gemini-3-pro-image",
  "prompt": "A wide-angle photorealistic shot of an alpine cabin at golden hour, warm interior light spilling onto pine snow, hyperreal detail, cinematic depth of field",
  "n": 2,
  "size": "1536x1024",
  "quality": "high",
  "style": "natural",
  "response_format": "url",
  "user": "internal-user-4711"
}

Response — URL

Default response_format. Each image lives at a signed Nimbus CDN URL for 24 hours. Fetch and persist within that window if you need long-term storage.

json
{
  "created": 1735689600,
  "model": "google/gemini-3-pro-image",
  "data": [
    {
      "url": "https://cdn.nimbusapi.net/img/2026-07-01/01H9K7Z2Q4T5N6Y7B8M9F0G1H2-0.png",
      "revised_prompt": "Ultra-wide photorealistic photograph of an alpine cabin at golden hour, warm amber interior light spilling out through mullioned windows onto fresh pine-shadowed snow, cinematic shallow depth of field."
    },
    {
      "url": "https://cdn.nimbusapi.net/img/2026-07-01/01H9K7Z2Q4T5N6Y7B8M9F0G1H2-1.png",
      "revised_prompt": "..."
    }
  ],
  "usage": {
    "images": 2,
    "cost_usd": 0.16
  }
}
  • revised_prompt — the actual prompt the model used after any safety rewriting. Log this alongside the request_id for reproducibility.
  • usage.cost_usd — the exact amount debited from your key balance for this call.

Response — b64_json

Set response_format: "b64_json" to get the PNG inline as base64. Useful when you never want the image to touch the Nimbus CDN — e.g. compliance workloads. Response bodies are larger; expect ~1.4 MB per 1024x1024 image.

json
{
  "created": 1735689600,
  "model": "openai/gpt-5-image",
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA... (truncated) ...ggg==",
      "revised_prompt": "..."
    }
  ],
  "usage": { "images": 1, "cost_usd": 0.04 }
}

Basic call

curl -sS https://llm.nimbusapi.net/v1/images/generations \
  -H "Authorization: Bearer $NIMBUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-image",
    "prompt": "A minimalist product shot of a matte-black hexagonal speaker on a warm concrete surface, soft window light from left",
    "n": 1,
    "size": "1024x1024",
    "quality": "standard"
  }'

Billing

Each successful image debits usage.cost_usd from the key balance. Failed generations (safety block, upstream error, invalid size) are never billed. If a request asks for n: 4 and one is refused by the safety filter, you are billed only for the images actually returned. The per-key USD spend cap (see /docs/authentication) applies here identically to chat completions.

Note. Image generations do not consume any prompt/completion token budget — they are their own line-item on your usage export, tagged kind: image.

Edge cases

  • CDN URLs expire. All response_format: url links are signed and expire 24 hours after generation. Download and re-host any image you plan to serve to your own users.
  • Size must match model. Requesting 2048x2048 on gpt-5-image-mini returns 400 unsupported_size. Use the Model catalog table above.
  • Aspect ratio caveats. Gemini models handle 1536x1024 natively; OpenAI GPT-Image uses 1792x1024 for the same aspect ratio. Pick per-model.
  • Safety refusals. When a prompt is refused, Nimbus returns 403 forbidden with code: policy_violation. No image, no billing. The error message names the category that triggered.
  • Timeouts. High-quality 2048 images can take 25–40s upstream. Set your client HTTP timeout to at least 90s for image workloads.
  • Batches vs parallel. Using n: 4 in one request is more cost-efficient than 4 parallel requests — Nimbus batches at the upstream when the model supports it.

Error codes

  • 400 invalid_request code: unsupported_size when the requested size is not in the model's catalog.
  • 400 invalid_request code: prompt_too_long when prompt exceeds 4000 characters.
  • 402 insufficient_balance — key balance below the estimated cost. Estimated cost is n * per_image_rate.
  • 403 forbidden code: policy_violation when the safety filter rejects the prompt.
  • 503 model_unavailable — every mirror for the requested image model is unhealthy. Fall back to a sibling (see catalog).