Overview
This guide will walk you through setting up the Groq Microservice on your local development environment. The service is built with Node.js and Express, using Groq’s LLM API to generate institutional document templates for Mexican government entities.Prerequisites
Before you begin, ensure you have the following installed on your system:Node.js and npm
The Groq Microservice requires Node.js version 18.x or higher. We recommend using the latest LTS version.Check your Node.js version:If you need to install or update Node.js, download it from nodejs.org or use a version manager like nvm.
Using nvm? Run
nvm install --lts to get the latest LTS version.Groq API Key
You’ll need a valid Groq API key to use this service. Sign up for a free account at console.groq.com to obtain your API key.
Installation
Clone or Download the Project
If using Git, clone the repository:Or download and extract the source code to your preferred directory.
Install Dependencies
Navigate to the project directory and install all required npm packages:This will install the following dependencies:
- express (v5.2.1) - Web application framework
- cors (v2.8.6) - Cross-Origin Resource Sharing middleware
- dotenv (v17.2.4) - Environment variable management
- nodemon (v3.1.11) - Auto-restart server during development
Configure Environment Variables
Create a Add your configuration to the
.env file in the project root directory:.env file:.env
Environment Variable Details
Environment Variable Details
- GROQ_API_KEY (required): Your Groq API authentication key
- PORT (optional): Server port, defaults to 5055 if not specified
Project Structure
After installation, your project structure should look like this:Testing Your Setup
Once the server is running, test the API endpoint:Available Scripts
The project includes the following npm scripts:npm run dev
npm run dev
Starts the development server with nodemon for auto-reloading:Use this during development when you’re actively making changes to the code.
npm start
npm start
Starts the production server without auto-reloading:Use this for production deployments or when auto-restart is not needed.
Troubleshooting
Port Already in Use
Port Already in Use
If you see an error about port 5055 being in use:
-
Change the PORT in your
.envfile: -
Or kill the process using port 5055:
Missing GROQ_API_KEY
Missing GROQ_API_KEY
If the server starts but API calls fail, verify:
- Your
.envfile exists in the project root - The
GROQ_API_KEYvariable is set - There are no extra spaces or quotes around the key
- The key is valid in the Groq console
Module Not Found Errors
Module Not Found Errors
If you see
Cannot find module errors:ES Modules Issues
ES Modules Issues
This project uses ES modules (import/export). Ensure your Node.js version is 18+. If you need to use CommonJS:
- Remove
"type": "module"from package.json (if present) - Change imports to require statements in server.js
Next Steps
Now that your development environment is set up:- Read the Configuration Guide to learn about customizing the system prompt and settings
- Explore the Deployment Guide when you’re ready to deploy to production
- Check the API Reference for detailed endpoint documentation
Remember to restart the server after making changes to the
.env file or server.js.