🎁 New Sign up free, 10 calls on us. Up to $1, no card needed.

Image Generation

POST /v1/images/generations

Generate images from a text prompt. OpenAI-compatible — the same endpoint and SDK call (client.images.generate) as OpenAI's image API, routed across OpenAI, Google, Alibaba, and ByteDance image models behind one API key.

Access is currently allowlist-gated (specific workspaces/users). A key that is not allowlisted receives 403 image_gateway_not_allowlisted — ask your administrator to enable it for your workspace.

Request Body

ParameterTypeDescription
model*stringThe image model to use (e.g. gpt-image-1, qwen-image-2.0, seedream-4-0-250828). List all available models via GET /v1/images/models.
prompt*stringText description of the desired image.
nintegerNumber of images to generate (default 1).
sizestringImage size, e.g. 1024x1024. Support varies by model — some accept only specific sizes; omit to use the model's default.
qualitystringQuality/rendering hint where the model supports it (e.g. standard, hd).
response_formatstringb64_json (default) returns base64 image bytes; url returns a fetchable URL where the upstream supports it.
seedintegerOptional seed for reproducible output (where supported).
negative_promptstringOptional text describing what to avoid (where supported).
imagestring | string[]Image-to-image input: base64 or a data URI (a string, or an array for multiple reference images). Including it edits the input image per the prompt instead of generating from text alone. http(s) URLs are not supported yet.

Available models

Model availability depends on your deployment. Fetch the live, compliance-aware list via GET /v1/images/models. A representative set:

Not sure which model? Pick by what you need

You needNoteRecommended models
Cheapest $0.03 / image wan2.7-image seedream-4-0-250828
Highest quality gemini-3-pro-image-preview gpt-image-2
Image editing (image-to-image) send the image field gpt-image-2 seedream-4-0-250828 wan2.7-image
Keep data outside mainland China Western vendors gpt-image-2 gemini-3-pro-image-preview
Slow / cross-border client links response_format: "url" wan2.7-image qwen-image-2.0
ModelProviderPriceResponseEdit (i2i)Notes
gpt-image-2 OpenAI token · $5→$30 /1M b64 only ≤16 Flagship; org verification required
gpt-image-1.5 OpenAI token · $5→$32 /1M b64 only ≤16 Deprecated
gpt-image-1 OpenAI token · $5→$40 /1M b64 only ≤16 Deprecated
gpt-image-1-mini OpenAI token · $2→$8 /1M b64 only ≤16 Deprecated; cheapest OpenAI
gemini-3-pro-image-preview Google token · $2→$120 /1M b64 only ≤14 Preview; top quality
gemini-3.1-flash-image-preview Google token · $0.5→$60 /1M b64 only ≤14 Preview
gemini-3.1-flash-lite-image Google token · $0.25→$30 /1M b64 only ≤14 Preview; fastest Gemini
gemini-2.5-flash-image Google token · $0.3→$30 /1M b64 only ≤3 Retiring 2026-10-02
qwen-image-2.0 Alibaba $0.035 / image b64 · url ✓ ≤3
qwen-image-2.0-pro Alibaba $0.075 / image b64 · url ✓ ≤3 Higher quality
wan2.7-image Alibaba $0.03 / image b64 · url ✓ ≤9 Cheapest
wan2.7-image-pro Alibaba $0.075 / image b64 · url ✓ ≤9
seedream-4-0-250828 ByteDance $0.03 / image b64 · url ✓ ≤10 Accepts 1024×1024
seedream-4-5-251128 ByteDance $0.04 / image b64 · url ✓ ≤10 size ≥ 1920×1920
seedream-5-0-260128 ByteDance $0.035 / image b64 · url ✓ ≤10 5.0 Lite; size ≥ 1920×1920

Price: token · $in→$out /1M = billed on usage (OpenAI / Google); $/image = flat per generated image. Response: b64 · url ✓ models can also return a pre-signed vendor-hosted URL (response_format: "url", valid ~24 h). Download speed depends on the vendor: Alibaba URLs ride a globally-accelerated CDN (fast everywhere, incl. mainland China); ByteDance seedream URLs are served from Singapore object storage (fast for overseas clients, slow from mainland China). b64 only models reject response_format: "url" with 400 url_not_supported. Edit (i2i) = every model supports image-to-image (send the image field); the value is the max reference images.

Image-to-image (edit)

Add an image field to the same request to edit or reference an input image. Supported on gpt-image, gemini-*-image, qwen-image / wan2.7, and seedream (each model caps how many input images it accepts). Send the image as base64 or a data URI; pass an array for multiple references.

curl https://synthorai.io/v1/images/generations \
  -H "Authorization: Bearer $SYNTHORAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "add a small red party hat on the main subject",
    "image": "'"$(base64 -i input.png)"'"
  }'

