import openai import os from dotenv import load_dotenv load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") def generate_krishna_image(prompt, size="512x512"): try: response = openai.Image.create( prompt=f"{prompt}, vibrant colors, cartoon style, Little Krishna theme with peacock feathers and Vrindavan background", n=1, size=size ) image_url = response['data'][0]['url'] return image_url except Exception as e: print(f"Error generating image: {str(e)}") return None def generate_comic_strip(): panels = [ "Little Krishna seeing a shy girl reading alone in Vrindavan", "Little Krishna appearing with a playful smile, holding a flute", "Little Krishna handing the girl a book, surrounded by cows", "Little Krishna and the girl smiling together, with peacocks dancing" ] comic_images = [] for panel_prompt in panels: image_url = generate_krishna_image(panel_prompt) if image_url: comic_images.append(image_url) else: comic_images.append("https://via.placeholder.com/512x512.png?text=Error+Generating+Image") return comic_images