Prerequisites
Before you begin, make sure you have:- Node.js 18 or higher installed
- A Groq API key (get one free at console.groq.com)
Clone and Install Dependencies
First, clone the repository and install the required dependencies:The service uses three main dependencies:
express- Web framework for the API servercors- Cross-origin resource sharing middlewaredotenv- Environment variable management
Configure Environment Variables
Create a
.env file in the project root with your Groq API key:.env
The
PORT variable is optional and defaults to 5055 if not specified.Start the Server
Launch the development server:You should see:The service is now running and ready to accept requests!
Make Your First API Request
Test the service by generating a document template. The API endpoint is:Here’s a complete example using curl:
curl
Understanding the Response
The API returns a JSON response with the generated template:The generated template includes:
Response
- Institutional header with municipality information
- Subject line (ASUNTO) describing the document purpose
- Place and date variables in
{{Variable}}format - Body content with relevant context and requirements
- Formal closing with signature block
- Carbon copy (C.c.p.) section for distribution
Request Parameters
The/api/generate-template endpoint accepts the following JSON body parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Description of the document template you want to generate (in Spanish) |
area | string | No | The department or area requesting the document (e.g., “Recursos Humanos”, “Finanzas”) |
Example Use Cases
Office Supply Request
Meeting Invitation
Authorization Letter
Budget Request
Variable Format
All generated templates use the{{Variable}} format with double curly braces. This format is compatible with most template engines and makes it easy to identify fields that need to be filled in:
{{Lugar}}- Municipality or location{{Fecha}}- Date{{Destinatario}}- Recipient name{{Cargo}}- Position/title{{Area}}- Department name- Custom variables based on your prompt
The service is configured to only return template text without explanations. You receive clean, ready-to-use document templates.
Error Handling
The API returns appropriate HTTP status codes:| Status Code | Description |
|---|---|
200 | Success - template generated |
400 | Bad request - missing or invalid prompt parameter |
500 | Server error - internal processing error |
502 | Bad gateway - Groq API error |
Error Response
Next Steps
API Reference
Explore detailed API documentation and advanced options
Configuration
Learn about customization and configuration options
Deployment
Deploy your service to production
Setup Guide
Complete setup and installation guide