Contract Clause Finder
Paste a short contract or upload a PDF - structured risk clauses, obligations, and dates table via generateObject.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/contract-clause-finder pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects. Outputs are not legal advice.
Contract Clause Finder accepts pasted contract text or a .pdf / .txt upload (unpdf for PDFs), then uses generateObject to return up to 24 rows classified as risk, obligation, date, or other. The UI renders a table and can export JSON. No AI keys - 503.
Features
- Paste or PDF – multipart upload or JSON
{ text }. - Structured table – kind, title, summary, party, deadline.
- Export JSON – download
{ clauses: [...] }. - Sample MSA – payment, liability, termination, confidentiality.
- Honest unavailable state.
Server Reference
POST /api/clauses
Multipart: text, optional file. Or JSON { "text": "..." }.
Success (200)
{
"clauses": [
{
"kind": "obligation",
"title": "Payment terms",
"summary": "Customer pays within 30 days.",
"excerpt": "Customer shall pay invoices within thirty (30) days",
"party": "Customer",
"dateOrDeadline": "30 days of receipt"
}
],
"charsUsed": 1200,
"provider": "ai-gateway"
}| Status | Cause |
|---|---|
503 | No AI provider |
400 | Empty source / bad PDF |
Implementation Details
Extract text
unpdf for PDFs; truncateText caps at ~20k chars.
generateObject + clamp
Zod schema + clampClauses trims excerpts and caps rows at 24.
Use Cases
- Quick triage of short vendor MSAs.
- Teach document - table composition with
generateObject. - Export clause JSON into review checklists.
Limitations
- Not legal advice; image-only PDFs fail extraction.
- Long agreements are truncated.
- No auth / rate limits.
Use in your project
Copy the multipart extract + generateObject pattern from app/api/clauses/route.ts. Persist rows to Neon or Blob as needed.
Deployment
Local Development
cd apps/experiments/contract-clause-finder
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
AI_GATEWAY_API_KEY | Yes (or OPENAI_API_KEY) | Preferred provider |
OPENAI_API_KEY | No | Fallback |
AI_MODEL | No | Model override |
Vercel / Next.js Features Used
- AI SDK
generateObject - Vercel AI Gateway
- Route Handlers
unpdf- Zod