Create Image (OpenAI format)

Generate images from text with the OpenAI Images API request format, on every image model.

Generate an image from a text prompt using the OpenAI Images API request format. Point the OpenAI SDK at https://api.aivene.com/v1 and images.generate works unchanged, on every image model in the catalogue.

POST /v1/images/generations

This endpoint is a compatibility layer over POST /v1/images: the request is translated into the same call, so model support, billing and the response are identical. The differences are in the request:

  • The output shape is set with size (WIDTHxHEIGHT), which is matched to one of the model's aspect ratios. There is no aspect_ratio or resolution parameter here; use POST /v1/images when you need them.
  • Text to image only. Reference images are rejected with 400; send them to POST /v1/images/edits instead.

Authentication

AuthorizationBearerrequired

API key as bearer token in the Authorization header. Create keys at Manage API Keys.

Headers

Content-Typestringrequired

Must be application/json.

Body

modelstringrequired

Image model id from GET /v1/models. Example: gpt-image-2, gpt-image-1-mini, gemini-3-pro-image.

promptstringrequired

Text description of the image to generate.

nintegeroptionalDefault 1

Number of images to generate, 1 to 10. A model with a lower limit declares it in architecture.image_max_n (many only support 1).

sizestringoptionalDefault auto

Output shape as WIDTHxHEIGHT (for example 1024x1024 or 1536x1024), or auto to leave it to the model. Any size whose ratio is in the model's architecture.image_aspect_ratios is accepted, and the image is generated at that aspect ratio. The pixel dimensions are the model's own and can differ from the requested size; the response size reports them. A ratio the model doesn't support returns 400 listing the supported ones.

qualitystringoptional

How much rendering effort the model spends. Declared per model in architecture.image_qualities. auto leaves the choice to the model.

Allowed values:autolowmediumhigh
output_formatstringoptional

Output image format. Declared per model in architecture.image_output_formats; svg is for vector models.

Allowed values:pngjpegwebpsvg
output_compressionintegeroptional

Compression level (0-100) for jpeg or webp output.

backgroundstringoptional

Background of the output. Declared per model in architecture.image_backgrounds. transparent needs png or webp. auto leaves the choice to the model.

Allowed values:autotransparentopaque
response_formatstringoptional

Only b64_json is accepted. url returns 400.

Allowed values:b64_json
userstringoptional

End-user identifier for abuse tracking.

Responses are always base64

Images come back as data[].b64_json, on every model. Leave response_format unset or send b64_json.

Rejected, not ignored

These OpenAI parameters return 400 instead of being dropped, so a request never silently produces something other than what you asked for: stream: true, response_format: "url", mask, image/images (use the edits endpoint), and any value other than auto for moderation, style or input_fidelity.

The model catalogue decides

GET /v1/models reports each model's architecture.image_aspect_ratios, image_qualities, image_backgrounds, image_output_formats and image_max_n. A value outside those lists returns 400 naming the supported values.

Response

idstringoptional

Aivene-assigned response identifier (avn_...). Used across logs, billing, and feedback.

createdintegeroptional

Unix timestamp (seconds) when the images were generated.

modelstringoptional

The model id you sent in the request.

dataImage[]optional

Array of generated images. Each contains b64_json, plus revised_prompt if the model rewrote your prompt.

sizestringoptional

Pixel dimensions of the result, when the model reports them.

usageobjectoptional

Token usage (input_tokens, output_tokens, total_tokens, plus input_tokens_details/output_tokens_details image vs. text breakdowns) for token-billed models. When the model hits its prompt cache, input_tokens_details also carries cached_tokens (and cache_write_tokens where the model bills cache writes), counted inside input_tokens. Models billed per image report all-zero usage plus an image_count.

Errors

All errors share one shape:

{ "error": { "message": "...", "type": "invalid_request_error" } }
Statuserror.typeMeaning
400validation_errorThe body failed schema validation. The message names the offending field.
400invalid_request_errorBody is not JSON, unknown model, a model not available on this endpoint, a size or other value the model does not support, a rejected parameter (see above), reference images sent to this endpoint, or a content policy rejection.
401authentication_errorMissing or invalid API key.
402invalid_request_errorNot enough credit for the request, an unpaid balance, or a spend limit was reached.
403permission_denied_errorThe account is suspended, an Admin key was used, or the model isn't included in your organization's tier.
404not_found_errorThe model is deprecated. The message names its replacement.
408timeout_errorThe model did not finish before the request timed out.
429rate_limit_errorYour organization hit its rate limit for this model. Back off and retry.
500internal_server_errorUnexpected server error.
502 / 503upstream_errorThe model is temporarily unavailable. Safe to retry.

When the model itself rejects a request, the response keeps the model's 4xx status with type upstream_error or invalid_request_error, and error.code names the cause when it is known (context_length_exceeded, content_filter, request_too_large).