rreAPI Docs
rreAPI Docs
HomeWelcome

Image

midjourney-v8flux-2z-imageqwen-image-2midjourney-v7wan-2-7-imagegpt-image-2gpt-image-2-officialgemini-2.5-flash-image-previewgemini-3-pro-image-previewgemini-3.1-flash-image-previewdoubao-seedream-5-0-liteimagen-4-0

Audio

Mureka V9 Song APIVocal Remover APIMusic Extractor APIVoice Cleaner APIMultistem Splitter APIVoice Changer API

Video

topaz-video-upscalerkling-3-0-turbokling-3-0music-video-1-0wan-2-7-videokling-motion-controlpixverse-v6Seedance 2.5doubao-seedance-2.0doubao-seedance-2.0-officialseedance-2-0-minihappyhorse-1-1happyhorse-1.0happyhorse-1.0-officialviduq3grok-imagine-video-1.5-betagrok-imagine-1.0-videoVeo 3.1gemini-omni

Chat

claude-fable-5minimax-m3deepseek-v4gpt-5.5gpt-5.4claude-opus-4-8claude-opus-4-7claude-sonnet-4-6

Text

ai-essay-writerhumanizeai-text-detector

Tools

enhance-video-1.0
X (Twitter)

gpt-image-2

GPT Image 2 — async text-to-image / image-to-image. Cheapest variant in the family with flat per-resolution pricing.

Async image generation through reAPI's cheap channel. One endpoint covers text-to-image and image-to-image. Flat per-resolution pricing — the cheapest variant in the family. For batches, masks, quality tiers, or transparent backgrounds, switch to gpt-image-2 stable.

  • Async processing — POST returns a task_id, poll GET /api/v1/tasks/{id} for the result.
  • OpenAI-compatible /api/v1/images/generations envelope (text-to-image / image-to-image).
  • 14 ratios via size; three resolution tiers (1k / 2k / 4k) via resolution.
  • Up to 16 reference images via image_urls — public HTTP(S) URLs only.
  • Single image per request — n is fixed at 1.
  • Flat per-resolution price; failed / moderated requests are not charged.

Try it

Request
Paste an API key and submit a real generation request. Add one or more reference image URLs to switch into image-to-image mode.

Stored in browser localStorage on this device.

HTTP(S) URLs only — base64 / data: URLs are rejected. Leave empty for text-to-image.

Advanced parameters

Requires at least one entry in reference images above.

Setting any of quality, background, moderation, output_compression, mask_url, or n > 1 routes the request to the official channel.

Show raw request
POST /api/v1/images/generations
Authorization: Bearer <your-api-key>
Content-Type: application/json

{
  "model": "gpt-image-2",
  "prompt": "a cute red panda eating bamboo",
  "size": "1:1"
}
Response
Live updates from the API + polling.

Submit a request to see results here.


Quick example

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a ginger cat on a windowsill at sunset, watercolor",
    "size": "16:9",
    "resolution": "2k"
  }'
import requests

