Goal
Build a production-ready ChatPDF app with:- Document prepare/upload
- Follow-up chat on a selected document
- URL-driven document rendering
- Minimal backend glue
Fastest path: starter app
Use the runtime demo starter:/chatpdffor chat flow/paper-explorerfor structured research workflow
Core flow
Runtime primitives to implement
| Capability | Method |
|---|---|
| Prepare document | documents.prepare({ sourceOrDocId, wait }) |
| Track status | documents.status(docId) / documents.wait(docId) |
| Chat turns | messages.create({ documentId, messages }) |
| Direct prompt | completions.create({ documentId, prompt }) |
| Page/image URLs | doc(docId).pages[n].image.url() |
Minimal architecture
- Client: upload/URL input + chat panel + page preview
- API routes:
session+askendpoints - Data model: store
docIdand conversation state in your app
Production hardening checklist
- Add role-based access and redaction policy before sharing outputs.
- Cache stable image/page URLs at CDN edge.
- Persist conversation history with document metadata.
- Instrument latency and per-session cost metrics.