Response format

Set response_format: b64_json returns base64 image bytes (default); url returns a fetchable URL where the upstream supports it. The response matches OpenAI's images API: { created, data: [{ b64_json | url }] }.

url is supported only where the upstream itself hands back a CDN URL — currently the Alibaba and ByteDance families (qwen-image*, wan*, seedream*); the image downloads from the vendor's CDN via a pre-signed URL valid ~24 hours. OpenAI and Google models (gpt-image*, gemini*) are b64-only: requesting url there returns 400 url_not_supported — rejected before generation, nothing is billed. Check per model via the supports_url field of GET /v1/images/models, or the model table above.

Complete example — url mode

Generate with response_format: "url", read data[0].url from the response, then download the image from the vendor's CDN — a full round-trip you can paste into a terminal:

# 1) Generate — ask for a URL instead of inline base64
curl https://synthorai.io/v1/images/generations \
  -H "Authorization: Bearer $SYNTHORAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-image",
    "prompt": "a serene mountain lake at sunrise",
    "response_format": "url"
  }'

# → 200 in ~15–30 s. Tiny JSON body — no image bytes inline:
{
  "created": 1783064343,
  "data": [
    {
      "url": "https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/8a/20260703/xxxx.png?Expires=1783151704&OSSAccessKeyId=LTAI...&Signature=bvTa..."
    }
  ]
}

# 2) Download from the vendor CDN — the URL is pre-signed, no auth header needed
curl -o out.png "https://dashscope-463f.oss-accelerate.aliyuncs.com/1d/8a/20260703/xxxx.png?Expires=1783151704&OSSAccessKeyId=LTAI...&Signature=bvTa..."

The URL is pre-signed — anyone with it can download, no auth header needed — and expires in ~24 hours: fetch promptly and re-host the file if you need it long-term. Typical end-to-end: ~15–30 s generation + sub-second CDN download.

Latency, large responses & timeouts

Generation time varies by model: qwen-image-2.0 typically returns in ~5–10 s, while wan2.7-image and seedream-class models take ~15–30 s (longer at 2K+ sizes). The gateway allows up to 180 s per request and returns 504 generation_timeout beyond that — this API itself never returns 408.

The default response_format=b64_json embeds the full image in the response body (2–3 MB of base64 for large models). On slow or long-haul client links, downloading that body can add minutes and trip your HTTP client's or relay gateway's own timeout — typically surfaced on your side as 408 or a timeout error.

For large-image models or clients far from the serving region, prefer response_format: "url" — the response body is tiny and the image downloads straight from the vendor. Vendor difference: Alibaba (qwen-image*/wan*) URLs ride a globally-accelerated CDN, fast even from mainland China; ByteDance seedream URLs are served from Singapore object storage — fast overseas, slow from mainland China. URLs are pre-signed and valid for ~24 hours: fetch promptly and re-host if you need persistence. If you must use b64_json over a slow link, raise your client timeout to ≥180 s.

Billing

Billed only on success (HTTP 200). Most models are charged per image (count × unit price); OpenAI gpt-image-* models that return token usage are charged per token. Every charge is recorded with request_id, model, and cost for traceability.

Some models reject an explicit size (e.g. seedream-4-5-251128 / seedream-5-0-260128 return 400 on size=1024x1024). On an InvalidParameter:size error, omit size to use the model's default.

Example — curl

curl https://synthorai.io/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "a serene mountain lake at sunrise, photorealistic",
    "n": 1,
    "size": "1024x1024"
  }'

Example — Python (OpenAI SDK)

from openai import OpenAI
import base64

client = OpenAI(base_url="https://synthorai.io/v1", api_key="YOUR_API_KEY")

resp = client.images.generate(
    model="qwen-image-2.0",
    prompt="a serene mountain lake at sunrise, photorealistic",
    n=1,
    size="1024x1024",
)
# Default response_format is b64_json
img = base64.b64decode(resp.data[0].b64_json)
with open("out.png", "wb") as f:
    f.write(img)

Example — Node (OpenAI SDK)

import OpenAI from "openai";
import fs from "node:fs";

const client = new OpenAI({
  baseURL: "https://synthorai.io/v1",
  apiKey: process.env.SYNTHORAI_API_KEY,
});

const resp = await client.images.generate({
  model: "seedream-4-0-250828",
  prompt: "a serene mountain lake at sunrise, photorealistic",
  n: 1,
});
fs.writeFileSync("out.png", Buffer.from(resp.data[0].b64_json, "base64"));

Idempotency

Pass an X-Idempotency-Key header to make retries safe: a repeat request with the same key returns 409 instead of generating (and billing) a second time. Image generation is slow and retry-prone, so this prevents double charges.