Skip to content

Media Generation

Media Generation

Purpose

Document the user-facing generation flow from Brisket through Sirloin, Brain, Round, and Flank.

Participants

  • Brisket initiates generation and displays credit pricing.
  • Sirloin validates usage, deducts credits at request time, and stores user-facing media state.
  • Brain handles async generation records, queues, provider integrations, and calls to round.
  • Round serves internal model inference.
  • Flank participates when media.workflow_name is set.

Sequence

sequenceDiagram
participant Brisket
participant Sirloin
participant Brain
participant Round
participant Flank
Brisket->>Sirloin: Create media/generation request
Sirloin->>Sirloin: Validate usage and deduct credits
alt workflow_name set
Sirloin->>Flank: Execute workflow
else default path
Sirloin->>Brain: Send media to brain
Brain->>Round: Inference when needed
end
Brain-->>Sirloin: Generation status/result
Sirloin-->>Brisket: User-facing media state
  • apps/brisket/src/hooks/use-credits.tsx
  • apps/brisket/src/lib/constants.ts
  • apps/sirloin/internal/app/services/media/
  • apps/brain/src/modules/
  • apps/flank/server/engine/

Image Moderation

Brain can moderate input or source images before generation when an image is present, and it moderates generated outputs before they become available. Pre-generation moderation uses visual checks only today. Post-generation moderation also runs demographics age scoring and can run celebrity checks for NSFW generations.

A flagged single output fails the generation. For carousel output, flagged panels can be dropped and the request fails only if no safe panels remain. See Image Moderation And Age Scoring for checkpoint rules, age-scoring thresholds, and provider fallback behavior.

State Transitions

Sirloin deducts credits when the request is accepted. Brain records and processes async generation. Flank routes workflow-backed media when media.workflow_name is set. Re-edits with source_id can be free.

Invariants

  • Credit deductions happen at request time, not completion time.
  • NSFW pricing and full-access credit behavior must follow the media credit-cost standard.
  • Brain owns generation records; Sirloin owns user-facing media state.

Error Paths

Insufficient credits stop the request before async work starts. Provider or queue failures surface through Brain status and logs. Flank-backed failures must preserve media state and execution logs for inspection.

Tests And Verification

  • cd apps/sirloin && make run-tests
  • cd apps/brain && pnpm test
  • cd apps/flank && pnpm test