gemini-2.5-flash-image-preview
Google Gemini 2.5 Flash image preview — async text-to-image and image-to-image. Fast, cost-efficient variant; up to 14 reference images at 1K resolution.
Async image generation tuned for speed. One endpoint covers text-to-image and image-to-image with up to 14 reference images. Two channels share the same parameter shape:
gemini-2.5-flash-image-preview— default channel.gemini-2.5-flash-image-preview-official— Google's official endpoint.
- Async processing —
POSTreturns atask_id, pollGET /api/v1/tasks/{id}for the result. - OpenAI-compatible
/api/v1/images/generationsenvelope (text-to-image / image-to-image). - 10 ratios via
size; only 1K resolution on this model. - Up to 14 reference images via
image_urls— public HTTP(S) URLs only. - Up to 4 images per request via
n. - Failed / moderated requests are not charged.
Quick example
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"prompt": "moonlight on a bamboo path, ink wash painting",
"size": "16:9"
}'import requests
resp = requests.post(
"https://reapi.ai/api/v1/images/generations",
headers={
"Authorization": "Bearer rk_live_xxx",
"Content-Type": "application/json",
},
json={
"model": "gemini-2.5-flash-image-preview",
"prompt": "moonlight on a bamboo path, ink wash painting",
"size": "16:9",
},
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: "gemini-2.5-flash-image-preview",
prompt: "moonlight on a bamboo path, ink wash painting",
size: "16:9",
}),
});
console.log(await r.json());package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "gemini-2.5-flash-image-preview",
"prompt": "moonlight on a bamboo path, ink wash painting",
"size": "16:9",
})
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": "gemini-2.5-flash-image-preview",
"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 resultAsync — 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_xxxBody
model
string · required
One of:
"gemini-2.5-flash-image-preview"— default channel."gemini-2.5-flash-image-preview-official"— Google's official endpoint.
prompt
string · required
1 – 1000 characters. English and Chinese both supported. Don't
restate the ratio in the prompt — pass it via size.
Image-to-image is no exception — the prompt describes what to do with
the reference. Sending image_urls without a prompt returns 400.
size
string · default "1:1" (text-to-image) / inherited (image-to-image)
Output ratio. One of these 10 values:
1:1 2:3 3:2 3:4 4:3
4:5 5:4 9:16 16:9 21:9Anything 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"
Only 1K is supported on this model. Sending 2K / 4K returns
400. Switch to
gemini-3-pro-image-preview or
gemini-3.1-flash-image-preview
when you need higher resolutions.
n
integer · default 1
1 – 4 images per request. Must be a number, not a string.
image_urls
string[] · optional
Reference images for image-to-image. Up to 14 entries. Each entry
must be a public HTTP(S) URL — data: / base64 payloads are rejected
at the gateway. Upload to your own object storage (S3 / R2 / OSS) and
pass the URL.
Use cases
1. Text-to-image (minimal)
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"prompt": "moonlight on a bamboo path, ink wash painting"
}'2. Text-to-image, widescreen
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"prompt": "a corgi astronaut on the moon, cinematic",
"size": "16:9"
}'3. Multiple variations in one call
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"prompt": "vintage botanical illustration, hibiscus",
"size": "4:5",
"n": 4
}'4. Image-to-image (single reference)
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"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": "gemini-2.5-flash-image-preview",
"prompt": "blend these two photos into a poster",
"size": "4:3",
"image_urls": [
"https://your-cdn.com/photo-a.jpg",
"https://your-cdn.com/photo-b.jpg"
]
}'6. Force the official channel
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer rk_live_xxx" \
-d '{
"model": "gemini-2.5-flash-image-preview-official",
"prompt": "studio portrait of a tabby cat, soft light",
"size": "1:1"
}'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": "gemini-2.5-flash-image-preview",
"status": "processing",
"created_at": 1735000000
}{
"id": "task_018f5a3a1b6e7d9f8c2b4d6e8f0a2c4e",
"model": "gemini-2.5-flash-image-preview",
"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": "gemini-2.5-flash-image-preview: only resolution=1K is supported",
"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 code | Meaning | Origin |
|---|---|---|
80001 | provider_submit_failed | Upstream 5xx / network on submit |
80002 | provider_polling_timeout | Wall-clock cap reached while polling |
80003 | provider_failed | Upstream returned a terminal failure |
See Errors catalog for the full code list.
Polling
status | Meaning |
|---|---|
processing | Submitted, still generating |
completed | output.image_urls is ready |
failed | See error.code; not charged |
Recommended cadence:
0–10s: wait before the first poll
10s–60s: poll every 2–3s
60s+: back off to 5s; cap at 15sA 1K image typically completes in 5 – 20 seconds.
Related
gemini-3-pro-image-preview— higher-quality variant with 1K / 2K / 4K resolutions.gemini-3.1-flash-image-preview— newer variant with extreme ratios and Google search grounding.- Errors catalog
- Authentication
- Quickstart
- Pricing — gemini-2.5-flash-image-preview
reAPI Docs