BookForge turns a few details and your AI API key into a complete, long-form PDF book. It plans a chapter structure, writes every page with an AI model, keeps a long rolling context, renders Times New Roman typography with an illustration on every page, and checkpoints its work so a large run can be resumed safely.
Author: S M Nazmuz Sakib · Email: [email protected] · License: MIT
- Long-context engine — configure a context window up to 1,000,000 tokens. The tool keeps the outline, the book specification and as many recent chapter summaries as fit, trimming older material only when the configured window is reached.
- Exactly the length you ask for — target 500 pages by default; chapter page counts are rebalanced to hit the target, and short AI outputs are expanded locally so no page is blank.
- Strict prose — every paragraph is validated and padded until it contains at least the requested number of sentences (20 by default).
- Visual on every page — a deterministic PNG illustration is embedded per page; optionally the tool spends credits on AI-generated illustrations via an images API, with automatic local fallback.
- Book finishing — a title cover, table of contents, Times New Roman typography, plus PDF, Markdown and EPUB exports of the entire book.
- Reference grounding — point
-sourcesat a folder of.txt/.mdnotes; the tool folds them into the long-context prompt so the book stays grounded in your material. - Publishing trim sizes — export A4, 6×9 inch or 5×8 inch interiors (the formats professionals use for print-on-demand).
- Provider presets —
-provider openai|groq|gemini|deepseek|together|xaiconfigures endpoint and long-context model in one step. - Manuscript QA — a
quality.jsonreport checks page count, sentence minimums and duplicate paragraphs, and flags a failed book before you publish. - Narration script —
-narration book.txtexports a TTS-ready script with chapter and page markers for audiobook or voice-cloning workflows. - DOCX export — a Word-compatible
.docxis written beside the PDF/EPUB/Markdown, covering another format professional authors are asked for. - Edition support —
-edition "2nd edition"stamps the cover and metadata so revised works can be republished cleanly. - Style signal — the quality report also names the most over-used long word, a simple guard against detectable repetitive AI prose.
- KDP listing — a
.listing.mdfile with title, description, suggested keywords, categories and ISBN placeholder is generated from the brief. - Cover specification —
.cover-spec.jsoncalculates full-wrap cover width, height, spine width and 3 mm bleed for the chosen trim. - Resumable — each chapter is checkpointed as JSON; rerun the tool and it continues instead of spending credits again.
- Offline-safe assembly — PDF rendering runs locally; only the text generation calls the AI API.
- Publish a technical book — give it a topic, audience and tone; get a 500-page draft with chapters, headings and visuals ready for editing.
- Course material — generate a long textbook for a cohort, with consistent terminology maintained through the long context summaries.
- Research monograph — plan 25 chapters of 20 pages each and let the model keep earlier chapters in view while writing later ones.
- Content experiments — use
-demoto validate layout and pagination without spending API credits, then switch to the real API. - Resume interrupted runs — if a network error stops chapter 17, rerun with the same work directory; chapters 1–16 are reused from checkpoints.
Download bookforge.exe from the Releases page.
# Interactive setup: tool asks for title, topic, audience, tone, pages, chapters,
# context window, API key, endpoint and model.
.\bookforge.exe -interactive
# Or use a JSON config file
.\bookforge.exe -config my-book.json
# Test the layout without using credits
.\bookforge.exe -demo -pages 3 -chapters 1 -out demo.pdf -fresh
# Ground the writing in your own notes, use Groq, produce a 6x9 KDP interior
.\bookforge.exe -config my-book.json -sources .\my-notes -provider groq -trim 6x9 -epub book.epubThe tool prints progress for every chapter and finishes with the total page count and PDF path.
Save a template with .\bookforge.exe -demo -save-config config.example.json, then edit it.
Key fields:
| Field | Meaning |
|---|---|
title, topic, audience, tone |
The few details the tool needs |
target_pages |
Minimum book length (default 500) |
chapters |
Chapter count (default 25) |
sentences_per_paragraph |
Minimum sentences per paragraph (default 20) |
context_window |
Token budget for rolling context (default 1,000,000) |
api_key, base_url, model |
Your OpenAI-compatible API credentials and model |
max_tokens, temperature |
Per-call generation controls |
work_dir |
Checkpoint directory for resumable runs |
use_ai_images, image_model |
Optional AI illustrations (uses credits); local art is used when disabled or on failure |
Any OpenAI-compatible /chat/completions endpoint works, including providers with very
large context windows. Set base_url to the provider root (for example https://api.openai.com/v1).
Cost notice: text generation uses your API credits. The tool retries failed calls up to three times and reuses checkpoints, so reruns do not pay for completed chapters twice.
- A4 pages, Times-Roman (the standard PDF face rendered as Times New Roman) body text.
- Title cover, table of contents, chapter headings in bold Times, justified paragraphs, page number footer.
- A companion
.mdfile containing the full book text is written next to the PDF. - One embedded PNG illustration per page.
- At least the requested number of sentences in every paragraph.
- PDF metadata title, author and subject.
A locally generated example is included as docs/demo.pdf. It was produced
with -demo, so it used no AI credits.
go test ./...
go build -o bookforge.exe .The API key is stored in the JSON config with owner-only permissions on POSIX systems. Do not commit a config containing a real key. The tool makes HTTPS requests only to the endpoint you configure.
S M Nazmuz Sakib · [email protected] · GitHub
MIT © S M Nazmuz Sakib (2026). See LICENSE.
