neo-backend is an Express.js server that provides an API endpoint to interact with Google's Gemini generative AI model. It accepts user input and returns generated text responses using the Gemini API.
- RESTful API endpoint (
/api/generate) for text generation - Uses Google Generative AI (Gemini)
- Input validation and error handling
- CORS support
- Environment variable configuration
- Clone the repository
- Install dependencies:
npm install
- Create a
.envfile in the project root with your Gemini API key:GEMINI_API_KEY=your_google_gemini_api_key PORT=3000 # optional, defaults to 3000
- Start the server:
node express.js # or for development npx nodemon express.js
Send a POST request to /api/generate with a JSON body:
{
"input": "Your prompt here"
}Example using curl:
curl -X POST http://localhost:3000/api/generate \
-H "Content-Type: application/json" \
-d '{"input": "Hello, Gemini!"}'Response:
{
"response": "...generated text..."
}Request Body:
input(string, required): The prompt to send to Gemini.
Response:
response(string): The generated text from Gemini.
Errors:
- 400: Invalid content type, missing or invalid input
- 500: Internal server error
- express
- @google/generative-ai
- dotenv
- cors
- nodemon (dev)
ISC