pollinations-bedtime-story — An illustrated, narrated bedtime story
Turn one idea into a finished bedtime story for a young child: a short story from a Pollinations text model, one picture per scene from a Pollinations image model, a read-aloud narration from a Pollinations speech model, and a single HTML storybook page with an audio player.
Setup
You need the Pollinations API. Prefer the polli CLI when it is installed;
otherwise call the REST API directly.
Authentication — no API key needed: sign in with polli auth login.
It uses a device flow — the CLI shows a code, you approve it in your
browser with your Pollinations account (billing through Pollinations Pay) —
and the CLI stores the issued key itself. Users never have to supply their
own API key. POLLINATIONS_API_KEY is only an optional, advanced
alternative for server-side / automated runs, never a requirement.
Never paste an API key into a chat, a file, or a command argument.
Cheap defaults that work — all verified on a free/quest balance (27 Nov 2026, real runs, see Costs):
- Text (story):
openai/gpt-5.4-nano— fast and near-free. - Image (scenes):
black-forest-labs/flux.1-schnell— $0.002/scene. - Narration:
openai/tts-1— about $0.0087 for a ~130-word story (~35 s).
Check current IDs first: polli models --type text,
polli models --type image, polli models --type audio.
Paid-only trap, verified: some audio models refuse the free/quest balance with HTTP 402 and cost real money —
hexgrad/kokoro-82m(TTS) andelevenlabs/eleven-music-v2.5viaelevenmusic(music, ~$0.075 for 3 s). Do NOT use them as defaults. Music is an optional, paid-only extra (step 5): offer it only if the user has paid balance, and say the price before generating.
Workflow
1. Ask for the idea (or invent one)
One small hero, one gentle fear or wish, one kind ending. Keep it to a single sentence, e.g. "Luna, a tiny firefly, is afraid of the dark, and a sleepy owl shows her the stars are friendly."
Ask the child's age (3–7 works best) and, if the user wants, a name to weave in as the listener ("for Maya"). Default: age 5, no name.
2. Write the story (text model)
Three scenes, each 40 words max, simple words, no scares, one warm ending line ("Goodnight, little light."). For each scene also ask for one visual description for the illustrator (one sentence).
polli gen text --model openai/gpt-5.4-nano --max-tokens 600 --no-stream \
"Write a short gentle bedtime story for a <age>-year-old, about <idea>.
Three short scenes. For each scene give: a title (3 words max), the story
text (40 words max), and one visual description for an illustrator (one
sentence). End with one line: Goodnight, little light. Keep it warm,
simple, in English." --output story.md
Save the result as story.md in the output folder.
3. Illustrate the scenes (image model)
One call per scene. Repeat the same hero description and the same style words in every prompt — that is what keeps the hero recognisable:
polli gen image "soft watercolor children's book illustration, <hero description, repeated verbatim>, <scene visual from the story>, gentle, cozy, dreamy" \
--model black-forest-labs/flux.1-schnell --width 512 --height 512 --seed 7 \
--output scene1.jpg
Rules:
- Same style prefix in all three prompts
(
soft watercolor children's book illustration,gentle, cozy, dreamy). - Same hero sentence in all three prompts, word for word.
- One new visual element per scene from the story — never rewrite the hero.
- If a scene comes back wrong, regenerate that scene only, with the missing element stated first in the prompt.
4. Narrate it (speech model)
Strip the titles and illustrator notes — narrate the story text only (~130 words max). Longer than that and one call can pass $0.01; split into one clip per scene if the story grows.
polli gen audio --model openai/tts-1 --output narration.mp3 < narration.txt
Check the file is a real MP3 (file narration.mp3, ~35 s for 130 words)
before calling it done.
5. Optional: a music sting (paid balance only)
Only if the user has paid Pollinations balance. Say the price first (~$0.075 for 3 s, verified 27 Nov 2026) and get a yes before generating:
polli gen audio --model elevenmusic --duration 3 --instrumental \
"soft music box lullaby, slow and gentle" --output music.mp3
Never generate music on the free/quest balance — the call fails with 402 and wastes the attempt. If there is no paid balance, ship the story without music: narration + pictures is the complete product.
6. Assemble the storybook page
Write an index.html next to the scenes: title, the three scenes in order
with picture + text, and an <audio controls> player for the narration at
the top (and the music sting at the end if there is one). Keep it a single
self-contained page that opens in any browser. Example:
examples/luna/index.html in this repo.
Also export a 16:9 screenshot (screenshot.png, 1280×720) for sharing.
7. Show it and check it
Read the page and listen to the narration before calling it done:
- Same hero in all three pictures (shape, colours, key features).
- Each picture matches its scene's text.
- Story reads in three beats: worry → comfort → brave goodnight.
- Narration audio plays, matches the written story, gentle pace.
- No scary words, no sad ending — the last line is a goodnight.
If a scene fails a check, regenerate it (step 3) — never ship a picture you know is wrong.
Costs (verified 27 Nov 2026, polli usage --history)
| Step | Model | Measured cost |
|---|---|---|
| Story text | openai/gpt-5.4-nano | $0.0002 |
| 3 illustrations | black-forest-labs/flux.1-schnell | 3 × $0.0020 = $0.0060 |
| Narration (~130 words, 35 s) | openai/tts-1 | $0.0087 |
| Whole story | $0.0149 |
Every call stays under $0.01. If the user's balance is low, say so before generating and offer a shorter story (fewer words = cheaper narration) or fewer scenes.
Example
examples/luna/ — "Luna the Firefly", made end to end with this skill:
story, 3 illustrations, 35 s narration, storybook page and 16:9
screenshot. Total spend: $0.0149. No music (paid-only on this account —
see step 5).
Script
scripts/run.sh runs the whole workflow for one idea:
scripts/run.sh "Luna, a tiny firefly, is afraid of the dark" ./out/luna