This is a conversational AI agent API designed to teach languages. It uses OpenAI's GPT-4o-mini model to provide a teaching experience tailored to the user's difficulty level.
- Conversational teaching.
- Supports
beginner,intermediate, andadvanceddifficulty levels. - User can specify their native language and the target language.
- Built with TypeScript, Express, and OpenAI.
- Node.js
- OpenAI API Key
- Clone the repository.
- Install dependencies:
npm install
- Create a
.envfile based on.env.exampleand add yourOPENAI_API_KEY. - Start the development server:
npm run dev
You can deploy this API on Render either manually or by using the render.yaml file (Blueprints).
- Sign Up/Login: Go to Render.com and sign up or login.
- New Web Service: Click the "New +" button and select "Web Service".
- Connect Repo: Connect your GitHub repository.
- Configure:
- Runtime: Node
- Build Command:
npm install && npm run build - Start Command:
npm start
- Environment Variables:
- Scroll down to the "Environment Variables" section.
- Add
OPENAI_API_KEYwith your OpenAI API key. - Render sets the
PORTvariable automatically, or you can set it to 3000.
- Deploy: Click "Create Web Service". Render will build and deploy your API.
- In the Render Dashboard, click "New +" and select "Blueprint".
- Connect your repository.
- Render will detect the
render.yamlfile. - Click "Apply" and provide the
OPENAI_API_KEYwhen prompted.
Endpoint: POST /api/chat
Request Body:
{
"nativeLanguage": "English",
"targetLanguage": "Spanish",
"difficulty": "beginner",
"messages": [
{
"role": "user",
"content": "Hola!"
}
]
}Example Curl Command:
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{
"nativeLanguage": "English",
"targetLanguage": "Spanish",
"difficulty": "beginner",
"messages": [
{ "role": "user", "content": "How do I say hello?" }
]
}'Response:
{
"response": "To say 'hello' in Spanish, you can say 'Hola'. It's a common greeting used in almost any situation!"
}