Skip to content

Image Generation

📝 Introduction

The gateway offers several families of image generation models:

Family Models Format
OpenAI gpt-image-2 POST /v1/images/generations
Vidu viduq1-image, viduq2-image POST /v1/images/generations
Google Gemini gemini-2.5-flash-image, gemini-3-pro-image-preview, gemini-3.1-flash-image-preview Gemini generateContent or OpenAI chat format

OpenAI Format (/v1/images/generations)

Endpoint

POST /v1/images/generations

Authentication

Authorization: Bearer $WS_API_KEY

Generate an Image ✅

curl http://baseurl/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $WS_API_KEY" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cute baby sea otter floating on its back, watercolor style",
    "n": 1,
    "size": "1024x1024"
  }'

Response Example:

{
  "created": 1713833628,
  "data": [
    {
      "b64_json": "..."
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50
  }
}

gpt-image-2 returns base64-encoded images (b64_json). Other models may return a url field instead.

Vidu Image Models ✅

curl http://baseurl/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $WS_API_KEY" \
  -d '{
    "model": "viduq2-image",
    "prompt": "A futuristic city skyline at sunset, ultra realistic",
    "size": "1024x1024"
  }'

Request Body Parameters

Parameter Type Required Description
model string Yes gpt-image-2, viduq1-image, viduq2-image
prompt string Yes Text description of the desired image
n integer No Number of images to generate. Default 1
size string No e.g. 1024x1024, 1536x1024, 1024x1536, or auto
quality string No e.g. low, medium, high, auto (model-dependent)
response_format string No url or b64_json (model-dependent; gpt-image-2 always returns b64_json)
user string No End-user identifier

Gemini Image Models

Gemini image models generate images through the standard generateContent interface — request image output via responseModalities.

Gemini Format ✅

curl "http://baseurl/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $WS_API_KEY" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Generate an image of a desert oasis at dawn"}]}
    ],
    "generationConfig": {
      "responseModalities": ["TEXT", "IMAGE"]
    }
  }'

Response: generated images are returned as inline_data parts (base64) inside candidates[].content.parts.

Image Editing (image + prompt) ✅

curl "http://baseurl/v1beta/models/gemini-2.5-flash-image:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $WS_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {"inline_data": {"mime_type": "image/png", "data": "<BASE64_IMAGE>"}},
          {"text": "Add a hot air balloon to the sky"}
        ]
      }
    ],
    "generationConfig": {
      "responseModalities": ["TEXT", "IMAGE"]
    }
  }'

Tip

Gemini image models can also be called through the OpenAI chat format — the generated image is returned inside the assistant message content.