NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

[Feature Request] Add Gemini 2.0 Flash Native Image Generation Support

Open lim-kim930 opened this issue 10 months ago • 1 comments

🥰 Feature Description

The Gemini 2.0 Flash API now supports native image generation: Experiment with Gemini 2.0 Flash native image generation

response_modalities: ['Text', 'Image'] is required in the API request:

config=types.GenerateContentConfig(
    response_modalities=["Text", "Image"]
),

Now NextChat lacks a setting to enable this,it would be great to add this feature.

🧐 Proposed Solution

Add a setting in model configuration for Gemini models to enable/disable native image generation, like Output Format.

📝 Additional Information

No response

lim-kim930 avatar Mar 13 '25 12:03 lim-kim930

I've tested the payload below locally and can confirm that I'm successfully receiving image responses (base64):

// app/client/platforms/google.ts

const requestPayload = {
    contents: messages,
    generationConfig: {
        responseModalities: ['Text', 'Image'], // added a property here
        temperature: modelConfig.temperature,
        // ........
    },
    // ......
};
{
    "candidates": [
        {
            "content": {
                "parts": [
                    {
                        "inlineData": {
                            "mimeType": "image/png",
                            "data": "iVBORw0KGgoAAAANSUhEUgAABAAAAAKkCAIAAAARItoWAAAgAElEQVR4...."
                        }
                    }
                ],
                "role": "model"
            },
            "index": 0
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 8,
        "totalTokenCount": 8,
        "promptTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 8
            }
        ]
    },
    "modelVersion": "gemini-2.0-flash-exp"
}

However, it seems that NextChat currently doesn't support displaying these images.

Image

lim-kim930 avatar Mar 13 '25 12:03 lim-kim930