generate_image_from_text
Create high-quality images from text prompts using Google's Gemini AI. Transform descriptions into visual content with automatic saving for versatile use cases.
Instructions
Generate an image based on the given text prompt using Google's Gemini model.
Args:
prompt: User's text prompt describing the desired image to generate
Returns:
Path to the generated image file using Gemini's image generation capabilities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes |
Implementation Reference
- src/gemini_image_mcp/server.py:247-270 (handler)The primary handler function decorated with @mcp.tool() for registration. Implements the core logic: translates prompt, creates enhanced prompt template, invokes Gemini image generation via helpers, saves and returns image path.async def generate_image_from_text(prompt: str) -> str: """Generate an image based on the given text prompt using Google's Gemini model. Args: prompt: User's text prompt describing the desired image to generate Returns: Path to the generated image file using Gemini's image generation capabilities """ try: # Translate the prompt to English translated_prompt = await translate_prompt(prompt) # Create detailed generation prompt contents = get_image_generation_prompt(translated_prompt) # Process with Gemini and return the result return await process_image_with_gemini([contents], prompt) except Exception as e: error_msg = f"Error generating image: {str(e)}" logger.error(error_msg) return error_msg