Overview
The Groq Microservice is designed to be simple yet flexible. This guide covers all configuration options, from environment variables to customizing the AI system prompt for your specific institutional needs.Environment Variables
The service uses environment variables stored in a.env file at the project root. These variables control authentication, server behavior, and operational settings.
Required Variables
GROQ_API_KEY
GROQ_API_KEY
Type: Where to get it:
string (required)Your Groq API authentication key for accessing the LLM API..env
- Sign up at console.groq.com
- Navigate to API Keys section
- Create a new API key
- Copy the key immediately (it won’t be shown again)
- Store this key securely
- Rotate keys periodically
- Use different keys for development and production
- Never expose in client-side code or logs
server.js:33
Optional Variables
PORT
PORT
Type: Common port configurations:
number (optional)Default: 5055The port number on which the Express server will listen for incoming requests..env
- Development:
5055(default) - Production:
80(HTTP),443(HTTPS), or3000 - Docker: Use environment variable passed at runtime
server.js:56-58
System Prompt Customization
ThebuildSystem() function defines the AI’s behavior and output format. This is the core of the document generation logic and is highly customizable.
Default System Prompt
The default prompt is optimized for Mexican government institutional documents:server.js:9-16
Understanding the Prompt Components
Identity and Role
- Change “Ayuntamiento” to your specific institution type (Secretaría, Dirección, etc.)
- Modify country/region for different administrative contexts
- Adjust formality level (formal, semi-formal)
Output Format Control
This prevents the AI from adding “Here’s the template:” or “I’ve created…” prefixes.
Document Structure Requirements
- encabezado institucional: Institutional header
- ASUNTO: Subject line
- lugar y fecha: Location and date
- cuerpo: Main body content
- cierre: Closing statement
- ATENTAMENTE: Formal signature block
- firma: Signature line
- C.c.p.: Carbon copy recipients
Variable Formatting Rules
{{Variable}} instead of other formats.Why this matters:- Enables easy template variable replacement
- Compatible with common templating engines (Handlebars, Mustache)
- Prevents ambiguity with other bracket types
{{NombreCompleto}}{{Cargo}}{{Dependencia}}{{FechaActual}}
Customization Examples
LLM Model Configuration
The service uses Groq’s LLM API with configurable model and parameters.Current Configuration
server.js:36-40
Model Options
llama-3.1-8b-instant (Default)
llama-3.1-8b-instant (Default)
Characteristics:
- Fast response times (< 1 second)
- Lower cost per request
- Good for straightforward template generation
- 8 billion parameters
- High-volume production environments
- Standard document templates
- Cost-sensitive deployments
- Real-time user-facing applications
llama-3.3-70b-versatile (Alternative)
llama-3.3-70b-versatile (Alternative)
Characteristics:
- Higher quality outputs
- Better understanding of complex requests
- Slightly slower response times
- 70 billion parameters
- Complex document requirements
- Higher quality expectations
- Lower request volumes
- When response time is less critical
server.js:36
Temperature Setting
server.js:39
0.4 (range: 0.0 - 2.0)
- Current (0.4): Balanced between consistency and creativity
- Lower (0.1-0.3): More deterministic, conservative outputs
- Higher (0.6-0.9): More creative, varied responses
For institutional documents, we recommend keeping temperature between 0.2-0.5 to maintain professional consistency.
Request Configuration
The API endpoint accepts requests with specific structure:server.js:25-28
Customizing User Message Format
You can modify how user input is formatted before sending to the LLM:Middleware Configuration
The service includes middleware for CORS and JSON parsing:CORS Configuration
server.js:6
JSON Body Parsing
server.js:7
1mb - Maximum request body size
Error Handling Configuration
The endpoint includes comprehensive error handling:server.js:19-54
Custom Error Messages
You can customize error responses:Environment-Specific Configuration
Create multiple environment files for different deployments:Next Steps
- Learn about Deployment strategies for production
- Explore the API Reference for endpoint details
- Review Setup Guide for installation instructions