Ir al contenido
Abre CastalyConsola

Imagen

gemini-3.1-flash-image API

Llame a gemini-3.1-flash-image a través de Modelflare con el ID de modelo exacto que se muestra en esta página.

Utilice el ID de modelo exacto gemini-3.1-flash-image. El campo del modelo debe coincidir exactamente con esta página.

Flores cortadas convirtiéndose en vidrio soplado en los estantes de acero de una cámara frigorífica de floristería.

Salida de muestragemini-3.1-flash-imagePOST /v1beta/models/gemini-3.1-flash-image:generateContent

Parámetros: size=2Kratio=16:9

Prompt: 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.

Solicitud que produjo esta muestra
{
"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"
}
}
}

Utilice una clave API de Modelflare con https://modelflare.dev. El punto de entrada de la puerta de enlace es POST /v1/models/{model}:generateContent.

HTTP
Authorization: Bearer YOUR_MODELFLARE_API_KEY
Ventana de terminalbash
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"}}
}'

Los modelos de imagen Gemini utilizan contents y generationConfig nativos; las ediciones envían la instrucción de texto y inline_data en el mismo parts[].

Los modelos de imagen Gemini utilizan Gemini nativo generateContent. Poner texto e imágenes de referencia en el mismo contents[].parts[]; las imágenes utilizan inline_data. No envíe estos modelos a /v1/images/generations, /v1/images/edits u OpenAI /v1/responses. La enumeración imageSize es específica del modelo y se muestra a continuación.

Campo Requerido Notas
contents[].parts[].text Sí Mensaje de texto o instrucción de edición
contents[].parts[].inline_data No Datos de imagen Base64 y tipo MIME
contents[].parts[].inline_data.mime_type No image/jpeg / image/png / image/webp
contents[].parts[].inline_data.data No Contenido de imagen de referencia codificada en Base64
generationConfig.responseModalities Sí ["IMAGE"] o ["TEXT", "IMAGE"]
generationConfig.imageConfig.aspectRatio No 1:1 / 4:3 / 3:4 / 16:9 / 9:16
generationConfig.imageConfig.imageSize No 512 / 1K / 2K / 4K

La imagen Flash admite 512, 1K, 2K y 4K con 1:1, 4:3, 3:4, 16:9 y 9:16. La documentación oficial no publica un límite de recuento de imágenes de referencia, por lo que la puerta de enlace no agrega ningún límite local.

Coloque la instrucción de edición y la imagen de referencia en el mismo contents[].parts[]. inline_data.data es el contenido de la imagen Base64; no envíe modelos de imágenes Gemini a las imágenes OpenAI o a los puntos finales Responses.

Ventana de terminalbash
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"}}
}'

Leer candidates[].content.parts[]; No asuma que cada parte es una imagen porque la respuesta puede contener partes de texto e imagen juntas.

Campo Notas
candidates[].content.parts[].inline_data Imagen generada tipo MIME y datos Base64
candidates[].content.parts[].text Título de texto devuelto cuando se solicitó TEXTO
candidates[].finishReason Razón de finalización o seguridad
usageMetadata Uso del token de entrada/salida cuando lo devuelve el servicio

Modelflare conserva la forma de respuesta nativa de Gemini para gemini-3.1-flash-image y conserva las partes de la imagen utilizables.

Los errores de campo, los límites de tamaño/proporción y los rechazos de seguridad de la solicitud nativa de Gemini siguen siendo respuestas de error compatibles con Gemini. La puerta de enlace no las reescribe como respuestas de OpenAI Images.

Esta página cubre las llamadas de generación y edición de modelos de Modelflare. El enriquecimiento de mapas o búsquedas, la administración de voz y la administración de bibliotecas de elementos son API de recursos fuera de esta superficie pública de llamada de modelo y no son campos de solicitud obligatorios.

Este modelo utiliza facturación basada en tokens. Consulte la página de precios de modelos para conocer el precio actual para el cliente, el precio de lista de referencia y las especificaciones completas.

Contrato de medios · v1

ID de contrato: media.gemini-3-1-flash-image.v1Adaptador: image.gemini.native.v1@v1Huella digital: fb4adc579d570a2f8d4371edde0dc6bfa1042a004eb39641c63bd98fa4c7c8cc

Fuente oficial: Google

Parámetros del contrato

Campo de intenciónControlOpciones
sizeselect512 / 1K / 2K / 4K
ratioselect1:1 / 4:3 / 3:4 / 16:9 / 9:16

Capacidad admitida

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

Ejemplo de solicitud estructurada

text

Intención

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

Solicitud de proveedor

{
  "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

Intención

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

Solicitud de proveedor

{
  "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."
      }
    ]
  }
}