Skip to main content
Get your Groq-powered document template generator running locally in minutes. This guide will walk you through installation, configuration, and making your first API request.

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)
1

Clone and Install Dependencies

First, clone the repository and install the required dependencies:
npm install
The service uses three main dependencies:
  • express - Web framework for the API server
  • cors - Cross-origin resource sharing middleware
  • dotenv - Environment variable management
2

Configure Environment Variables

Create a .env file in the project root with your Groq API key:
.env
GROQ_API_KEY=your_groq_api_key_here
PORT=5055
The PORT variable is optional and defaults to 5055 if not specified.
Never commit your .env file to version control. Your Groq API key should remain secret.
3

Start the Server

Launch the development server:
npm run dev
You should see:
Groq micro corriendo en http://localhost:5055
The service is now running and ready to accept requests!
4

Make Your First API Request

Test the service by generating a document template. The API endpoint is:
POST /api/generate-template
Here’s a complete example using curl:
curl
curl -X POST http://localhost:5055/api/generate-template \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Crear un oficio para solicitar material de oficina",
    "area": "Recursos Humanos"
  }'
The area field is optional but helps provide context for better template generation.
5

Understanding the Response

The API returns a JSON response with the generated template:
Response
{
  "text": "AYUNTAMIENTO MUNICIPAL\n\nASUNTO: Solicitud de Material de Oficina\n\n{{Lugar}}, {{Fecha}}\n\n{{Destinatario}}\n{{Cargo}}\nPresente\n\nPor medio del presente, el Departamento de {{Area}} solicita de su amable apoyo para la requisición del siguiente material de oficina:\n\n{{ListaMateriales}}\n\nLo anterior con el fin de continuar con las actividades cotidianas del departamento de manera eficiente.\n\nAgradeciendo de antemano su atención y apoyo, quedo de usted.\n\nATENTAMENTE\n\n{{Nombre}}\n{{Cargo}}\nDepartamento de {{Area}}\n\nC.c.p. {{CopiaConocimiento}}"
}
The generated template includes:
  • 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:
ParameterTypeRequiredDescription
promptstringYesDescription of the document template you want to generate (in Spanish)
areastringNoThe department or area requesting the document (e.g., “Recursos Humanos”, “Finanzas”)

Example Use Cases

Office Supply Request

{
  "prompt": "Oficio para solicitar papelería",
  "area": "Administración"
}

Meeting Invitation

{
  "prompt": "Invitación a reunión de cabildo",
  "area": "Secretaría"
}

Authorization Letter

{
  "prompt": "Carta de autorización para evento público",
  "area": "Eventos Especiales"
}

Budget Request

{
  "prompt": "Solicitud de presupuesto para proyecto",
  "area": "Finanzas"
}

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 CodeDescription
200Success - template generated
400Bad request - missing or invalid prompt parameter
500Server error - internal processing error
502Bad gateway - Groq API error
Example error response:
Error Response
{
  "error": "prompt es requerido"
}

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

Build docs developers (and LLMs) love