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

FieldTypeRequiredDescription
modelstringyesImage model id, e.g. gpt-image-2, gpt-image-1-mini, or gemini-2.5-flash-image.
promptstringyesDescription of the desired image, or the edit instruction.
input_referencesarraynoSource images to work from. See below.
nintegernoNumber of images. Defaults to 1.
aspect_ratiostringnoOutput shape, e.g. '16:9'. Model-dependent.
qualitystringnoE.g. 'low', 'medium', 'high'. Model-dependent.
resolutionstringnoE.g. '2K'. Used instead of quality by some models.
output_formatstringno'png', 'jpeg', or 'webp'.
userstringnoEnd-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

Statuserror.typeMeaning
400invalid_request_errorPrompt rejected, unsupported parameter value, or bad params.
401authentication_errorMissing or invalid API key.
402billing_errorAccount out of credit or hit a spend limit.
413invalid_request_errorImage file too large.
429rate_limit_errorRPM exceeded.
500internal_server_errorUnexpected gateway failure.
502 / 503upstream_errorDownstream provider failure.