DEV Community

张洲诚(Zack.ZHANG)
张洲诚(Zack.ZHANG)

Posted on

I Built an AI Storybook Generator for My Kid With One CLI

It's summer break, and I wanted to make a personalized picture book for my 5-year-old. Every tool I tried fell short the same way: "AI storybook" apps generate images, but the hero's face changes every other page — and there's no narration, no video, no way to make it an interactive, tappable book.

I ended up doing the whole thing with one command-line tool: Bailian CLI (bl). It writes the story, generates consistent illustrations, synthesizes narration, and I wrapped it into an interactive HTML book. Here's how.

Install

npm install -g bailian-cli   # needs Node.js >= 18
bl auth login --api-key sk-xxxxx
Enter fullscreen mode Exit fullscreen mode

Grab a free key from the Model Studio console (free credits are enough to run all of this).

Step 1 — Write the story

bl text chat --model qwen3.7-max \
  --system "You are a children's picture-book author. Warm, simple language for a 5-year-old." \
  --message "Write a 3-act short story 'Xiaoyu and the Firefly', 2-3 sentences per act."
Enter fullscreen mode Exit fullscreen mode

Step 2 — Consistent illustrations (the whole game)

The trick to keeping the same character across pages: bake the look into a fixed anchor you reuse in every prompt, plus the same --seed.

ANCHOR="A cute 5-year-old girl named Xiaoyu, round face, big eyes, short black bob hair with a red hairpin, yellow dress, white sneakers, soft watercolor picture book"

bl image generate --model qwen-image-2.0-pro --size 4:3 --seed 71 \
  --prompt "$ANCHOR, standing in a meadow at dusk holding a glowing lantern, one firefly nearby"
Enter fullscreen mode Exit fullscreen mode

Only swap the scene; the hero stays put:

Picture book scene 1: Xiaoyu with a lantern meets a firefly at dusk

Picture book scene 2: Xiaoyu follows the firefly into the forest

Picture book scene 3: fireflies surround Xiaoyu and light up the night

Same Xiaoyu across all three. qwen-image-2.0-pro even renders in-image text well — here's a 4-panel comic with speech bubbles:

Four-panel comic: a boy learns the yo-yo from failure to success

Step 3 — Narration

bl speech synthesize --text "At dusk, Xiaoyu strolled across the meadow with a little lantern..." --voice <voice_id> --out voice1.mp3
# bl speech synthesize --list-voices  # to pick a voice
Enter fullscreen mode Exit fullscreen mode

Step 4 — Assemble the interactive book

Drop each act's {image, text, audio} into a small HTML template with page-flip + play buttons:

Interactive HTML storybook UI: title bar, illustration, narration, prev/play/next buttons

~200 lines of HTML; the images and audio are all bl output. From "write me a firefly story" to a tappable e-book — without opening a single app.

Bonus: it's also a tutor

Same bl text chat, different persona:

bl text chat --system "You are an IELTS speaking examiner." --message "Score this answer on fluency, vocabulary, grammar, pronunciation and suggest fixes: 'I very like play basketball on weekend.'"
Enter fullscreen mode Exit fullscreen mode

Honest limitations

  • Consistency isn't 100% — generate a few, pick the best.
  • Video (video generate) is async; poll with bl video task get.
  • Assembling PDF/video/HTML is a separate step (template included).
  • Adults should vet the content — AI is the pen, not the author.

Try it


All examples run on Bailian CLI (bl 1.4.2); illustrations, comic, and the book UI are real bl output. Model Studio pricing.

Top comments (0)