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/generationsThis 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 noaspect_ratioorresolutionparameter here; usePOST /v1/imageswhen you need them. - Text to image only. Reference images are rejected with
400; send them toPOST /v1/images/editsinstead.
Authentication
AuthorizationBearerrequiredAPI key as bearer token in the Authorization header. Create keys at
Manage API Keys.
Headers
Content-TypestringrequiredMust be application/json.
Body
modelstringrequiredImage model id from GET /v1/models. Example: gpt-image-2,
gpt-image-1-mini, gemini-3-pro-image.
promptstringrequiredText description of the image to generate.
nintegeroptionalDefault 1Number 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 autoOutput 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.
qualitystringoptionalHow much rendering effort the model spends. Declared per model in
architecture.image_qualities. auto leaves the choice to the model.
autolowmediumhighoutput_formatstringoptionalOutput image format. Declared per model in
architecture.image_output_formats; svg is for vector models.
pngjpegwebpsvgoutput_compressionintegeroptionalCompression level (0-100) for jpeg or webp output.
backgroundstringoptionalBackground of the output. Declared per model in
architecture.image_backgrounds. transparent needs png or webp.
auto leaves the choice to the model.
autotransparentopaqueresponse_formatstringoptionalOnly b64_json is accepted. url returns 400.
b64_jsonuserstringoptionalEnd-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
idstringoptionalAivene-assigned response identifier (avn_...). Used across logs,
billing, and feedback.
createdintegeroptionalUnix timestamp (seconds) when the images were generated.
modelstringoptionalThe model id you sent in the request.
dataImage[]optionalArray of generated images. Each contains b64_json, plus
revised_prompt if the model rewrote your prompt.
sizestringoptionalPixel dimensions of the result, when the model reports them.
usageobjectoptionalToken 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" } }| Status | error.type | Meaning |
|---|---|---|
400 | validation_error | The body failed schema validation. The message names the offending field. |
400 | invalid_request_error | Body 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. |
401 | authentication_error | Missing or invalid API key. |
402 | invalid_request_error | Not enough credit for the request, an unpaid balance, or a spend limit was reached. |
403 | permission_denied_error | The account is suspended, an Admin key was used, or the model isn't included in your organization's tier. |
404 | not_found_error | The model is deprecated. The message names its replacement. |
408 | timeout_error | The model did not finish before the request timed out. |
429 | rate_limit_error | Your organization hit its rate limit for this model. Back off and retry. |
500 | internal_server_error | Unexpected server error. |
502 / 503 | upstream_error | The 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).