// Package backend defines the model-agnostic contract every image-generation // adapter must satisfy. The framework speaks only through Backend; concrete // adapters (ComfyUI, Replicate, OpenAI, …) translate Request into whatever // the upstream API expects and return a Result. package backend import ( "context" "io" ) // Request is the cross-backend request shape. Adapters translate it // to whatever their target API expects. Zero values mean "use backend default" // unless documented otherwise. type Request struct { Prompt string NegativePrompt string Width, Height int Steps int Seed int64 Style string BackendOpts map[string]any } // Result is what the backend produces. The caller is responsible for closing // ImageReader. type Result struct { ImageReader io.ReadCloser MimeType string Metadata map[string]any } // Backend is the interface every adapter satisfies. type Backend interface { Name() string Generate(ctx context.Context, req Request) (*Result, error) }