Skip to content

OpenAI-compatible

Image generation (Images)

Generate images in the OpenAI Images format — URL, parameters, response and samples — and which endpoint Gemini image models use.

Compatible with OpenAI’s Create image.

POST https://noviahub.com/v1/images/generations

For models whose endpoint labels include Image, such as gpt-image-2 (check on Models & Pricing).

Header Required Description
Authorization Yes Bearer <your API key>
Content-Type Yes application/json
Parameter Type Required Description
model string Yes Model ID, such as gpt-image-2. Without it the gateway assumes dall-e, which NoviaHub doesn’t have, so the call returns 503.
prompt string Yes Description of the image. The gateway doesn’t check it, but the model needs it.
n integer No Number of images, 1 to 128. Missing or 0 means 1; above 128 returns an error.
size string No Size, such as 1024x1024. Use the letter x, not the multiplication sign ×, or you get an error.
quality string No Quality; values depend on the model.
response_format string No How the image is returned, such as b64_json or url, if the model supports it.
background, output_format, output_compression, moderation, style, partial_images, input_fidelity — No Forwarded as defined by OpenAI; support depends on the model.
stream boolean No Stream the result (if the model supports it).
user — No User identifier, forwarded as is.

Fields not in the table are not forwarded upstream.

终端窗口
curl https://noviahub.com/v1/images/generations \
-H "Authorization: Bearer $NOVIAHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "An orange cat sunbathing on a windowsill, watercolour style",
"size": "1024x1024",
"n": 1
}'
Field Description
created Creation time (Unix seconds).
data[] One entry per image. The image is in b64_json (Base64) or url, depending on the model.
usage Usage, when the model reports it.
Example response (test instance; image data shortened)
{
"created": 1790609867,
"data": [{ "b64_json": "iVBORw0KGgo=" }],
"usage": { "input_tokens": 10, "output_tokens": 1056, "total_tokens": 1066 }
}

b64_json is the image file encoded in Base64; decode it and save it, as the samples do.

Whether a model is billed by tokens or per image, and at what price, is shown on its Models & Pricing page.

Gemini image models such as gemini-3.1-flash-image can be called in two ways:

  1. Native Gemini endpoint (recommended): POST /v1beta/models/gemini-3.1-flash-image:generateContent; see generateContent. The generated image is in candidates[].content.parts[].inlineData (mimeType plus Base64 data).
  2. Chat Completions: POST /v1/chat/completions with this image model as model; the gateway asks the model for both text and image output. Images come back inside choices[0].message.content as Markdown images: ![image](data:<image type>;base64,<data>).
    • Set aspect ratio and size with extra_body.google.image_config, using the keys aspect_ratio and image_size (snake_case only; camelCase keys are rejected).
HTTP status Cause
400 n above 128 (n must be an integer between 1 and 128), the sign × in size, or the body isn’t valid JSON.
401 The key is invalid, disabled, expired or out of quota.
403 The key isn’t allowed to use this model, the IP isn’t on the allow list, or the account balance is too low.
500 A Gemini image model was called on this endpoint (convert_request_failed).
503 Wrong or missing model ID, or no channel is currently available for the model.

See Errors and troubleshooting for details.