Amux AI

Generate image

Last updated September 2, 2026

Generate images with google/gemini-2.5-flash-image on Gemini's native endpoint, usable with the official SDKs.

Image generation with google/gemini-2.5-flash-image. It uses Gemini's native generateContent at the same address as a chat call, so the official SDKs work once their base URL points here.

Google marks it as the previous generation. For new work prefer 3.1 Flash Image — same Flash tier, wider range, and a lower price per image.

POSThttps://gateway.amux.ai/v1beta/models/google/gemini-2.5-flash-image:generateContent

Authorization

header
AuthorizationstringRequired

Request

application/json
contentsarray<object>Required

Prompt and reference images. Text in parts[].text, reference images in parts[].inline_data (raw base64, no data: prefix). Reference images make it image-to-image; the endpoint does not change.

›contentsarray<object>
role"user" | "model"

Who is speaking. user is you, model is the model's own earlier reply. Optional for a single-turn request.

partsarray<object>

The pieces of this turn, in the order given. Text and reference images may be mixed in one turn.

›partsarray<object>
textstring

A text piece. Several text pieces in one turn are concatenated in order.

inline_dataobject

An inline reference image. Only inline bytes and the Files API are accepted, not URLs — a URL is dropped and noted in amux.notes.

›inline_dataobject
mime_typestring

Media type of the image, e.g. image/png, image/jpeg, image/webp.

datastring

The image bytes as base64, without the data:image/png;base64, prefix. With the prefix the upstream reads it as an invalid image.

generationConfigobjectRequired

Generation settings. The fields relevant to image output are responseModalities and the size controls. The size controls accept two equivalent forms, imageConfig and responseFormat.image. Google's documentation has used each of them in different versions; Amux supports both. When both are supplied, imageConfig takes precedence, field by field.

›generationConfigobject
responseModalitiesarray<"TEXT" | "IMAGE">Required

Required: ["TEXT", "IMAGE"]. Without it this endpoint returns text only.

responseFormatobject

Output format. Image settings live under image.

›responseFormatobject
imageobject

Size controls for the image. Both may be omitted, in which case the upstream picks its default.

›imageobject
aspectRatio"1:1" | "1:4" | "1:8" | "2:3" | "3:2" | "3:4" | "4:1" | "4:3" | "4:5" | "5:4" | "8:1" | "9:16" | "16:9" | "21:9"

Aspect ratio. This model accepts the 14 values below. An out-of-range value is dropped and noted in amux.notes, and the model falls back to its default; this endpoint, /v1/images/* and /v1/tasks all behave the same.

imageSize"1K"

Resolution tier. Out-of-range values are handled the same way as aspectRatio.

toolsarray<object>

This model does not support grounding. Passing it is rejected upstream (400).

Response

200response

The result. Images and text are interleaved in parts.

Turning image output on

generationConfig.responseModalities must be ["TEXT", "IMAGE"]. Without it the same endpoint returns text only.

What this model accepts

Aspect ratios (14):

1:1 · 2:3 / 3:2 · 3:4 / 4:3 · 4:5 / 5:4 · 9:16 / 16:9 · 21:9 · 1:4 / 4:1 · 1:8 / 8:1

Resolutions: 1K

A value outside those sets is dropped and noted in amux.notes, after which the model falls back to its own default. This native endpoint shares one image pipeline with the OpenAI-compatible image endpoint and Amux Tasks, so all three behave the same.

An OpenAI-style pixel string in size (for example 1024x1024) is folded into an aspect ratio and a tier, constrained to the sets above, and a lossy fold is noted in amux.notes. Gemini's native body has no such field — on a native call, write the aspect ratio and the tier directly.

Reference images

Image-to-image and text-to-image share this endpoint: put the reference into contents[].parts as an inline_data block. data is raw base64 without the data: prefix.

This model has no documented limit.

Supplying a reference by URL is not supported — the upstream accepts inline bytes and the Files API only.

What drives the cost

How output is billed depends on the provider: for the same model, some providers charge per token and others per image. The provider's price list on the model page is authoritative. All three call paths — this endpoint, /v1/images/* and /v1/tasks — share one image pipeline, so a given provider bills the same on all of them.

When billing is per token, image tokens and text tokens are priced differently. The two are reported separately in usageMetadata.candidatesTokensDetails, and Amux bills them as separate line items rather than charging image tokens at the text rate.

How many tokens one image costs depends on the resolution: 1290 tokens at 1K and below.

For the rates themselves see the model page and pay-as-you-go pricing. They are deliberately not repeated here — providers and discounts change, and a copy in the docs would drift away from the invoice.

Grounding is not supported

This model does not accept tools: [{ "google_search": {} }]; passing it is rejected upstream (400). To generate from current facts, use Gemini 3 Pro Image or Gemini 3.1 Flash Image instead.

Streaming is not supported

Gemini streams by switching the action (:streamGenerateContent), and the official documentation gives no syntax for streaming images, so streaming requests to this model are rejected. Retry without streaming.

One call returns one image; the request body has no batch field.

Other ways to call this model

The model is also reachable through the OpenAI-compatible image endpoint and Amux Tasks. The ranges listed on this page apply on those converted paths too.

Errors

Errors use Gemini's error body. See Errors and retries for status values and retry semantics.

cURL
curl https://gateway.amux.ai/v1beta/models/google/gemini-2.5-flash-image:generateContent \
  -H "x-goog-api-key: $AMUX_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "<string>",
            "inline_data": {
              "mime_type": "image/png",
              "data": "<string>"
            }
          }
        ]
      }
    ],
    "generationConfig": {
      "responseModalities": [
        "TEXT",
        "IMAGE"
      ],
      "responseFormat": {
        "image": {
          "aspectRatio": "1:1",
          "imageSize": "1K"
        }
      }
    },
    "tools": [
      {}
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "<string>",
            "inlineData": {
              "mimeType": "image/png",
              "data": "<string>"
            }
          }
        ]
      }
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 0,
    "candidatesTokenCount": 0,
    "totalTokenCount": 0,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 0
      }
    ],
    "candidatesTokensDetails": [
      {
        "modality": "IMAGE",
        "tokenCount": 0
      }
    ]
  }
}