Skip to content

ValentinJSchmidt/romantic-quest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Book Generator

Generate 100+ page books on any topic using a LangGraph agentic pipeline powered by Google Gemini (or Anthropic Claude). The output is a ready-to-publish .epub file, complete with a generated cover image.

How it works

The system is a stateful graph built with LangGraph. Given a topic, author name, and language, it runs the following pipeline:

  1. Premise generation — the LLM writes a compelling one-paragraph premise and picks a title.
  2. Outline generation — a structured JSON outline with 15+ chapters is produced, each chapter split into two parts following a dramatic five-part structure.
  3. Cover generation — an image is generated via Imagen 4 Ultra based on the title and premise.
  4. Chapter writing loop — each chapter is written in two sequential parts, with the full draft so far passed as context to reduce repetition and maintain continuity.
  5. Description writing — a back-cover blurb is generated from the finished draft.
  6. EPUB packaging — all chapters and the cover are bundled into a proper .epub file using ebooklib.

Books can also be generated using Claude Sonnet by toggling USE_CLAUDE = True in the notebook.

Setup

Install and activate the conda environment:

conda env create -f environment.yml
conda activate <env-name>

Export your API keys before launching the notebook:

export GEMINI_API_KEY=your_key_here
export ANTHROPIC_API_KEY=your_key_here   # only needed if using Claude

Then open the notebook:

jupyter notebook beyond_llms_project.ipynb

Run the cells in order. When prompted, enter the book topic, author name, and target language.

Output

  • EPUB saved to books/<title>.epub
  • Cover image saved to book_covers/<title>_cover.jpg

Model choice and cost

Model Cost per book Speed Notes
Gemini 2.5 Flash ~$1 Fast Recommended default
Claude Sonnet ~$4+ Slow Higher quality prose on some topics

Generating a full book takes 30+ minutes. API calls can occasionally fail; the notebook includes retry logic, but you may need to rerun cells.

Ethical note

This tool can produce books in any language and at scale. Please use it responsibly and be mindful of the environmental cost of large LLM inference runs and the risk of flooding platforms with low-quality generated content.

About

A fully-functioning automatic book creator. Given a prompt, the system generates a 100+ page book.Create books on demand and have fun.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors