English
  • 中文
  • English
English
  • 中文
  • English
官网
服务状态
English
  • 中文
  • English
  1. Images
  • Quickstart & Conventions
  • Images
    • GPT Image 2 / 2.5 / 2.6 Generation & Editing
    • Nano Banana Image Generation
    • Gemini Native Sync Image Generation
    • Seedream 5.0 Pro / 5.5 Image Generation
    • Midjourney Image Generation
  • Videos
    • Seedance 2 Video Generation
    • Omni Video Generation
    • Seedance 2.5 Video Generation
    • MiniMax H3 Video Generation
    • WAN 3.0 Video Generation
    • Muse Video Generation
    • Seedance Asset Registration
    • Gemini Omni 1.2 Flash Video Generation
    • Seedance Volcengine Native Video Generation
    • MAGI-2 Video Generation
  • Text Models
    • Claude Desktop (CC Switch) Setup Guide
    • Codex in ChatGPT Desktop Setup Guide
    • Gemini Text Models (Native Format)
    • Text & Chat APIs (OpenAI / Claude)
  • Audio
    • Gemini Text-to-Speech (TTS)
  1. Images

Gemini Native Sync Image Generation

Generate images synchronously with gemini-3.1-flash-image, gemini-3.0-pro-image, or nano-banana-2.1 via the native Gemini generateContent endpoint. Requests block until image generation completes; clients extract the image directly from the synchronous response following the Client Extraction Order below—there is no async task ID and no polling.
Model availability depends on the live response of GET /v1/models for your API key. Do not submit generation requests for models that do not appear in that list.
None of the models on this page support OpenAI-compatible /v1/chat/completions. If you use an OpenAI-style client, gemini-3.1-flash-image and gemini-3.0-pro-image can be called via the async image endpoint described in Calling via the Async Image Endpoint below.

Endpoint & Authentication#

Replace {model} with a model ID available to your API key. Authenticate with your Brioi API key via Authorization: Bearer, the x-goog-api-key header, or the ?key= query parameter—the default x-goog-api-key header sent by official Gemini SDKs works directly.
List models visible to your API key:

Supported Models#

ModelPositioningimageSizeaspectRatio
gemini-3.1-flash-imageBalanced speed and quality1K, 2K, 4K (required)1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 16:9, 9:16, 21:9
gemini-3.0-pro-imageQuality-first1K, 2K, 4K (required)1:1, 2:3, 3:2, 3:4, 4:3, 16:9, 9:16, 21:9
nano-banana-2.1Balanced speed and quality1K, 2K, 4K (optional; defaults to 1K when omitted)1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 16:9, 9:16, 21:9
aspectRatio can be omitted to let the model choose its default composition. Because aspectRatio expresses a composition preference, always read the actual pixel dimensions of the returned image. nano-banana-2.1 only supports the generateContent endpoint on this page and does not support the async image endpoint.

Request Schema#

FieldTypeRequiredDescription
contentsarrayYesConversation turns; must include at least one non-empty item.
contents[].rolestringNoRecommended value for user prompts: user.
contents[].partsarrayYesText instructions and reference image parts.
parts[].textstringConditionalImage generation or editing instructions.
parts[].inlineDataobjectNoBase64 reference image containing mimeType and data.
parts[].fileDataobjectNoPublic URL reference image containing mimeType and fileUri.
generationConfig.responseModalitiesstring[]YesMust include IMAGE.
generationConfig.imageConfig.imageSizestringYes1K, 2K, or 4K (uppercase K required). Optional for nano-banana-2.1 (defaults to 1K when omitted).
generationConfig.imageConfig.aspectRatiostringNoAspect ratio supported by the target model.

Text-to-Image Example#

URL Reference Image Example#

fileUri must be a publicly accessible direct HTTPS image URL—not a web page, preview page, or URL requiring login or cookies. mimeType must match the actual MIME type of the remote file.

Base64 Reference Image Example#

