Detect and route to the correct visual content type (hero shot, poster, infographic, etc.) from a text description or output type hint. Use when you need to...
Classify a content generation request into a structured content type configuration that provides layout rules, visual mode constraints, typography rules, and generation hints for downstream image generation.
The router maps natural language descriptions (and optional industry/type hints) to one of 17 predefined content type configurations across 4 categories:
| Category | Slugs |
|---|---|
product_focused | hero_shot, lifestyle_shot, flat_lay, detail_closeup, scale_shot, unboxing |
typography_heavy | poster, sale_promo, countdown, quote_graphic, announcement |
educational | infographic, comparison_chart, process_howto, carousel_educational |
social_proof | testimonial_graphic, before_after, ugc_repost |
Every content type has one of three visual modes that determine text handling:
| Mode | Slug | Behavior |
|---|---|---|
| Pure Visual | pure_visual | NO text on image — pure photography, composition, and lighting |
| Educational | educational | Minimal text allowed (data labels, steps) — up to ~35% of area |
| CTA | cta | Text is required — headlines, body, and call-to-action |
pure_visual)hero_shot — Single product on clean background, hero positioning
lifestyle_shot — Product in real-world context showing aspiration
flat_lay — Top-down arrangement of multiple items
detail_closeup — Macro shot for texture and craftsmanship
scale_shot — Product with size reference object
unboxing — Product with packaging, reveal aesthetic
cta)poster — Designed travel/event poster with headline and imagery
sale_promo — Promotional graphic with discount/offer messaging
countdown — Time-limited offer with countdown element
quote_graphic — Brand quote or testimonial as designed asset
announcement — Product launch or news announcement graphic
educational)infographic — Data visualization with labeled information
comparison_chart — Side-by-side comparison of options
process_howto — Step-by-step visual guide
carousel_educational — Multi-frame educational series (single frame rules)
cta or educational)testimonial_graphic — Customer quote with attribution
before_after — Side-by-side transformation visual
ugc_repost — User-generated content styled for brand repost
from content_types.registry import (
detect_content_type,
get_content_type_config,
get_industry_content_types,
get_content_types_by_visual_mode,
get_content_types_by_category,
get_all_content_types,
)
from content_types.base import VisualMode
# Detect from description
slug, confidence = detect_content_type(
description="I need a product shot on white background for Amazon",
industry="ecommerce",
)
# → ("hero_shot", 0.95)
# Get full config with layout rules and generation hints
config = get_content_type_config(slug)
prompt_context = config.to_prompt_context() # Inject into LLM prompt
negative_prompts = config.get_negative_prompt_string() # For image gen
# Industry-based recommendations
types = get_industry_content_types("beauty")
# → [HeroShot, BeforeAfter, FlatLay]
# Filter by visual mode
pure_visual_types = get_content_types_by_visual_mode(VisualMode.PURE_VISUAL)
# Filter by category
product_types = get_content_types_by_category("product_focused")
output_type exactly matches a slug → confidence 1.0lifestyle_shot(slug: str, confidence: float)
# confidence: 0.0-1.0
# 0.3+ = usable, 0.7+ = high confidence
ContentTypeConfig Structure@dataclass
class ContentTypeConfig:
name: str # Human-readable name
slug: str # Machine key: "hero_shot"
category: str # "product_focused" | "typography_heavy" | etc.
definition: str # One-line definition for LLM context
visual_mode: VisualMode # PURE_VISUAL | EDUCATIONAL | CTA
layout: LayoutRules # Focal point, coverage, background, camera angle
typography: Optional[TypographyRules] # Headline words, weight, CTA rules
generation_hints: List[str] # Positive requirements for image gen prompt
negative_prompts: List[str] # What to avoid (comma-joined for diffusion)
detection_keywords: List[str] # Keyword matching corpus
common_industries: List[str] # Industry affinity
aspect_ratios: List[str] # Recommended ratios: ["4:5", "1:1"]
LayoutRules Structure@dataclass
class LayoutRules:
focal_point: str # "center" | "upper_third" | "rule_of_thirds" | "left" | "right"
text_zone: Optional[str] # "bottom_40_percent" | "top_20_percent" | "overlay" | None
subject_coverage_min: float # Min % of frame for main subject
subject_coverage_max: float # Max % of frame for main subject
text_area_max: float # Max % of frame for text (0.0 = no text)
logo_zone: str # "corner" | "bottom_center" | "none"
whitespace_min: float # Minimum negative space target
camera_angle: Optional[str] # "eye_level" | "overhead" | "low_angle" | "macro"
background: Optional[str] # "white" | "gradient" | "contextual" | "lifestyle"
| Industry | Top 3 Content Types |
|---|---|
| travel | poster, lifestyle_shot, carousel_educational |
| dtc | hero_shot, lifestyle_shot, ugc_repost |
| fashion | lifestyle_shot, flat_lay, ugc_repost |
| beauty | hero_shot, before_after, flat_lay |
| food | flat_lay, lifestyle_shot, process_howto |
| saas | infographic, comparison_chart, testimonial_graphic |
| luxury | hero_shot, detail_closeup, lifestyle_shot |
| health | before_after, testimonial_graphic, infographic |
The registry supports optional DB-backed content types (for per-brand customization):
export USE_DB_CONTENT_TYPES=true # Enable DB mode
When enabled, types load from a content_types Supabase table with brand-specific overrides. Falls back to code-defined types on DB errors.
# Invalidate cache after DB updates
from content_types.registry import invalidate_cache
invalidate_cache()
# Enable/disable at runtime
from content_types.registry import enable_db_mode
enable_db_mode(True)
Inject the config into image generation prompts:
slug, confidence = detect_content_type(description, industry=industry)
config = get_content_type_config(slug)
# Build generation prompt
system_context = config.to_prompt_context()
negative = config.get_negative_prompt_string()
# Pass to image generation
generate_image(
prompt=f"{system_context}\n\n{user_prompt}",
negative_prompt=negative,
aspect_ratio=config.aspect_ratios[0],
)
ZIP package — ready to use