Cover Image Generation
| API route | app/api/generate-cover/route.ts |
| Image model | gemini-2.5-flash-image (via lib/gcp/imagen.ts) |
| Storage path | images/{storyId}/cover.png |
| Triggered by | GenerationProvider.tsx / useStoryAssembler.ts — after all page images finish |
What it does
Generates a dedicated front cover illustration for the story — separate from the page images. The cover has a centered composition with space at the top for the title, watercolor children's book style, and no text on the image.
Prompt
Children's storybook front cover for a book titled "{title}".
Story theme: {firstPageImagePrompt}.
Beautiful illustrated cover art, colorful and magical, centered composition
with space at the top for a title, watercolor children's book style,
whimsical, soft warm colors, inviting and joyful, safe for children,
portrait orientation, no text on the imagetitle— AI-generated story title from StoryWriterfirstPageImagePrompt— used as a theme hint (optional — omitted if not available)- No
referenceImagespassed — the cover is a scene shot, not character-focused
Flow
All page images generated
│
▼
POST /api/generate-cover { storyId, title, firstPageImagePrompt }
│
▼
generateImage(coverPrompt, []) ← no reference images
│
▼
uploadAndSign(buffer, "images/{storyId}/cover.png", "image/png")
│
▼
{ coverImageUrl } → saved to Firestore story.coverImageUrlStorage
images/{storyId}/cover.pngThe coverImageUrl field on the Firestore story document points to this GCS signed URL. It is displayed in:
- The dashboard library card thumbnail
- The story header/cover page
- The OG meta image for public story sharing (
/s/[id])