Provide only the raw base64 payload in inlineData.data—do not include a data:image/...;base64, prefix.
{
  "contents": [{
    "role": "user",
    "parts": [
      {"text": "Preserve the product structure and material, and replace the background with a clean white photo studio"},
      {
        "inlineData": {
          "mimeType": "image/png",
          "data": "BASE64_IMAGE_DATA"
        }
      }
    ]
  }],
  "generationConfig": {
    "responseModalities": ["IMAGE"],
    "imageConfig": {
      "imageSize": "2K",
      "aspectRatio": "1:1"
    }
  }
}

Response & Image Extraction#

In a successful response, parts may contain both text and images. Standard Gemini image output is located at inlineData.data and should be decoded according to inlineData.mimeType; remote image outputs follow the unified extraction order below.
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "BASE64_IMAGE_DATA"
            }
          }
        ]
      },
      "finishReason": "STOP"
    }
  ]
}
In some cases, inlineData is omitted and the generated image is returned as a remote URL inside candidate.content.parts[] via one or both of the following forms:
1.
fileData.fileUri
2.
Markdown image syntax ![...](https://...) inside text
The same image may appear simultaneously as both fileData.fileUri and a Markdown image URL. Clients must deduplicate URLs rather than treating them as two separate images.

Remote Image Response Example#

{
  "candidates": [{
    "content": {
      "role": "model",
      "parts": [
        {
          "text": "![image](https://cdn.example/generated.png)"
        },
        {
          "fileData": {
            "mimeType": "image/png",
            "fileUri": "https://cdn.example/generated.png"
          }
        }
      ]
    },
    "finishReason": "STOP"
  }]
}

Client Extraction Order#

1.
Decode inlineData.data first if present.
2.
Otherwise, read fileData.fileUri.
3.
Otherwise, extract Markdown image URLs from parts[].text.
4.
Deduplicate URLs and verify that downloaded payloads are non-empty, decodable images.
Standard Gemini SDKs typically recognize only inlineData as image output. When handling compatible remote image outputs, callers must implement the extraction and download logic above.

Calling via the Async Image Endpoint#

gemini-3.0-pro-image and gemini-3.1-flash-image can also be invoked through the async image endpoints, suitable for clients built around OpenAI-style REST conventions:
Request fields, reference image limits, aspect ratios, and size tiers match nano-banana-pro and nano-banana-2, respectively—see Nano Banana Image Generation: pass reference images via image_urls, set size tier and ratio via image_size (1K, 2K, 4K) and aspect_ratio, and set n to 1 only. Allowed aspect_ratio values follow the Nano Banana specification: on the async endpoint, gemini-3.1-flash-image supports only 1:1, 16:9, 9:16, 4:3, 3:4, auto (fewer than on this native endpoint), whereas gemini-3.0-pro-image supports 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, auto. Billing follows the image_size tier at the same pricing as the native endpoint; omitting image_size generates and bills at 1K, and omitting aspect_ratio generates a 9:16 portrait image.
Neither model supports /v1/chat/completions, nor synchronous /v1/images/generations or /v1/images/edits—use the async image endpoint above or generateContent on this page.

Limits & Error Handling#

generationConfig.responseModalities must include IMAGE.
imageSize only accepts 1K, 2K, or 4K; lowercase k is not part of the public API contract.
aspectRatio must be an enum value supported by the target model (see Supported Models).
URL reference images must be directly downloadable over the public internet and return the matching image MIME type; short-lived signed URLs must remain valid for the entire synchronous generation cycle.
Base64 reference images must match their declared mimeType.
Synchronous requests block until generation completes. If a client times out, do not blindly retry—capture the X-Oneapi-Request-Id response header and error details first to avoid duplicate generations.
HTTP status codes: 400 invalid request parameters, 401 missing or invalid API key, 403 insufficient balance/quota or missing model permission, 429 rate limit exceeded, 503 service temporarily unavailable, 500 / 502 transient server error.
Modified at 2026-12-04 09:01:17
Previous
Nano Banana Image Generation
Next
Seedream 5.0 Pro / 5.5 Image Generation
Built with