This is the backend server for the ZAP Labs AI-Powered Interview Training Platform. It proxies requests to the Grok API to ensure secure handling of API keys and proper rate limiting.
- Node.js 14+
- Grok API key
- Clone this repository
- Install dependencies:
npm install - Create a
.envfile based on.env.exampleand add your Grok API key - Start the development server:
npm run dev
-
Install the Vercel CLI:
npm install -g vercel -
Login to Vercel:
vercel login -
Deploy:
vercel -
Add environment variables in the Vercel dashboard:
- Go to your project settings
- Navigate to the "Environment Variables" section
- Add
GROK_API_KEYwith your Grok API key
-
For production deployment:
vercel --prod
-
Install the Heroku CLI and login:
npm install -g heroku heroku login -
Create a new Heroku app:
heroku create zap-labs-backend -
Set your environment variables:
heroku config:set GROK_API_KEY=your_grok_api_key_here -
Deploy:
git push heroku main
GET /- Response:
{ status: 'ok', message: 'ZAP Labs API server is running' }
- Response:
POST /api/grok- Request body:
{ "prompt": "Your prompt text here", "options": { "model": "grok-beta", "max_tokens": 500, "temperature": 0.7 } } - Response:
{ "success": true, "data": "Response from Grok API" }
- Request body:
- CORS protection
- Rate limiting (60 requests per minute)
- Automatic retry logic with exponential backoff for rate-limited requests
- Security headers
- Environment variable protection for API keys