Bỏ qua để đến nội dung
Mở CastalyBảng điều khiển

Hình ảnh

gemini-3.1-flash-image API

Gọi gemini-3.1-flash-image thông qua Modelflare với ID mẫu chính xác được hiển thị trên trang này.

Sử dụng ID mẫu chính xác gemini-3.1-flash-image. Trường mô hình phải khớp chính xác với trang này.

Cắt hoa biến thành thủy tinh thổi trên kệ thép của phòng lạnh bán hoa.

Đầu ra mẫugemini-3.1-flash-imagePOST /v1beta/models/gemini-3.1-flash-image:generateContent

Thông số: size=2Kratio=16:9

Câu lệnh: The cold room of a flower shop, steel shelves and buckets of cut stems. A figure in an acid-green vinyl coat has just pulled one bucket toward the door. Along that whole shelf the flowers have begun turning to blown glass, petal by petal, the transformation running outward from the bucket like frost: stems still green at the base, heads already clear and ringing, throwing hard coloured caustics across the steel. One hard pink light through the open cooler door, cold blue shade behind. Wide low camera, macro-sharp on the glass edges, real weight, film grain, no text.

Yêu cầu tạo ra mẫu này
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "The cold room of a flower shop, steel shelves and buckets of cut stems. A figure in an acid-green vinyl coat has just pulled one bucket toward the door. Along that whole shelf the flowers have begun turning to blown glass, petal by petal, the transformation running outward from the bucket like frost: stems still green at the base, heads already clear and ringing, throwing hard coloured caustics across the steel. One hard pink light through the open cooler door, cold blue shade behind. Wide low camera, macro-sharp on the glass edges, real weight, film grain, no text."
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "2K"
}
}
}

Sử dụng khóa API Modelflare với https://modelflare.dev. Điểm vào cổng là POST /v1/models/{model}:generateContent.

HTTP
Authorization: Bearer YOUR_MODELFLARE_API_KEY
Terminal windowbash
curl "https://modelflare.dev/v1/models/gemini-3.1-flash-image:generateContent" \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "A white cat runs through a neon-lit street in the rain"}]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"], "imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"}}
}'

Mô hình hình ảnh Gemini sử dụng contents và generationConfig gốc; chỉnh sửa gửi hướng dẫn văn bản và inline_data trong cùng parts[].

Mô hình hình ảnh Gemini sử dụng Gemini bản địa generateContent. Đặt văn bản và hình ảnh tham chiếu trong cùng một contents[].parts[]; hình ảnh sử dụng inline_data. Không gửi các mô hình này tới /v1/images/generations, /v1/images/edits hoặc OpenAI /v1/responses. Enum imageSize dành riêng cho từng mô hình và được hiển thị bên dưới.

Cánh đồng Bắt buộc Ghi chú
contents[].parts[].text Có Lời nhắc văn bản hoặc hướng dẫn chỉnh sửa
contents[].parts[].inline_data Không Dữ liệu hình ảnh Base64 và loại MIME
contents[].parts[].inline_data.mime_type Không image/jpeg / image/png / image/webp
contents[].parts[].inline_data.data Không Nội dung hình ảnh tham chiếu được mã hóa Base64
generationConfig.responseModalities Có ["IMAGE"] hoặc ["TEXT", "IMAGE"]
generationConfig.imageConfig.aspectRatio Không 1:1 / 4:3 / 3:4 / 16:9 / 9:16
generationConfig.imageConfig.imageSize Không 512 / 1K / 2K / 4K

Hình ảnh Flash hỗ trợ 512, 1K, 2K và 4K với 1:1, 4:3, 3:4, 16:9 và 9:16. Tài liệu chính thức không công bố giới hạn số lượng hình ảnh tham chiếu, do đó cổng không thêm giới hạn cục bộ.

Đặt hướng dẫn chỉnh sửa và hình ảnh tham chiếu vào cùng một contents[].parts[]. inline_data.data là nội dung hình ảnh Base64; không gửi các mẫu hình ảnh Gemini tới các điểm cuối Hình ảnh OpenAI hoặc Responses.

