Developer docs/gemini-3.1-flash-image-preview

Gemini 3.1 Flash Image · 1K/2K

gemini-3.1-flash-image-preview

Gemini 3.1 Flash Image (1K) generates images quickly for product mockups, thumbnails, and creative drafts.

Overview

Official $0.0735
LumeAPI $0.05
POST /v1/chat/completions
Base: https://api.lumeapi.site/v1

Auth: Authorization: Bearer sk-… from the Console. Use this model id exactly in the model field.

Request parameters — Gemini / Nano Banana image via chat

Only parameters relevant to gemini-3.1-flash-image-preview are listed below.

FieldTypeReqDescription
modelstringgemini-3.1-flash-image-preview | …-2k | google/gemini-3-pro-image-preview
messagesarrayOpenAI multimodal messages. Text + optional image_url parts for edit/style reference.
messages[].content[]object[][{type:"text",text:"…"},{type:"image_url",image_url:{url:"https://…"}}] — attach 1+ reference images
image_config.image_sizestring2K tier: use *-2k model ids

Examples

bash
curl https://api.lumeapi.site/v1/chat/completions \
  -H "Authorization: Bearer sk-…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.1-flash-image-preview",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "Keep the bottle layout; change background to sunset beach"},
        {"type": "image_url", "image_url": {"url": "https://cdn.example.com/ref.png"}}
      ]
    }]
  }'

Image integration notes

1. Base URL & auth

POST https://api.lumeapi.site/v1/images/generations or /v1/chat/completions with Authorization: Bearer sk-…. Obtain keys at the LumeAPI Console (/console). Catalog: GET /api/models on the LumeAPI portal API.

2. Model ids (exact match)

images/generations: gpt-image-2, gpt-image-2-2k, doubao-seedream-5.0, grok-4-image, grok-4.2-image. images/edits: grok-4-image, grok-4.2-image (multipart). chat/completions for Gemini Flash / Nano Banana: gemini-3.1-flash-image-preview, gemini-3.1-flash-image-preview-2k, google/gemini-3-pro-image-preview.

3. GPT Image 2 & Grok Image

One POST returns sync OpenAI { data: [{ url }] } after the gateway finishes (typically 30–90s). Do NOT poll /v1/tasks yourself. size = aspect ratio (16:9); 2K → model gpt-image-2-2k. With image_urls: pass reference images (gateway enforces max). Grok: aspect_ratio or size; resolution 1k|2k; quality low|medium|high; n 1–10. For Grok edits use POST /v1/images/edits with one image file. HTTP read timeout ≥ 180s.

4. Seedream & Gemini Flash

doubao-seedream-5.0: POST /v1/images/generations with aspect ratio size + resolution 2K (default). Sync { data: [{ url }] } after 30–90s. gemini-3.1-flash-image-preview*: POST /v1/chat/completions with modalities + image_config.

5. Billing & errors

Flat USD per image (see pricing tables). 402 insufficient_user_quota when balance empty. Failed generations return 4xx/5xx with error message.

6. If you still get task_id in ~0.3s

Contact support — success should be { data: [{ url }] } after 30–90s. Your request format is likely correct.

Errors

  • 401 — invalid or missing Bearer key
  • 402 — insufficient wallet balance (top up in Account)
  • 403 — model id not on the whitelist / wrong id spelling
  • 429 — rate limited; back off and retry
  • 502 — temporary gateway error; retry