A powerful npm package for generating professional sales proposals and legal agreements using OpenAI's GPT-5 Nano API with support for both PDF and DOC formats.
- 🚀 Proposal Generation: Create compelling sales proposals with AI assistance
- ⚖️ Agreement Generation: Generate comprehensive legal agreements between parties
- đź“„ PDF Generation: Convert proposals and agreements to professional PDF documents
- 📝 DOC Generation: Convert proposals and agreements to Microsoft Word (.docx) documents
- 🤖 AI-Powered: Uses OpenAI's latest GPT-5 Nano for high-quality content generation
- 📝 Customizable: Add extra details and context for tailored outputs
- đź”’ Secure: Pass your own API key for complete control
- 📦 Lightweight: Minimal dependencies, easy to integrate
- 🆕 Latest Model: Leverages GPT-5 Nano for improved performance and accuracy
- 🔄 Dual Format: Generate documents in both PDF and DOC formats simultaneously
npm install triostack-document-sdk
import {
generateProposal,
generateAgreement,
generateProposalPDF,
generateProposalDOC,
generateAgreementPDF,
generateAgreementDOC
} from 'triostack-document-sdk';
// Your OpenAI API key
const apiKey = 'your-openai-api-key-here';
// Generate a proposal
const proposal = await generateProposal(
apiKey,
'E-commerce platform development with advanced analytics',
'Acme Corp Website Redesign',
'$50,000',
'Client needs improved conversion rates and mobile optimization'
);
// Generate an agreement
const agreement = await generateAgreement(
apiKey,
'Web application development project',
'TechCorp Mobile App',
'$75,000',
'TechCorp Inc., 123 Business St, New York, NY',
'DevStudio LLC, 456 Tech Ave, San Francisco, CA',
'Project includes backend API, mobile app, and 6 months of support'
);
// Generate PDF versions
const proposalPDF = await generateProposalPDF(apiKey, details, name, pricing, extra);
const agreementPDF = await generateAgreementPDF(apiKey, details, name, pricing, partyA, partyB, extra);
// Generate DOC versions
const proposalDOC = await generateProposalDOC(apiKey, details, name, pricing, extra);
const agreementDOC = await generateAgreementDOC(apiKey, details, name, pricing, partyA, partyB, extra);
Generates a professional sales proposal.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationextraDetails
(string, optional): Additional context for the AI
Returns: Promise - Generated proposal content
Example:
const proposal = await generateProposal(
'sk-your-api-key',
'Custom CRM system with advanced reporting and mobile app',
'Enterprise CRM Solution',
'$25,000 - $35,000',
'Client is a growing startup with 50+ employees. Need scalable solution.'
);
Generates a comprehensive legal agreement between two parties.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationpartyA
(string): Information about Party A (name, details, etc.)partyB
(string): Information about Party B (name, details, etc.)extraDetails
(string, optional): Additional context for the AI
Returns: Promise - Generated agreement content
Example:
const agreement = await generateAgreement(
'sk-your-api-key',
'Software development and maintenance services',
'Cloud Platform Development',
'$100,000 with milestone payments',
'Acme Corporation, 123 Main St, New York, NY 10001',
'TechSolutions Inc., 456 Innovation Dr, Austin, TX 78701',
'Project includes 12 months of development and 24 months of support'
);
Generates a professional sales proposal and converts it to PDF format.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationextraDetails
(string, optional): Additional context for the AIfilename
(string, optional): Name for the PDF file (without .pdf extension)
Returns: Promise - PDF as Uint8Array buffer
Example:
const proposalPDF = await generateProposalPDF(
'sk-your-api-key',
'Custom CRM system with advanced reporting and mobile app',
'Enterprise CRM Solution',
'$25,000 - $35,000',
'Client is a growing startup with 50+ employees. Need scalable solution.',
'enterprise-crm-proposal'
);
// Save PDF to file
fs.writeFileSync('proposal.pdf', Buffer.from(proposalPDF));
Generates a professional sales proposal and converts it to Microsoft Word (.docx) format.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationextraDetails
(string, optional): Additional context for the AIfilename
(string, optional): Name for the DOC file (without .docx extension)
Returns: Promise - DOC as Uint8Array buffer
Example:
const proposalDOC = await generateProposalDOC(
'sk-your-api-key',
'Custom CRM system with advanced reporting and mobile app',
'Enterprise CRM Solution',
'$25,000 - $35,000',
'Client is a growing startup with 50+ employees. Need scalable solution.',
'enterprise-crm-proposal'
);
// Save DOC to file
fs.writeFileSync('proposal.docx', Buffer.from(proposalDOC));
generateAgreementPDF(apiKey, projectDetails, projectName, pricing, partyA, partyB, extraDetails?, filename?)
Generates a comprehensive legal agreement and converts it to PDF format.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationpartyA
(string): Information about Party A (name, details, etc.)partyB
(string): Information about Party B (name, details, etc.)extraDetails
(string, optional): Additional context for the AIfilename
(string, optional): Name for the PDF file (without .pdf extension)
Returns: Promise - PDF as Uint8Array buffer
Example:
const agreementPDF = await generateAgreementPDF(
'sk-your-api-key',
'Software development and maintenance services',
'Cloud Platform Development',
'$100,000 with milestone payments',
'Acme Corporation, 123 Main St, New York, NY 10001',
'TechSolutions Inc., 456 Innovation Dr, Austin, TX 78701',
'Project includes 12 months of development and 24 months of support',
'cloud-platform-agreement'
);
// Save PDF to file
fs.writeFileSync('agreement.pdf', Buffer.from(agreementPDF));
generateAgreementDOC(apiKey, projectDetails, projectName, pricing, partyA, partyB, extraDetails?, filename?)
Generates a comprehensive legal agreement and converts it to Microsoft Word (.docx) format.
Parameters:
apiKey
(string): Your OpenAI API keyprojectDetails
(string): Detailed description of the projectprojectName
(string): Name of the projectpricing
(string): Pricing informationpartyA
(string): Information about Party A (name, details, etc.)partyB
(string): Information about Party B (name, details, etc.)extraDetails
(string, optional): Additional context for the AIfilename
(string, optional): Name for the DOC file (without .docx extension)
Returns: Promise - DOC as Uint8Array buffer
Example:
const agreementDOC = await generateAgreementDOC(
'sk-your-api-key',
'Software development and maintenance services',
'Cloud Platform Development',
'$100,000 with milestone payments',
'Acme Corporation, 123 Main St, New York, NY 10001',
'TechSolutions Inc., 456 Innovation Dr, Austin, TX 78701',
'Project includes 12 months of development and 24 months of support',
'cloud-platform-agreement'
);
// Save DOC to file
fs.writeFileSync('agreement.docx', Buffer.from(agreementDOC));
- Warm introduction
- Key benefits tailored to the project
- Clear next steps
- Professional formatting with clear sections
- Compelling call-to-action
- Clear identification of both parties
- Project scope and deliverables
- Terms and conditions
- Payment terms and schedule
- Timeline and milestones
- Intellectual property rights
- Confidentiality clauses
- Termination conditions
- Legal jurisdiction
The package includes comprehensive error handling:
try {
const proposal = await generateProposal(apiKey, details, name, pricing);
console.log(proposal);
} catch (error) {
console.error('Generation failed:', error.message);
}
While the package doesn't require .env
files, you can use them in your application:
# .env
OPENAI_API_KEY=your-api-key-here
import dotenv from 'dotenv';
dotenv.config();
const proposal = await generateProposal(
process.env.OPENAI_API_KEY,
// ... other parameters
);
- Node.js 16+ (ES modules support)
- OpenAI API key with GPT-5 Nano access
- Internet connection for API calls
This package uses OpenAI's latest GPT-5 Nano model, which provides:
- Improved Performance: Better understanding and generation of business documents
- Enhanced Accuracy: More precise legal and business terminology
- Faster Response: Optimized for quick document generation
- Cost Effective: Efficient pricing for business applications
The package includes built-in document generation capabilities for both PDF and DOC formats:
- Direct PDF Creation: Convert AI-generated content to professional PDFs
- Customizable Formatting: Professional layout with proper margins and typography
- Multi-page Support: Automatic page breaks for long documents
- File Management: Generate PDFs with custom filenames
- Buffer Output: Get PDF as Uint8Array for flexible file handling
PDF Features:
- A4 page format with proper margins
- Professional typography and spacing
- Automatic page breaks for long content
- Clean, business-ready formatting
- Microsoft Word Format: Generate .docx files compatible with Word, Google Docs, and other editors
- Professional Styling: Proper headings, paragraphs, and formatting
- Customizable Layout: Professional document structure with titles and sections
- Cross-Platform: Works on Windows, Mac, and Linux
- Buffer Output: Get DOC as Uint8Array for flexible file handling
DOC Features:
- Professional document structure with headings
- Proper paragraph spacing and formatting
- Microsoft Word compatible (.docx format)
- Clean, editable business documents
The package includes several example files to help you get started:
Basic examples for generating proposals and agreements as text.
Examples for generating PDF documents.
Examples for generating documents in both PDF and DOC formats simultaneously.
Run the examples:
# Generate PDFs only
node example-pdf.js
# Generate both PDF and DOC formats
node example-both-formats.js
openai
: Official OpenAI Node.js client (supports GPT-5 Nano)jspdf
: PDF generation library for Node.js (fixed constructor issue)docx
: Microsoft Word document generation librarydotenv
: Environment variable management (optional)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Create an issue on GitHub
- Check the documentation
- Review the examples
This package generates content using AI. While the content is professional and well-structured, it's recommended to have legal professionals review any agreements before use in business transactions.
Note: The generated content is for informational purposes only and should not be considered as legal advice.