Translate any english text or sentence to luganda using this api that uses google gemini-2.0-flash
# English → Luganda Translator API
A lightweight and efficient **serverless translation API** built using **LangChain**, **Google Gemini (Generative AI)**, and **Vercel**.
It translates English text into **Luganda** through a simple POST request.
---
## Features
- **English → Luganda translation** using Google Gemini 2.0 Flash
- **Built with LangChain** prompt templates for better control
- **Serverless deployment** via Vercel
- **Secure API key management** using environment variables
- **JSON-based REST API** for easy integration with web and mobile apps
---
## Project Structure
translator-app/
│
├── api/
│ └── translator.js # Main serverless API endpoint
│
├── package.json # Project dependencies
├── .env # Environment variables (not uploaded)
├── .gitignore # Ignore node_modules, .env, etc.
└── README.md # Documentation
---
## Tech Stack
| Component | Technology |
|------------|-------------|
| Backend Runtime | Node.js |
| Framework | LangChain Core |
| AI Model | Google Gemini 2.0 Flash |
| Deployment | Vercel Serverless Functions |
| Language | JavaScript (ES Modules) |
---
## Installation & Setup
### 1 Clone the Repository
```bash
git clone
github.com
cd translator-app
```
##3 2 Install Dependencies
```bash
npm install
```
### 3 Add Environment Variables
Create a .env file in your project root:
```
GOOGLE_API_KEY=your_google_api_key_here
```
API Usage
Endpoint
```
POST /api/translator
```
Request Headers
```
{
"Content-Type": "application/json"
}
```
Request Body
```
{
"text": "Good morning, how are you?"
}
```
Example cURL Command
```
curl -X POST
translator-app.vercel.app \
-H "Content-Type: application/json" \
-d '{"text":"Good morning"}'
```
Sample Response
```
{
"success": true,
"translation": "Wasuze otya nno"
}
```
### Code Overview
The core logic uses LangChai …