AI-powered conversational document filling for legal templates.
Fill legal documents faster with AI-guided conversations. Upload your .docx template, answer questions in a chat, and download a perfectly formatted completed document.
π Live App: https://clausefill-ai.vercel.app/
- β Preserves formatting - Original document structure maintained perfectly
- β
Multiple placeholder formats -
[brackets],{curly},$[amount],___(3+ underscores) - β Live preview - See changes in real-time as you fill
- β No data stored - Everything processed in your browser
- β Skip functionality - Skip placeholders that may not be applicable or erroneously detected
- β AI-enhanced questions - Natural, contextual questions using GPT-4o-mini
- β Batch processing - Generates all questions at once (8x faster, 89% cost reduction)
- β Smart field detection - Auto-categorizes: company, person, date, amount, address, email, phone
- β Question caching - Questions generated once, retrieved instantly
- β Works offline - No AI key required (uses deterministic fallback)
- β
State abbreviations -
DEβDelaware,CAβCalifornia - β
Date shortcuts -
today,tomorrow,yesterdayβ Full formatted dates - β
Currency formatting -
100000β$100,000 - β
Business entities -
ABC llcβABC LLC,XYZ corpβXYZ Corp.
- β Rate limiting - 50 AI questions/hour per IP (protects your API costs)
- β BYOK support - Users can bring their own OpenAI API key
- β Error handling - Graceful fallbacks at every level
- β Document validation - Detects poorly formatted documents with helpful guidance
- β Markdown chat - Proper formatting with bullets, lists, bold text
- β Typing indicators - Shows AI is "thinking"
- β Theme toggle - Light/dark mode support
- β Collapsible instructions - Clean, uncluttered interface
- Node.js 18+
- npm or yarn
npm installThe app has multiple layers of protection to prevent unexpected OpenAI bills:
- Rate Limiting: 50 AI questions per hour per IP address (when using your default key)
- Efficient Model: Uses GPT-4o-mini (~$0.0001 per question)
- Batch Processing: Generates all questions in one API call (89% cost reduction)
- Graceful Fallback: Works without AI if key is missing or rate limit exceeded
Estimated Costs with Default Key:
- Light usage (10 users/day): ~$0.50/month
- Medium usage (50 users/day): ~$2.50/month
- Heavy usage (200 users/day): ~$10/month
For AI-enhanced question generation, you have three options:
- App works perfectly with deterministic questions
- No AI features, but fully functional
- Best for: Testing, demos without AI
- Users enter their own API key in the app header
- Their key is used only for their session (never stored)
- No rate limiting applied
- Best for: Power users, enterprise customers
- Get an API key from https://platform.openai.com/api-keys
- Set usage limits in OpenAI dashboard (recommended: $10/month hard cap)
- Add to Vercel environment variables:
OPENAI_API_KEY=your_api_key_here - Rate limiting automatically protects you: 50 questions/hour per IP
- Best for: Public demos, assessor testing
π Additional Protection Steps:
-
Set OpenAI Usage Limits:
- Go to https://platform.openai.com/account/limits
- Set a hard monthly limit (e.g., $10)
- Set email alerts at 50% and 90%
-
Monitor Usage:
- Check https://platform.openai.com/usage
- Review daily/weekly usage
- Adjust rate limits if needed
-
For Public Testing:
- Use Option 3 with rate limiting
- Set OpenAI hard limit to $10-20/month
- Monitor for first few days
- Disable key if needed (app still works without it)
Note: The app works perfectly without any API key using deterministic questions.
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
- Upload - Drag & drop or select a .docx file with placeholders
- Parse - App detects placeholders like
[Company Name],$[Amount],___ - Chat - Answer questions in a conversational interface
- Normalize - Values are automatically formatted (states, dates, amounts, etc.)
- Preview - See your document update in real-time
- Download - Get your completed document with perfect formatting
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS + Material Design 3
- Document Parsing: Mammoth.js
- Document Generation: Docxtemplater
- AI: OpenAI GPT-4o-mini (optional)
- Deployment: Vercel
- Batch Processing: 8x faster than individual API calls
- Cost Efficiency: 89% reduction in API costs
- Rate Limiting: 50 AI questions/hour per IP
- Response Time: ~4 seconds for full document (vs ~18 seconds before optimization)
- Roadmap - Development phases and completed features
- Spec - Product specification and architecture
- Future Enhancements - Planned improvements
- Cost Protection - Detailed cost analysis and protection measures
For questions or issues, please open an issue on GitHub.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.