// Package mediagen provides a unified interface for media (image/video) generation // across multiple providers with fallback and routing capabilities. package mediagen import ( "context" "time" ) // Provider defines common methods for all media generation providers. // Implementations must be safe for concurrent use. type Provider interface { // Name returns the provider name for logging and metrics. Name() string // Health checks if the provider is reachable and operational. Health(ctx context.Context) error } // ImageGenerator defines the interface for image generation providers. // Implementations must be safe for concurrent use. type ImageGenerator interface { Provider // GenerateImage generates one or more images from a text prompt. GenerateImage(ctx context.Context, req ImageRequest) (*ImageResponse, error) } // VideoGenerator defines the interface for video generation providers. // Implementations must be safe for concurrent use. type VideoGenerator interface { Provider // GenerateVideo generates a video from a text prompt and optional reference images. // May block for extended periods (30s-5min) while video renders. GenerateVideo(ctx context.Context, req VideoRequest) (*VideoResponse, error) } // MediaGenerator combines both image and video generation capabilities. // Use when a provider supports both. type MediaGenerator interface { ImageGenerator VideoGenerator } // ImageRequest represents a unified image generation request. type ImageRequest struct { Prompt string // Required: text description of desired image Model string // Optional: model override (provider-specific) Size string // Optional: size hint ("1K", "2K", "4K") AspectRatio string // Optional: aspect ratio ("16:9", "1:1", "9:16") Count int // Optional: number of images (default: 1) Timeout time.Duration // Optional: request timeout // Reference image for identity consistency (e.g., maintaining same face/character) ReferenceImage []byte // Optional: reference image bytes ReferenceMime string // Optional: MIME type ("image/png", "image/jpeg", "image/webp") // Determinism controls for reproducible generation Seed *int32 // Optional: seed for reproducible results (nil = provider chooses random) } // ImageResponse represents a unified image generation response. type ImageResponse struct { Images []Image // Generated images Provider string // Name of provider that generated this response Latency time.Duration // Time taken to generate Seed *int32 // Seed used for generation (nil if random, echoed back for reproducibility) } // Image represents a single generated image. type Image struct { Data []byte // Raw image bytes (PNG, JPEG, etc.) MimeType string // MIME type ("image/png", "image/jpeg") URL string // Optional: URL if provider returns URL instead of bytes } // VideoRequest represents a unified video generation request. type VideoRequest struct { Prompt string // Required: text description of desired video Model string // Optional: model override (provider-specific) ReferenceImages []Image // Optional: reference images for image-to-video AspectRatio string // Optional: aspect ratio ("16:9", "9:16") Duration string // Optional: duration ("5s", "10s") Count int // Optional: number of videos (default: 1) Timeout time.Duration // Optional: request timeout // Determinism controls for reproducible generation Seed *int32 // Optional: seed for reproducible results (nil = provider chooses random) } // VideoResponse represents a unified video generation response. type VideoResponse struct { Videos []Video // Generated videos Provider string // Name of provider that generated this response Latency time.Duration // Time taken to generate Seed *int32 // Seed used for generation (nil if random, echoed back for reproducibility) } // Video represents a single generated video. type Video struct { Data []byte // Raw video bytes (MP4, etc.) MimeType string // MIME type ("video/mp4") URL string // Optional: URL if provider returns URL instead of bytes }