Skip to main content

Goal

Build a production-ready ChatPDF app with:
  1. Document prepare/upload
  2. Follow-up chat on a selected document
  3. URL-driven document rendering
  4. Minimal backend glue

Fastest path: starter app

Use the runtime demo starter:
cd runtime-demo/apps/vercel-pdf-pipeline-starter
npm install
cp .env.example .env.local
# set OKRA_API_KEY
npm run dev
Then open:
  • /chatpdf for chat flow
  • /paper-explorer for structured research workflow

Core flow

Runtime primitives to implement

CapabilityMethod
Prepare documentdocuments.prepare({ sourceOrDocId, wait })
Track statusdocuments.status(docId) / documents.wait(docId)
Chat turnsmessages.create({ documentId, messages })
Direct promptcompletions.create({ documentId, prompt })
Page/image URLsdoc(docId).pages[n].image.url()

Minimal architecture

  • Client: upload/URL input + chat panel + page preview
  • API routes: session + ask endpoints
  • Data model: store docId and conversation state in your app
This keeps document parsing/orchestration out of your app runtime while preserving typed and cacheable URL surfaces.

Production hardening checklist

  1. Add role-based access and redaction policy before sharing outputs.
  2. Cache stable image/page URLs at CDN edge.
  3. Persist conversation history with document metadata.
  4. Instrument latency and per-session cost metrics.