A fun web app that generates jokes using Google's Gemini AI.
-
Install dependencies:
npm install
-
Get a Gemini API key from Google AI Studio
-
Set the environment variable:
- For local development: Create a
.envfile withGEMINI_API_KEY=your_key_here - For deployment: Add
GEMINI_API_KEYto your platform's environment variables (Vercel, Netlify, etc.)
- For local development: Create a
-
The serverless function at
/api/joke.jshandles all API calls securely, keeping your API key server-side only.
Run the development server locally:
npm run devThis will start a local server at http://localhost:3000 that serves your static files and handles the /api/joke endpoint, allowing you to test the Gemini API integration locally.
Make sure you have a .env file in the root directory with:
GEMINI_API_KEY=your_api_key_here
This project uses serverless functions. The API endpoint is located at /api/joke.js and works with:
- Vercel (automatic detection)
- Netlify (may need
netlify.tomlconfiguration) - Other serverless platforms
Make sure to set the GEMINI_API_KEY environment variable in your deployment platform.