Skip to content

AI Image Generate

AI Image Generate API

Image generation is asynchronous:

  1. POST /v1/images/generations → returns an id; credits are held, not charged
  2. Wait (typically 30–60 seconds)
  3. GET /v1/images/jobs/{id} until status is completed or failed
  4. completed → links in data[].url. failed → credits are refunded automatically

Base URL and authentication

https://revidapi.com/v1
Authorization: Bearer sk_...

X-API-Key: sk_... works too. Get a key at revidapi.com/dashboard.


Models

curl https://revidapi.com/v1/models \
  -H "Authorization: Bearer sk_..."

Filter for entries with "kind": "image". Currently sold:

Model Notes
gpt-image-2 Cheapest
gpt-image-2-super, gpt-image-2-4k Same model, larger size tiers
grok-imagine-image, grok-imagine-image-quality Grok Imagine
nano-banana, nano-banana-pro Nano Banana
seedream-4.5, seedream-5-lite, seedream-5-pro Seedream
flux-2-pro Flux 2 Pro
gemini-3-pro-image, gemini-3.1-flash-image Gemini Image
imagen-4-ultra Imagen 4 Ultra

1) Create an image job

  • Method: POST
  • URL: https://revidapi.com/v1/images/generations
  • Content-Type: application/json
Name Type Required Description
model string Yes From GET /v1/models
prompt string Yes What the image should show
aspect_ratio string No 1:1, 4:3, 16:9, 9:16
size string Model-dependent Size tier 1k/2k/3k/4k for Nano Banana, Seedream, Flux, Kling Image — required; omitting it returns 400 listing the tiers. GPT Image / Grok Imagine take WIDTHxHEIGHT, e.g. 2048x2048
reference_images array No Image-to-image references. img_url / image_urls also accepted
output_format string No png, jpeg, webp
transparent_output bool No Transparent background, where the model supports it

n is not supported: the upstream returns exactly one image per billed call, so the gateway does not accept it.

Two response shapes

There are two families of image models, differing in how they return:

  • Immediate (Nano Banana, Seedream, Flux, Kling Image): the response already has data[].url, no polling.
  • Job-based (GPT Image, Grok Imagine): the response has id + poll; call GET /v1/images/jobs/{id}.

Write the client to handle both: if data is present use it, otherwise take id and poll.

Curl

curl -X POST https://revidapi.com/v1/images/generations \
  -H "Authorization: Bearer sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a red apple on a wooden table, product photo",
    "aspect_ratio": "1:1"
  }'

Image to image

import requests

r = requests.post(
    "https://revidapi.com/v1/images/generations",
    headers={"Authorization": "Bearer sk_..."},
    json={
        "model": "nano-banana-pro",
        "prompt": "replace the background with a dark studio",
        "reference_images": ["https://example.com/product.jpg"],
        "aspect_ratio": "16:9",
    },
)
print(r.json())

Response

{
  "id": "img_xCOC2TseCCwDpyR-eqM7evGT",
  "object": "image.job",
  "status": "queued",
  "model": "gpt-image-2",
  "poll": "/v1/images/jobs/img_xCOC2TseCCwDpyR-eqM7evGT",
  "credits_reserved": 16
}

2) Poll the job

  • Method: GET
  • URL: https://revidapi.com/v1/images/jobs/{id}
curl https://revidapi.com/v1/images/jobs/img_xCOC2TseCCwDpyR-eqM7evGT \
  -H "Authorization: Bearer sk_..."

Done:

{
  "id": "img_...",
  "object": "image.job",
  "status": "completed",
  "model": "gpt-image-2",
  "waited": 45.1,
  "data": [{ "url": "https://edit.revidapi.com/media/anh/....png" }],
  "usage": { "credits_charged": 16, "credits_remaining": 352264, "seconds": 33.1 }
}

On failure status is failed and credits are already refunded.


Error codes

Code Meaning What to do
400 Missing model/prompt, or bad aspect_ratio/size Read message
401 Wrong or missing key Check the Authorization header
402 Not enough credits Top up at revidapi.com/dashboard/usage
404 That model is not sold See GET /v1/models
429 Too many concurrent images for your plan Wait for running jobs to finish