llmboxDocumentationSign in
API · Images

Images

POST /v1/images/generations — image generation from a prompt and references.

POST /v1/images/generations generates images in the OpenAI Images format. It works only with image models from the catalog.

Request

curl https://llmbox.cc/v1/images/generations \
  -H "Authorization: Bearer $LLMBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-2",
    "prompt": "A fox in a neon city, watercolor",
    "n": 1,
    "resolution": "1K",
    "quality": "medium"
  }'

Response

json
{
  "created": 1790000000,
  "data": [{"b64_json": "iVBORw0KGgo..."}]
}

Specifics

  • The response never streams, and generation may take minutes — give your client a generous timeout.
  • Images come in data[].b64_json. If the provider returns a link, the gateway downloads the file itself — the response has no links to the provider's storage.
  • n is 1 to 10. The response contains at most n images, even if the model generated more. You are billed per delivered image.
  • Canceling (dropping the connection) after the provider accepted the request charges the price times n, even though no images arrive. Before that, nothing is charged (see Balance and pricing).
  • For GPT Image 2, the size is set by the resolution field (1K, 2K or 4K), and the quality by quality.
  • References go in the image / images fields — as a link or a base64 data: URL. The request body limit is 90 MiB.
  • Other parameters (size, aspect_ratio, resolution, image_size, quality, background, output_format, output_compression, negative_prompt, seed) are passed to the model as is; which fields and values it supports is up to its provider. A field the model does not know may get the request rejected with 400: for example, some models set the size via image_size and do not accept aspect_ratio.

Generation errors

HTTPcodeWhat to do
400content_policy_violationThe content policy rejected the prompt — change it.
400invalid_imageThe model rejected the reference — try a different image.
422generation_failedThe model returned no image — retry or rephrase the prompt.

Other codes are in Errors.