resp = requests.post(
    "https://reapi.ai/api/v1/images/generations",
    headers={
        "Authorization": "Bearer rk_live_xxx",
        "Content-Type": "application/json",
    },
    json={
        "model": "gpt-image-2",
        "prompt": "a ginger cat on a windowsill at sunset, watercolor",
        "size": "16:9",
        "resolution": "2k",
    },
    timeout=30,
)
print(resp.json())
const r = await fetch("https://reapi.ai/api/v1/images/generations", {
  method: "POST",
  headers: {
    Authorization: "Bearer rk_live_xxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-image-2",
    prompt: "a ginger cat on a windowsill at sunset, watercolor",
    size: "16:9",
    resolution: "2k",
  }),
});
console.log(await r.json());
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]any{
        "model":      "gpt-image-2",
        "prompt":     "a ginger cat on a windowsill at sunset, watercolor",
        "size":       "16:9",
        "resolution": "2k",
    })
    req, _ := http.NewRequest("POST",
        "https://reapi.ai/api/v1/images/generations", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer rk_live_xxx")
    req.Header.Set("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    out, _ := io.ReadAll(resp.Body)
    fmt.Println(string(out))
}

Submit response

{
  "id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
  "model": "gpt-image-2",
  "status": "processing",
  "created_at": 1735000000
}

Hold onto id and poll GET /api/v1/tasks/{id} until completion.


Endpoint

POST /api/v1/images/generations    # submit a job
GET  /api/v1/tasks/{id}            # poll for the result

Async — submit returns a task_id immediately; the actual image arrives via the polling endpoint. Polling is free.


Authentication

Bearer token, minted at reapi.ai/settings/apikeys.

Authorization: Bearer rk_live_xxx

Body

model

string · required · default "gpt-image-2"

Must be "gpt-image-2".

prompt

string · required

1 – 4000 characters. English and Chinese both supported. Detailed prompts produce better results. Every prompt goes through pre-submission moderation; rejected prompts return 400 at no charge.

Don't restate the ratio in the prompt — pass it via size. Repeating it in the prompt confuses the upstream.

size

string · default "1:1" (text-to-image) / inherited (image-to-image)

Output ratio. One of these 14 values:

auto
1:1   16:9   9:16   4:3   3:4
3:2   2:3    5:4    4:5
2:1   1:2    21:9   9:21

auto lets the upstream pick from the prompt or first reference image. Pixel strings (e.g. 1024x1024) are not accepted — combine size with resolution to control output pixels. Anything outside the list is rejected with 400.

When image_urls is provided without size, the output inherits the first reference image's resolution (image-to-image mode). Pass size to force a specific ratio.

resolution

string · default "1k"

1k / 2k / 4k. Case-insensitive — "2K" and "2k" are equivalent.

4k is only valid with the six widescreen sizes below. Other sizes — including auto — exceed the model's total-pixel cap and are rejected with 400.

size1k2k4k
1:11024×10242048×2048❌
3:2 / 2:31536×10242048×1360❌
4:3 / 3:41024×7682048×1536❌
5:4 / 4:51280×10242560×2048❌
16:9 / 9:161536×8642048×11523840×2160
2:1 / 1:22048×10242688×13443840×1920
21:9 / 9:212016×8642688×11523840×1648
autoserver picksserver picks❌

n

integer · default 1 · must be 1

Single image per request. This variant produces one image per call; sending any other value returns 400. For batches up to 4, use gpt-image-2 stable.

image_urls

string[] · optional

Reference images for image-to-image. Up to 16 entries. Each entry must be a public HTTP(S) URL — data: / base64 payloads are rejected. Upload to your own object storage (S3 / R2 / OSS) and pass the URL.

No batch / quality / mask on this variant. Sending n > 1, quality, mask_url, background, moderation, output_format, or output_compression against gpt-image-2 returns 400. Switch to gpt-image-2 stable — set "model": "gpt-image-2-official" — when you need those features.


Use cases

1. Text-to-image (minimal)

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a ginger cat on a windowsill at sunset, watercolor"
  }'

2. Text-to-image at 2K widescreen

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a corgi astronaut on the moon, cinematic",
    "size": "16:9",
    "resolution": "2k"
  }'

3. Text-to-image at 4K

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "ancient castle beneath a starry sky",
    "size": "16:9",
    "resolution": "4k"
  }'

4. Image-to-image (single reference)

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "turn this photo into a watercolor painting",
    "image_urls": ["https://your-cdn.com/photo.jpg"]
  }'

5. Multi-reference fusion

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "blend these two photos into a poster",
    "size": "4:3",
    "resolution": "2k",
    "image_urls": [
      "https://your-cdn.com/photo-a.jpg",
      "https://your-cdn.com/photo-b.jpg"
    ]
  }'

6. Force a ratio for image-to-image

When the reference is portrait but you need a landscape output:

curl https://reapi.ai/api/v1/images/generations \
  -H "Authorization: Bearer rk_live_xxx" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "extend the scene horizontally into a moonlit forest",
    "size": "21:9",
    "resolution": "2k",
    "image_urls": ["https://your-cdn.com/portrait.jpg"]
  }'

