---
title: "Gemini Image Generation"
method: POST
path: "/v1beta/models/{model}:generateContent"
---

# Gemini Image Generation

`POST /v1beta/models/{model}:generateContent`

## Path parameters

- `model` string, required

## Request body

- object
  - `contents` object[], required — Conversation turns. Each item has a `role` ("user" or "model") and `parts` array containing text and/or image data.
    - `role` 'user' | 'model' — Role of the message sender.
    - `parts` object[] — Content blocks — text prompts and/or inline image data.
      - `text` string — Text content (prompt or instruction).
      - `inline_data` object — Inline image data for image-to-image or multi-image input.
        - `mime_type` 'image/jpeg' | 'image/png' | 'image/webp' — MIME type of the image.
        - `data` string — Raw Base64-encoded image data. Do not include the `data:image/...;base64,` prefix.
  - `generationConfig` object — Controls generation behavior — output modalities, image resolution, thinking, etc.
    - `responseModalities` string[] — Output types to return. Use `["TEXT", "IMAGE"]` for mixed output, or `["IMAGE"]` to force image-only output.
    - `imageConfig` object — Image output configuration.
      - `aspectRatio` string — All models: `1:1` `2:3` `3:2` `3:4` `4:3` `4:5` `5:4` `9:16` `16:9` `21:9`. Gemini 3.1 Flash also supports `1:4` `4:1` `1:8` `8:1`.
      - `imageSize` '512px' | '1K' | '2K' | '4K' — Output resolution. Gemini 3 models only — `gemini-2.5-flash-image` always outputs 1024px. Use uppercase K.
    - `thinkingConfig` object — Controls the Thinking process (Gemini 3 models). Thinking generates interim images before the final output.
      - `thinkingLevel` 'minimal' | 'high' — Thinking effort level. Only configurable for `gemini-3.1-flash-image-preview`; `gemini-3-pro-image-preview` always uses high thinking.
      - `includeThoughts` boolean — Whether to include thought parts in the response.
  - `tools` object[] — Optional tools. Pass `[{"google_search": {}}]` to enable Google Search grounding for real-time information in generated images.
    - `google_search` object — Enables Google Search grounding.

## Response `200`

Success

- object
  - `candidates` object[]
    - `content` object
      - `role` string — Always `model` for responses.
      - `parts` object[] — Response parts — may contain text, images, or both.
        - `text` string — Text content from the model.
        - `inlineData` object — Generated image data.
          - `mimeType` string — Image MIME type, typically `image/png`.
          - `data` string — Base64-encoded image data.
    - `finishReason` 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' — Reason generation stopped.
    - `index` integer
    - `safetyRatings` object[]
      - `category` string
      - `probability` string
  - `usageMetadata` object
    - `promptTokenCount` integer
    - `candidatesTokenCount` integer
    - `totalTokenCount` integer
    - `thoughtsTokenCount` integer — Token count for thinking process (Gemini 3 models only).

---

[API](https://skmtc.net/deerapi/apis/text-to-audio-api.md) · [All operations](https://skmtc.net/deerapi/apis/text-to-audio-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/deerapi/text-to-audio-api/versions/b6265ced74a1/schema)
