Integrating Gemini models in the django & django rest framework project. Develop own chatbot using Gemini Models.
- Backend:- Django, DjagoRestFramework
- Frontend (GUI):- tkinter
- go to https://aistudio.google.com/
- Login with google account
- click Get API key
- click Create API key
- create new project/import project (if you not get any default project)
- after creating project you get your API KEY
python -m venv .venv.venv\Scripts\activatesource .venv/bin/activatepip install django djangorestframework mysqlclient
pip install google-generativeai
pip install djangorestframework-simplejwt # JWT Authenticationdjango-admin startproject gemini_chatbot_project .
django-admin startapp gemini_appINSTALLED_APPS = [
...
'gemini_app',
'rest_framework',
]DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB_NAME',
'USER': 'DB_USER',
'PASSWORD': 'DB_PASSWORD',
'HOST': 'localhost', # Or your DB host
'PORT': '3306',
}
}python manage.py makemigrations
python manage.py migratepython manage.py runserver- start development server and with that open new terminal and run
-
python gemini.py
- for tkinter GUI (for Chat)
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/register/ |
User Registration |
| POST | /api/login/ |
User Login |
| POST | /chat/ |
For Chat with Gemini |
{
"name": "demo",
"email": "demo@gmail.com",
"password": "demo@123",
}{
"email": "demo@gmail.com",
"password": "demo@123"
}{
"message": "why sky is blue?"
}