A tsundere AI companion powered by the Gemini API. She remembers your conversations, reacts emotionally, and never admits she cares.
- Emotion system — affection and mood shift based on what you say
- Memory — keeps track of the last 20 messages for context
- Gemini backend — powered by Google AI Studio (free tier)
- REST API — built with FastAPI
ai_waifu/
├── app/
│ ├── main.py # FastAPI app and routes
│ ├── core/
│ │ ├── llm.py # Gemini API integration
│ │ ├── emotion.py # Emotion state logic
│ │ ├── memory.py # Conversation memory
│ │ └── prompt.py # Prompt builder
│ └── models/
│ └── shema.py # Request schemas
├── config.py # Centralized config (API key, model name)
├── requirements.txt
└── .env.example
- Python 3.11+
- A Google AI Studio API key → aistudio.google.com/app/apikey
# Clone the repo
git clone <repo-url>
cd ai_waifu
# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # macOS / Linux
# Install dependencies
pip install -r requirements.txtcp .env.example .envEdit .env and fill in your API key:
GEMINI_API_KEY=your_api_key_here
config.py centralizes all app settings. You can change the model here without touching any other files:
class Config:
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
MODEL_NAME = "gemini-3.1-flash-lite" # Change this to switch modelsuvicorn app.main:app --reloadAPI is available at http://127.0.0.1:8000
Interactive docs at http://127.0.0.1:8000/docs
Send a message and get a response from Aki.
Request
{
"message": "你好"
}Response
{
"reply": "……你突然說這個幹嘛。",
"emotion": {
"affection": 50,
"mood": "neutral"
}
}