Generate the desired image from the text description.
Bearer Auth (In: header)Authorization: Bearer <YOUR_API_KEY>Bearer <YOUR_API_KEY>. Format: Authorization: Bearer sk-xxxxxx.| Field | Type | Required | Description |
|---|---|---|---|
contents | array | ✅ | Content of the current conversation with the model. For single-turn queries, this contains one instance. For multi-turn queries (e.g., chat), this contains the conversation history and the latest request. |
>contents.role | string | ✅ | The role of the message sender. Can be user model. |
>contents.parts | array | ✅ | The content parts of the message, which can contain different types of content (text, inlineData, etc.). See Multimodal |
>>contents.parts.text | string | ✅ | The prompt for generating images. To include images or multiple images |
generationConfig | object | - | Configuration options for content generation. |
>generationConfig.imageConfig | object | - | Configuration for image generation. If set for models that don’t support these configuration options, the system will return an error. See ImageConfiguration |
>generationConfig.responseModalities | array | - | The modalities of the response. If set for models that don’t support these configuration options, the system will return an error. Can be TEXT IMAGE. |
>generationConfig.temperature | number | - | Controls the randomness of the output. Range in 0.0-1.0. |
| Field | Type | Required | Range/Example | Description |
|---|---|---|---|---|
parts | array | ✅ | text inlineData fileData | The content parts of the message, which can contain different types of content. |
>parts.inlineData | object | - | - | Inline media content. If used, data must be base64-encoded. |
>>parts.inlineData.mimeType | string | ✅ Yes (if inline_data is used) | image/jpeg image/png | The IANA-standard MIME type of the source data. If the provided MIME type is not supported, the system will return an error. |
>>parts.inlineData.data | string | ✅ Yes (if inline_data is used) | - | Base64-encoded media data. |
>parts.fileData | object | - | - | File media content. If used, fileUri must be provided. |
>>parts.fileData.mimeType | string | ✅ Yes (if file_data is used) | image/jpeg image/png | The IANA-standard MIME type of the source data. If the provided MIME type is not supported, the system will return an error. |
>>parts.fileData.fileUri | string | ✅ Yes (if file_data is used) | - | The URI of the file to be processed. |
| Field | Type | Required | Range/Example | Description |
|---|---|---|---|---|
imageConfig | object | - | - | Configuration for image generation. |
>imageConfig.aspectRatio | string | - | 1:1 2:3 3:2 3:4 4:3 9:16 16:9 21:9 1:4 4:1 1:8 8:1 | Configuration for image generation. |
>imageConfig.imageSize | string | - | 0.5K 1K 2K 4K | Approximate size of the generated image. If not specified, the model will use the default value of 1K. 0.5K is only supported by Gemini 3.1 Flash Image Preview; 2K and 4K are only supported by Gemini 3.1 Flash Image Preview and Gemini 3 Pro Image Preview. |
| Feature | Gemini 2.5 Flash Image | Gemini 3.1 Flash Image Preview | Gemini 3 Pro Image Preview |
|---|---|---|---|
| Use case | Speed & efficiency | Speed & high-volume | Professional asset production |
| Supported sizes | 1K | 0.5K, 1K, 2K, 4K | 1K, 2K, 4K |
| Max reference images | 3 | 14 | 14 |
| Max object images | — | 10 | 6 |
| Max portrait images | — | 4 | 5 |
| Extra aspect ratios | — | 1:4, 4:1, 1:8, 8:1 | — |
aspect_ratio field under image_config in your request, as shown below: