A simple Express.js backend server that connects to Groq API (llama-3.3-70b-versatile) for ultra-fast, terminal-based code generation.
- Groq API Integration: Uses the fast Llama 3 models.
- Client Script:
ask.jshandles output formatting and prevents truncation in PowerShell. - File Download Support: Support for saving generated code to a file via Vercel or local server.
- Vercel Ready: Includes configuration for easy deployment.
-
Install dependencies:
npm install
-
Configure API key:
- Create
.envfile - Add your Groq API key:
GROQ_API_KEY=your_groq_api_key - Create
-
Start the server:
npm start
Use the included ask.js script to get clean, full output:
node ask.js "write a factorial function in python"To download the generated code to a file:
Git Bash / Mac / Linux:
curl -OJ "https://your-app.vercel.app/ask?q=write%20function&filename=code.py"Windows PowerShell:
Use curl.exe explicitly to avoid the PowerShell alias:
curl.exe -OJ "https://your-app.vercel.app/ask?q=write%20function&filename=code.py"Or use the PowerShell native command:
Invoke-WebRequest "https://your-app.vercel.app/ask?q=write%20function&filename=code.py" -OutFile "code.py"- Push this repository to GitHub.
- Import the project into Vercel.
- Add the environment variable
GROQ_API_KEYin Vercel project settings. - Redeploy.
GET /ask?q=question- Returns plain text answer.GET /ask?q=question&filename=file.ext- Downloads the answer as a file.