A lightweight AI chatbot built with FastAPI and the OpenAI API.
This project demonstrates how to build and run a simple AI-powered backend with a minimal web interface.
- FastAPI backend
- Simple browser-based UI
- OpenAI-powered responses
- Clean and minimal setup
- Easy to extend (chat history, RAG, etc.)
simple-chatbot/
├── app.py
├── requirements.txt
├── .env.example
├── .gitignore
└── README.md
- Python 3.10+
- OpenAI API key
git clone https://github.com/pydev-y/simple-chatbot
cd simple-chatbotWindows
python -m venv envLinux / macOS
python3 -m venv envWindows
env\Scripts\activateLinux / macOS
source env/bin/activatepip install -r requirements.txtCreate a .env file in the root directory.
Example:
OPENAI_API_KEY=your_api_key_here
OPENAI_MODEL=gpt-4o-miniDo not upload your
.envfile to GitHub.
uvicorn app:app --reloadOpen in browser:
http://127.0.0.1:8000
POST /chat
http://127.0.0.1:8000/chat?message=Hello
Missing API key
- Ensure
.envfile exists - Ensure
OPENAI_API_KEYis set correctly
Module not found
- Activate virtual environment
- Run
pip install -r requirements.txt
Port already in use
uvicorn app:app --reload --port 8001- Chat history
- Streaming responses
- Custom system prompts
- RAG (document-based chatbot)
- Database integration
- UI improvements
This project is open-source and available for learning and experimentation.
- Email: mystt06@gmail.com
- telegram: @yusuf_py