Image Generation
Generate brand-new images from a prompt or edit existing ones with a mask.
Every image model - OpenAI's gpt-image-2 / gpt-image-1.5 /
gpt-image-1-mini and Google's Gemini image models
(gemini-2.5-flash-image, gemini-3-pro-image, gemini-3.1-flash-image,
gemini-3.1-flash-lite-image) alike - is reachable through one endpoint.
POST /v1/images - JSON in, image out. Pass any supported model id and the
gateway routes it to the right provider. Attach input_references and the
same request edits or remixes those images instead.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | yes | Image model id, e.g. gpt-image-2, gpt-image-1-mini, or gemini-2.5-flash-image. |
prompt | string | yes | Description of the desired image, or the edit instruction. |
input_references | array | no | Source images to work from. See below. |
n | integer | no | Number of images. Defaults to 1. |
aspect_ratio | string | no | Output shape, e.g. '16:9'. Model-dependent. |
quality | string | no | E.g. 'low', 'medium', 'high'. Model-dependent. |
resolution | string | no | E.g. '2K'. Used instead of quality by some models. |
output_format | string | no | 'png', 'jpeg', or 'webp'. |
user | string | no | End-user identifier for safety tracking. |
Example
curl https://api.aivene.com/v1/images \
-H "Authorization: Bearer $AIVENE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "Studio photo of an orange tabby cat wearing sunglasses",
"aspect_ratio": "1:1",
"n": 1
}'Response:
{
"id": "avn_01hzy8m2q9x4v7",
"created": 1715000000,
"model": "gemini-2.5-flash-image",
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "Studio portrait of an orange tabby cat ..."
}
]
}Always base64
Images come back as b64_json, never as a short-lived URL. Decode and
store the bytes yourself.
Editing with references
Pass the images you want the model to work from. Each reference accepts an
https:// URL, a data: URL, or a file_id from the Files API.
import { writeFile } from 'node:fs/promises';
const response = await fetch('https://api.aivene.com/v1/images', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AIVENE_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-2.5-flash-image',
prompt: 'Put the logo on a ceramic coffee mug, studio lighting',
input_references: [
{ type: 'image_url', image_url: { url: 'https://example.com/logo.png' } }
]
})
});
const result = await response.json();
await writeFile('mug.png', Buffer.from(result.data[0].b64_json, 'base64'));Models whose architecture.input_modalities has no image reject
input_references with a 400 rather than ignoring them.
Call it with plain JSON
/v1/images takes a JSON body, not multipart. Any HTTP client works -
fetch, requests, curl - and reference images travel as URLs inside
the body rather than as uploaded file parts.
Pricing
Image endpoints do not bill on tokens. The price depends on model,
aspect_ratio, and quality or resolution. See the Console usage page
for exact rates per request.
Safety
Prompts pass through the downstream provider's content filter. Disallowed
prompts return 400 invalid_request_error with the rejection reason in
error.message. The gateway does not silently rewrite prompts - if a
model returns revised_prompt, that came from the provider.
Errors
| Status | error.type | Meaning |
|---|---|---|
400 | invalid_request_error | Prompt rejected, unsupported parameter value, or bad params. |
401 | authentication_error | Missing or invalid API key. |
402 | billing_error | Account out of credit or hit a spend limit. |
413 | invalid_request_error | Image file too large. |
429 | rate_limit_error | RPM exceeded. |
500 | internal_server_error | Unexpected gateway failure. |
502 / 503 | upstream_error | Downstream provider failure. |