Generative AI transforms marketing workflows by automating content creation, personalizing campaigns, and generating visual assets. This guide shows how to use Gemini and Imagen to create marketing materials at scale while maintaining brand consistency.
Generate complete marketing campaigns from product information:
def generate_marketing_content( product_name: str, product_description: str, product_image_url: str, target_audience: str,) -> dict: """Generate comprehensive marketing content for a product.""" system_instruction = """You are an expert marketing copywriter specializing in compelling,conversion-focused content. Create engaging, authentic content thatresonates with the target audience while highlighting product benefits. """ prompt = f"""Create marketing content for:Product: {product_name}Description: {product_description}Target Audience: {target_audience}Generate:1. Catchy tagline (max 10 words)2. Product description for e-commerce (50-75 words)3. Short social media caption (20-30 words)4. Email subject line5. Key selling points (5 bullet points)6. Call-to-action suggestions """ response = client.models.generate_content( model="gemini-2.5-pro", contents=[ prompt, Part.from_uri(file_uri=product_image_url, mime_type="image/jpeg"), ], config=GenerateContentConfig( system_instruction=system_instruction, temperature=0.8, # Higher creativity for marketing ), ) return response.text# Usagecontent = generate_marketing_content( product_name="EcoBottle Pro", product_description="Insulated stainless steel water bottle with smart temperature tracking", product_image_url="gs://marketing-assets/ecobottle-pro.jpg", target_audience="environmentally-conscious millennials and Gen Z",)print(content)
Output:
# EcoBottle Pro Marketing Content## Tagline"Stay Hydrated. Stay Smart. Stay Sustainable."## Product DescriptionThe EcoBottle Pro combines premium insulated construction with intelligenttemperature monitoring to keep your drinks perfect all day. Crafted fromdurable stainless steel with a leak-proof design, it tracks your hydrationgoals while keeping beverages hot for 12 hours or cold for 24. Eco-friendly,technology-enabled, and built to last a lifetime.## Social Media Caption🌍 Hydration meets innovation! The EcoBottle Pro keeps your drinks perfectwhile tracking your wellness goals. Sustainable living, smarter. 💧✨## Email Subject Line"Your Perfect Temperature, Always: Meet EcoBottle Pro 🌡️"## Key Selling Points- Smart temperature tracking via companion app- 24-hour cold / 12-hour hot insulation- 100% recycled stainless steel construction- Leak-proof, dishwasher-safe design- Lifetime warranty & plastic-free packaging## Call-to-Action- "Shop EcoBottle Pro"- "Start Your Sustainable Journey"- "Join the Hydration Revolution"
Adapt content for different social media platforms:
from pydantic import BaseModelclass SocialMediaPost(BaseModel): platform: str caption: str hashtags: list[str] character_count: int best_posting_time: strclass SocialMediaCampaign(BaseModel): facebook: SocialMediaPost instagram: SocialMediaPost linkedin: SocialMediaPost twitter: SocialMediaPostresponse = client.models.generate_content( model="gemini-2.0-flash", contents=f"""Create social media posts for EcoBottle Pro across all major platforms.Product: {product_name}Key Message: Sustainable hydration with smart technologyAdapt the tone, length, and hashtags for each platform's best practices. """, config=GenerateContentConfig( response_schema=SocialMediaCampaign, response_mime_type="application/json", ),)campaign = response.parsedfor platform in ["facebook", "instagram", "linkedin", "twitter"]: post = getattr(campaign, platform) print(f"\n{post.platform.upper()}:") print(f"Caption: {post.caption}") print(f"Hashtags: {' '.join(post.hashtags)}") print(f"Best time: {post.best_posting_time}")
from vertexai.preview.vision_models import ImageGenerationModeldef generate_marketing_image( prompt: str, negative_prompt: str = None, aspect_ratio: str = "1:1", number_of_images: int = 4,) -> list: """Generate marketing images using Imagen. Args: prompt: Detailed description of desired image negative_prompt: What to avoid in the image aspect_ratio: "1:1", "16:9", "9:16", "4:3" number_of_images: Number of variations (1-4) Returns: List of generated images """ model = ImageGenerationModel.from_pretrained("imagen-3.0-generate-001") images = model.generate_images( prompt=prompt, negative_prompt=negative_prompt, number_of_images=number_of_images, aspect_ratio=aspect_ratio, safety_filter_level="block_some", person_generation="allow_adult", ) return images.images# Generate product lifestyle imagesprompt = """Professional product photography of a sleek stainless steel water bottleon a minimalist desk setup with a laptop, notebook, and succulent plant.Natural lighting, modern aesthetic, teal and white color scheme,high resolution, e-commerce ready."""negative_prompt = "cluttered, blurry, low quality, distorted, text, watermark"images = generate_marketing_image( prompt=prompt, negative_prompt=negative_prompt, aspect_ratio="1:1", number_of_images=4,)# Save imagesfor i, image in enumerate(images): image.save(f"marketing_image_{i}.png")
def localize_marketing_content( content: str, target_language: str, target_region: str,) -> str: """Localize marketing content with cultural adaptation.""" prompt = f"""Localize this marketing content for {target_region} in {target_language}.Original Content:{content}Requirements:1. Translate accurately while maintaining marketing impact2. Adapt idioms and cultural references appropriately3. Adjust for local market preferences4. Maintain brand voice5. Optimize for local SEO keywordsProvide both the localized content and notes on cultural adaptations made. """ response = client.models.generate_content( model="gemini-2.5-pro", contents=prompt, ) return response.text# Localize for multiple marketsmarkets = [ ("Spanish", "Latin America"), ("Japanese", "Japan"), ("German", "Germany"),]for language, region in markets: localized = localize_marketing_content( content=base_marketing_content, target_language=language, target_region=region, ) print(f"\n--- {region} ({language}) ---") print(localized)
AI-generated content should align with your brand guidelines and be reviewed before publication. Always comply with advertising regulations and platform policies.