Skip to main content
Glama
IMAGE_GENERATION_FIX.md1.94 kB
# Gemini Image Generation Fix Summary ## Issue Found The `generate_image` function was failing because: 1. It was using `gemini-2.0-flash-exp` which is an older experimental model 2. The `generationConfig` with `responseModalities: ['Text', 'Image']` wasn't being passed correctly to the API ## What Changed Based on Google's latest documentation, image generation with Gemini 2.0 Flash requires: - Using the specific model: `gemini-2.0-flash-preview-image-generation` - Passing `generationConfig` to the `generateContent()` method (not to `getGenerativeModel()`) ## Files Modified 1. **src/config.js**: Updated model names for IMAGE_GENERATION and IMAGE_EDITING 2. **src/gemini/gemini-service.js**: Fixed how `generationConfig` is passed in `generateImage()` and `analyzeImage()` methods ## To Apply the Fix 1. **Restart Claude Desktop** to reload the MCP server with the changes 2. **Test the fix** using the provided test script: ```bash cd /Users/rob/Claude/mcp-servers/gemini-mcp-server chmod +x test-image-generation.js ./test-image-generation.js ``` 3. **Or test directly in Claude** by using the generate_image tool: ``` Use the generate_image tool to create "A beautiful serene mountain landscape at sunset" with context "artistic" ``` ## Important Notes - The image generation feature is in preview and may have rate limits - Generated images will be saved to: `~/Claude/resources/gemini-images/` - The fix also applies to the `gemini-edit-image` tool which uses the same preview model ## API Changes Google updated their image generation API approach: - Old: Regular Gemini 2.0 Flash models don't generate images - New: Must use specific preview models with `responseModalities` configuration - Model name: `gemini-2.0-flash-preview-image-generation` The refactored Smart Tool Intelligence system is working perfectly - the issue was just with the Gemini API configuration for image generation!

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Garblesnarff/gemini-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server