Response

POST returns immediately with status: "processing"; poll GET /api/v1/tasks/{id} until status is completed or failed. Both responses share the same envelope — the output field is null until the task finishes.

{
  "id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
  "model": "gpt-image-2",
  "status": "processing",
  "created_at": 1735000000
}
{
  "id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
  "model": "gpt-image-2",
  "status": "completed",
  "created_at": 1735000000,
  "output": {
    "image_urls": [
      "https://cdn.reapi.ai/media/tasks/018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e/0.png"
    ]
  },
  "error": null
}

URLs are stable for 7 days. Download to your own storage if you need them longer.

{
  "error": {
    "code": 20003,
    "message": "gpt-image-2: field 'quality' is only supported on gpt-image-2-official",
    "request_id": "req_8a4f0d2e-1c8b-4f1a-9e2d-3b7c5a6f0a1b"
  }
}
{
  "error": {
    "code": 10003,
    "message": "API key invalid",
    "request_id": "req_8a4f0d2e-1c8b-4f1a-9e2d-3b7c5a6f0a1b"
  }
}
{
  "error": {
    "code": 30001,
    "message": "Insufficient credits",
    "request_id": "req_8a4f0d2e-1c8b-4f1a-9e2d-3b7c5a6f0a1b"
  }
}
{
  "error": {
    "code": 50001,
    "message": "Rate limit exceeded",
    "request_id": "req_8a4f0d2e-1c8b-4f1a-9e2d-3b7c5a6f0a1b"
  }
}
{
  "error": {
    "code": 60099,
    "message": "Internal error — please retry",
    "request_id": "req_8a4f0d2e-1c8b-4f1a-9e2d-3b7c5a6f0a1b"
  }
}

Upstream errors (502 / 503)

reAPI does not surface raw upstream 5xx codes to the caller. When the upstream provider returns 502 Bad Gateway, 503 Service Unavailable, or a connection failure, the worker retries up to 5 attempts with exponential backoff (~30s total budget). If all retries fail, the task ends with one of these reapi-specific error codes (returned via GET /api/v1/tasks/{id} as error.code):

reapi codeMeaningOrigin
80001provider_submit_failedUpstream 5xx / network on submit
80002provider_polling_timeoutWall-clock cap reached while polling
80003provider_failedUpstream returned a terminal failure

See Errors catalog for the full code list.


Polling

statusMeaning
processingSubmitted, still generating
completedoutput.image_urls is ready
failedSee error.message; not charged

Recommended cadence:

0–30s:  wait before the first poll
30s–3m: poll every 3–5s
3m+:    back off to 10s; cap at 30s

A 1K image typically completes in 30–60s; 2K adds ~30s; 4K can take 90–120s.


Differences from the stable channel

Featuregpt-image-2 (this page)gpt-image-2 stable
Endpoint/api/v1/images/generations/api/v1/images/generations
size enum (14)✅✅
Resolution tiers (1k / 2k / 4k)✅✅
Image-to-image (image_urls)✅✅
Pricingflat per resolutionvaries by parameters — see model page
Batch (n > 1)❌✅ up to 4
Quality tiers❌✅ auto / low / medium / high
Mask inpainting (mask_url)❌✅
Background control❌✅ (transparent is silently downgraded by upstream)
Output format / compression❌ (always PNG)✅ png / jpeg / webp + compression
Moderation knob❌ (default)✅ auto / low

Related

  • gpt-image-2 stable — full feature surface (batch, mask, quality tiers).
  • Errors catalog
  • Authentication
  • Quickstart
  • Pricing — gpt-image-2

Table of Contents

Try it
Quick example
Submit response
Endpoint
Authentication
Body
model
prompt
size
resolution
n
image_urls
Use cases
1. Text-to-image (minimal)
2. Text-to-image at 2K widescreen
3. Text-to-image at 4K
4. Image-to-image (single reference)
5. Multi-reference fusion
6. Force a ratio for image-to-image
Response
Upstream errors (502 / 503)
Polling
Differences from the stable channel
Related