Skip to Content
New FeaturesFeature: AI Image Generation for Social & Ads — ✅ IMPLEMENTED

Feature: AI Image Generation for Social & Ads — ✅ IMPLEMENTED

Priority: ✅ Implemented (April 2026)
Area: Content / Design
Competitive Reference: Jasper (AI Image Suite), Predis.ai (AI creative generation), Canva AI


Implementation Status

Completed:

  • OpenAI/Azure images provider package (@leadmetrics/provider-openai-images)
  • Social post designer agent integration with AI image generation
  • Credit tracking for image generation (2 credits per image)
  • Support for both Azure OpenAI and OpenAI DALL-E
  • Automatic brand-aware prompt generation
  • Logo overlay and composite image creation

Files Created/Modified:

  • packages/providers/openai-images/ - New provider package
  • packages/agents/src/workers/social-post-designer.worker.ts - Refactored to use provider
  • packages/billing/src/credit-rates.ts - Added image generation costs

Why This Matters

Every major competitor now includes AI image generation. Marketing agencies need on-brand visuals for social posts, ad creatives, blog headers, and landing pages. Leadmetrics now generates AI images with brand consistency and automatic credit tracking.


What Leadmetrics Has Now

OpenAI Images Provider (packages/providers/openai-images)

  • Primary: Azure OpenAI GPT Image 1.5 (high quality, cost-effective)
  • Fallback: OpenAI DALL-E 3 (when Azure unavailable)
  • Brand-aware prompt builder with color, style, and element avoidance
  • Configurable quality and size options
  • Type-safe TypeScript implementation with comprehensive tests

Social Post Designer Integration

  • Automatically generates images for social posts
  • Integrates tenant brand assets (colors, style, logo)
  • Reserves and consumes credits per image
  • Handles carousel posts with multiple slides
  • Overlays brand logo on generated images

Credit System Integration

  • ai_image_generation: 2 credits per image (Azure GPT Image 1.5 / DALL-E 3)
  • ai_image_flux: 0.5 credits per image (reserved for future Flux integration)
  • Automatic credit reservation before generation
  • Credit consumption tracking per image
  • Partial credit release on failures

What Competitors Offer

PlatformFeatureCapability
JasperAI Image SuiteText-to-image generation with brand guidelines enforcement (colors, style, no-go zones)
Predis.aiCreative GenerationAI generates complete social media graphics (image + text overlay + branding) from a text prompt
CanvaMagic DesignAI generates full designs from a text description using brand kit
Copy.aiDoes not have image generation (text-only)

Implementation Details

OpenAI Images Provider

Location: packages/providers/openai-images/

Features:

  • Dual provider support (Azure GPT Image 1.5 primary, OpenAI DALL-E 3 fallback)
  • Type-safe TypeScript with comprehensive error handling
  • Brand-aware prompt builder
  • Configurable image sizes, quality, and output formats
  • Base64 or URL response formats
  • PNG output with configurable compression

Usage Example:

import { OpenAIImagesProvider } from "@leadmetrics/provider-openai-images"; // Initialize with Azure const provider = new OpenAIImagesProvider({ provider: "azure", apiKey: process.env.AZURE_IMAGE_API_KEY!, azureEndpoint: process.env.AZURE_IMAGE_ENDPOINT!, }); // Or with OpenAI DALL-E const provider = new OpenAIImagesProvider({ provider: "openai", apiKey: process.env.OPENAI_API_KEY!, }); // Generate image with brand guidelines const result = await provider.generateImage({ prompt: provider.buildBrandAwarePrompt( "social media marketing tips", { primaryColor: "#6B21A8", visualStyle: "modern professional", avoidElements: ["faces", "text"], } ), size: "1024x1024", quality: "hd", }); const imageBuffer = Buffer.from(result.images[0].b64Json!, "base64");

Social Post Designer Integration

The social-post-designer worker now:

  1. Reserves credits before generation (2 credits × slide count)
  2. Generates images using the OpenAI provider with brand guidelines
  3. Overlays logo on generated images
  4. Uploads to Spaces and creates Media records
  5. Consumes credits for successful generations
  6. Releases unused credits if some slides fail

Credit Tracking:

  • Upfront reservation prevents over-spending
  • Per-image consumption for accurate billing
  • Partial release on failures
  • Logged in CreditLedger for audit trail

Brand-Aware Generation

Images are automatically generated with tenant’s brand assets:

  • Primary and secondary colors
  • Visual style preferences (professional, modern, vibrant, etc.)
  • Design notes and style keywords
  • Element avoidance (faces, text, etc.)

Example Prompt:

A professional graphic about social media marketing tips. Brand colors: primary #6B21A8, secondary #FFFFFF. Style: modern, clean, minimalist. No photorealistic faces. No embedded text. Clean professional composition.

Configuration

Environment Variables

Azure GPT Image 1.5 (primary):

AZURE_IMAGE_API_KEY=DzQKmjEA8WofYwOxbLaPVmek5PWqMt3XeBUuDNm5BGVybFJwscQSJQQJ99CCACF24PCXJ3w3AAAAACOG1Joz AZURE_IMAGE_ENDPOINT=https://getmo-mn31nkpp-uaenorth.cognitiveservices.azure.com/openai/deployments/gpt-image-1.5/images/generations?api-version=2024-02-01

OpenAI DALL-E 3 (fallback):

OPENAI_API_KEY=sk-your-openai-key

The system automatically uses Azure GPT Image 1.5 if AZURE_IMAGE_ENDPOINT is set, otherwise falls back to OpenAI DALL-E 3.


Credit Costs

ProviderCost per ImageUse Case
Azure GPT Image 1.52 creditsPrimary provider, high quality
OpenAI DALL-E 32 creditsFallback provider
Flux / Stability (future)0.5 creditsHigh-volume, lower cost

Example:

  • Instagram carousel with 5 slides = 10 credits
  • Single Instagram post = 2 credits
  • Blog header image = 2 credits

Testing

Provider Tests: packages/providers/openai-images/src/__tests__/

  • ✅ 15 unit tests covering all features
  • Constructor validation
  • Image generation (OpenAI and Azure)
  • Brand-aware prompt building
  • Error handling

Run tests:

cd packages/providers/openai-images pnpm test

Future Enhancements

Phase 2 — API Endpoints (Planned)

Add dashboard endpoints for manual image generation:

POST /tenant/v1/images/generate { "prompt": "modern tech workspace", "brandGuidelines": { "primaryColor": "#6B21A8", "visualStyle": "professional" }, "size": "1024x1024", "quality": "hd" }

Phase 3 — Additional Providers (Planned)

  • Flux (Black Forest Labs) - Lower cost alternative
  • Stability AI - Stable Diffusion models
  • Midjourney - Via API when available

Phase 4 — Template Compositing (Planned)

Combine AI images with text overlays:

  • Platform-specific layouts (Instagram, LinkedIn, etc.)
  • Auto-place logo, CTA, text
  • Export ready-to-publish graphics

© 2026 Leadmetrics — Internal use only