Terminal windowbash
curl "https://modelflare.dev/v1/models/gemini-3.1-flash-image:generateContent" \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [
{"text": "Keep the subject and lighting, but replace the background with a misty pine forest."},
{"inline_data": {"mime_type": "image/jpeg", "data": "BASE64_IMAGE_DATA"}}
]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"], "imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"}}
}'

Đọc candidates[].content.parts[]; đừng cho rằng mọi phần đều là hình ảnh vì phản hồi có thể chứa các phần văn bản và hình ảnh cùng nhau.

Cánh đồng Ghi chú
candidates[].content.parts[].inline_data Đã tạo loại MIME hình ảnh và dữ liệu Base64
candidates[].content.parts[].text Chú thích văn bản được trả về khi TEXT được yêu cầu
candidates[].finishReason Lý do hoàn thành hoặc an toàn
usageMetadata Việc sử dụng mã thông báo đầu vào/đầu ra khi được dịch vụ trả về

Modelflare duy trì hình dạng phản hồi gốc của Gemini cho gemini-3.1-flash-image và duy trì các phần hình ảnh có thể sử dụng được.

Lỗi trường, giới hạn kích thước/tỷ lệ và từ chối an toàn từ yêu cầu Gemini gốc vẫn là phản hồi lỗi tương thích với Gemini. Cổng không viết lại chúng dưới dạng phản hồi Hình ảnh OpenAI.

Trang này bao gồm các cuộc gọi chỉnh sửa và tạo mô hình Modelflare. Tính năng làm giàu bản đồ hoặc tìm kiếm, quản lý giọng nói và quản lý thư viện thành phần là các API tài nguyên nằm ngoài bề mặt lệnh gọi mô hình công khai này và không phải là các trường yêu cầu bắt buộc.

Mô hình này sử dụng thanh toán dựa trên mã thông báo. Xem trang định giá mẫu để biết giá khách hàng hiện tại, giá niêm yết tham khảo và thông số kỹ thuật đầy đủ.

Hợp đồng truyền thông · v1

ID hợp đồng: media.gemini-3-1-flash-image.v1Bộ chuyển đổi: image.gemini.native.v1@v1Dấu vân tay: fb4adc579d570a2f8d4371edde0dc6bfa1042a004eb39641c63bd98fa4c7c8cc

Nguồn chính thức: Google

Thông số hợp đồng

Trường ý địnhĐiều khiểnTùy chọn
sizeselect512 / 1K / 2K / 4K
ratioselect1:1 / 4:3 / 3:4 / 16:9 / 9:16

Khả năng được hỗ trợ

  • allowed_values · size · 512, 1K, 2K, 4K
  • allowed_values · ratio · 1:1, 4:3, 3:4, 16:9, 9:16

Ví dụ về yêu cầu có cấu trúc

text

Ý định

{
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "ratio": "1:1",
  "size": "512"
}

Yêu cầu của nhà cung cấp

{
  "contents": [
    {
      "parts": [
        {
          "text": "A red paper kite over a quiet harbour at dusk."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "512"
    },
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ]
  },
  "systemInstruction": {
    "parts": [
      {
        "text": "Generate an image for the user's request. If details are missing, choose reasonable defaults and still return an image. Do not ask clarifying questions."
      }
    ]
  }
}

reference

Ý định

{
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "ratio": "1:1",
  "size": "512"
}

Yêu cầu của nhà cung cấp

{
  "contents": [
    {
      "parts": [
        {
          "text": "A red paper kite over a quiet harbour at dusk."
        },
        {
          "inline_data": {
            "data": "AAAA",
            "mime_type": "image/png"
          }
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "512"
    },
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ]
  },
  "systemInstruction": {
    "parts": [
      {
        "text": "Generate an image for the user's request. If details are missing, choose reasonable defaults and still return an image. Do not ask clarifying questions."
      }
    ]
  }
}