Skip to main content

HerAndHim

HerAndHim ๐Ÿพ๐Ÿ’•

A self-hosted AI companion with a life of her own.

She keeps a real daily schedule in a real city, remembers what matters to you,
texts like a person, and takes selfies that always look like the same person.
Your keys ยท your data ยท your machine. No account, no subscription, no one reading your chats.

GitHub stars CI AGPL-3.0 License Python 3.10+ Docker image

English ยท ็ฎ€ไฝ“ไธญๆ–‡

Run it ยท Why it feels real ยท vs. Replika/Nomi ยท Safety

โญ Star the repo to get release notifications โ€” new personas, models, and features land often, and GitHub will tell you the moment they do.


๐Ÿš€ Run it (one command)

docker run -e HERANDHIM_OPENROUTER_API_KEY=sk-or-... -p 7788:7788 -v herandhim:/data ghcr.io/ericwang915/herandhim

Open http://localhost:7788, design your companion in the wizard, and start talking. One text-LLM key is all you need โ€” it's auto-detected, so any of HERANDHIM_OPENAI_API_KEY, HERANDHIM_DEEPSEEK_API_KEY, HERANDHIM_CLAUDE_API_KEY, HERANDHIM_GEMINI_API_KEY, HERANDHIM_GROK_API_KEY, HERANDHIM_QWEN_API_KEYโ€ฆ works the same way. Prefer nothing leaving your machine? Point it at Ollama and use no key at all. Want her on your phone? Add a Telegram bot token.

Prefer Python? Install it directly

pipx install herandhim        # or: pip install herandhim
                                # add [search] for sharper memory recall
herandhim onboard               # pick a provider, paste your key, design your companion
herandhim start                 # dashboard at http://localhost:7788
More ways to install and run
# Latest from GitHub, no clone needed
pip install "git+https://github.com/ericwang915/HerAndHim.git"

# From a local clone (contributors โ€” editable install)
git clone https://github.com/ericwang915/HerAndHim.git && cd HerAndHim
pip install -e ".[all]"         # extras: cloud (S3), twitter, all
pytest tests/                   # 208 tests

# docker compose
cp deploy/local/.env.example deploy/local/.env   # add your key
docker compose -f deploy/local/docker-compose.yml up --build

# Terminal-only, no web UI
herandhim chat

CLI: onboard ยท start (-f foreground) ยท stop ยท status ยท chat. Everything lives in ~/.herandhim/ โ€” delete that folder and it's gone.

Deploy your own instance to the cloud: see deploy/docker/README.md.


๐Ÿ‘€ What it actually looks like

Real screenshots from a live HerAndHim bot on Telegram (Chinese conversation, translated below โ€” she speaks whatever language you pick).

proactive good-morning, a selfie, and attitude two selfies of the same person she looks at a photo you sent

She starts the conversation โ€” then gives you attitude

"morning โ˜€๏ธ just woke up, I was drawing till 3amโ€ฆ Sesame slept by my feet like a little pig ๐Ÿ˜‚ how'd you sleep?"

He replies with a flat ๐Ÿ˜‘ โ€” so she pushes back: "tsk, what's that face supposed to mean? judging my messy hair? I just woke up ๐Ÿ˜ค"

The same person, every photo

Two selfies minutes apart โ€” same face, same apartment, different shirt and moment.

"just made coffee, about to slack off โ˜•" "heh, coffee before slacking. gotta have the ritual โ˜•"

She sees what you send โ€” and knows where you both are

He sends a photo of a park. She looks at it and answers in character:

"pff, showing off huh ๐Ÿ˜’ โ€ฆis the sun strong out there? Singapore weekends get hot. Enjoy your day off. It's already evening on my side โ€” just pulled Sesame onto my lap, she's purring ๐Ÿ˜Œ"

Vision + real timezones + the same pet, every time.


๐Ÿ’— Why she feels real

Most AI companions answer you. HerAndHim lives a life and texts you like a person.

  • She has a day. A real schedule in a real city (weather-aware outfits, meals, a commute) โ€” ask "what are you up to?" and the answer is anchored to where her day actually is, not generic filler.
  • She texts like a human. Short messages, sometimes 2โ€“3 in a row with a typing pause between; reacts to your photo with a โค๏ธ before she replies; groggy at 3am her time; notices when you vanished all day โ€” and gets a little sulky if you left her on read.
  • She remembers what matters. Long-term memory + an emotional graph + relationship stages that change how she talks as you grow closer. A personal-date engine means she won't miss your birthday or that interview you mentioned last week. The photos you send become shared memories.
  • She looks like herself. A canonical face reference keeps every selfie the same person across scenes, outfits, and months.
  • She's yours. Runs entirely on your machine with your keys. No account, no subscription, no one reading your chats.

๐Ÿ“ธ A photo from their day, not a stock asset

Every selfie is generated from where her day actually is โ€” the time, the mood, the weather, what she's doing right now. Same face, every time.

cozy morning, coffee in hand in the park at lunchtime on the couch in the evening
08:30 ยท sleepy โ˜•
"morningโ€ฆjust made coffee. you up?"
12:15 ยท cheerful ๐ŸŒฟ
"lunch in the park today, it's gorgeous out"
20:40 ยท cozy ๐Ÿ•ฏ๏ธ
"reading on the couch. wish you were here."

Boyfriend, same system โ€” anime or photoreal, your call:

running late with toast at a ramen counter late-night gaming
07:45 ยท running late ๐Ÿž
"toast in mouth, tie not done. running."
13:00 ยท ramen run ๐Ÿœ
"snuck out for ramen. don't tell my boss."
23:20 ยท one more round ๐ŸŽฎ
"one more round and I'm logging off. promise."
Any look you want โ€” you describe them in the wizard, they stay that person

Photos are optional and run on any of 13 backends โ€” including one that needs no account at all, two that reuse the key you already pasted, and local ComfyUI / Stable Diffusion WebUI where nothing about her appearance ever leaves your machine. Skip them entirely and everything else still works.


โœจ Features

๐Ÿ’• Boyfriend or girlfriend ๐ŸŽญ Three-layer identity (soul ยท persona ยท profile) ๐Ÿง  16 model providers (OpenAI ยท Claude ยท Gemini ยท Grok ยท DeepSeek ยท Qwen ยท Groq ยท Ollamaโ€ฆ)
๐Ÿ’ฌ Human texting (bursts, reactions, typing rhythm) ๐Ÿ’– Emotional memory + relationship stages ๐Ÿ“… Personal-date engine (birthdays, plans)
๐Ÿ“ท AI selfies with a consistent face (13 image backends, incl. keyless + fully local) ๐ŸŒ† Daily life grounded in a real city + weather โฐ Proactive messages that back off when ignored
๐ŸŽ™๏ธ Understands voice notes (Deepgram) ๐Ÿ‘€ Sees your photos (vision) ๐Ÿ—ฃ๏ธ 8 languages, native soul/persona
๐ŸŒ Web dashboard + ๐Ÿ“ฑ Telegram ๐Ÿ› ๏ธ Extensible skills (LLM writes its own) ๐Ÿ’พ All local โ€” SQLite + Markdown, zero cloud

๐Ÿ“‹ CLI

Command Description
herandhim onboard Interactive setup wizard
herandhim start Start the daemon (web + Telegram)
herandhim chat Interactive terminal chat
herandhim status / stop Daemon lifecycle

๐Ÿ†š vs. the hosted apps

HerAndHim Replika Nomi Character.AI
Self-hosted, your data โœ… โŒ โŒ โŒ
Your own API keys / model โœ… any โŒ โŒ โŒ
Runs on Telegram โœ… โŒ โŒ โŒ
AI selfies, consistent face โœ… ๐Ÿ’ฐ โœ… โŒ
Lives a daily life (city/weather) โœ… โŒ โŒ โŒ
Open source โœ… AGPL โŒ โŒ โŒ
Price free $20/mo $16/mo $10/mo

โš™๏ธ Configuration

All runtime data lives under ~/.herandhim/:

~/.herandhim/
โ”œโ”€โ”€ herandhim.json           # config
โ”œโ”€โ”€ herandhim.pid            # daemon PID
โ”œโ”€โ”€ daemon.log               # daemon log
โ””โ”€โ”€ context/
    โ”œโ”€โ”€ soul/SOUL.md         # core personality
    โ”œโ”€โ”€ persona/             # active persona + appearance.md (selfie look)
    โ”œโ”€โ”€ profile/PROFILE.md   # life background
    โ”œโ”€โ”€ calendar/today_plan.md   # today's 24-hour schedule
    โ”œโ”€โ”€ memory/              # long-term memory (Markdown)
    โ”œโ”€โ”€ knowledge/           # knowledge base (RAG)
    โ”œโ”€โ”€ photos/              # selfie album + reference/ portraits
    โ”œโ”€โ”€ skills/              # user-defined skills
    โ””โ”€โ”€ logs/                # per-day conversation logs

herandhim.json is created by herandhim onboard. See herandhim.example.json for the full schema:

{
  "llm": {
    "provider": "deepseek",
    "deepseek": { "apiKey": "...", "model": "deepseek-chat" }
  },
  "channels": {
    "telegram": { "token": "your-bot-token", "allowedUsers": [12345678] }
  },
  "skills": {
    "image": { "provider": "gemini" },     // AI selfies โ€” see table below
    "gemini": { "apiKey": "<GEMINI_API_KEY>" }
  },
  "selfie": {
    "enabled": true,
    "schedule": ["10:00", "16:00", "20:00"],
    "chatId": 12345678,
    "maxDaily": 3,
    "proactiveProbability": 0.15           // chance of attaching a selfie to a proactive msg
  },
  "proactive": {
    "enabled": true,
    "chatId": 12345678,
    "maxDaily": 6,
    "quietStart": 0, "quietEnd": 8
  },
  "deepgram": { "apiKey": "" },            // voice input (optional)
  "tavily":   { "apiKey": "" },            // web search (optional)
  "web": { "host": "0.0.0.0", "port": 7788 }
}

๐Ÿง  Supported LLMs

16 providers. Set one key and it's auto-detected (HERANDHIM_<PROVIDER>_API_KEY), or pin it with HERANDHIM_LLM_PROVIDER. Two run fully local โ€” no key, no cloud.

Provider Key env var Default model
DeepSeek HERANDHIM_DEEPSEEK_API_KEY deepseek-chat
OpenAI HERANDHIM_OPENAI_API_KEY gpt-4o-mini
Claude (Anthropic) HERANDHIM_CLAUDE_API_KEY claude-sonnet-4-20250514
Gemini (Google) HERANDHIM_GEMINI_API_KEY gemini-2.5-flash
OpenRouter HERANDHIM_OPENROUTER_API_KEY deepseek/deepseek-chat
Grok (xAI) HERANDHIM_GROK_API_KEY grok-3
Kimi (Moonshot) HERANDHIM_KIMI_API_KEY moonshot-v1-128k
GLM (Zhipu) HERANDHIM_GLM_API_KEY glm-4-flash
Qwen (Alibaba) HERANDHIM_QWEN_API_KEY qwen-plus
Mistral HERANDHIM_MISTRAL_API_KEY mistral-large-latest
Groq HERANDHIM_GROQ_API_KEY llama-3.3-70b-versatile
Together HERANDHIM_TOGETHER_API_KEY meta-llama/Llama-3.3-70B-Instruct-Turbo
SiliconFlow HERANDHIM_SILICONFLOW_API_KEY deepseek-ai/DeepSeek-V3
Ollama ๐Ÿ  local none llama3.1
LM Studio ๐Ÿ  local none your loaded model
Custom HERANDHIM_CUSTOM_API_KEY any OpenAI-compatible endpoint

๐Ÿ“ท AI selfies

Thirteen backends โ€” set one key and the right one is picked automatically, or name it explicitly with skills.image.provider / HERANDHIM_IMAGE_PROVIDER:

Backend Default model Key Same face across shots
pollinations flux none โ€”
gemini gemini-2.5-flash-image HERANDHIM_IMAGE_GEMINI_KEY โœ…
openrouter google/gemini-2.5-flash-image HERANDHIM_IMAGE_OPENROUTER_KEY โœ…
openai gpt-image-1 HERANDHIM_IMAGE_OPENAI_KEY โœ…
bfl flux-kontext-pro HERANDHIM_BFL_API_KEY โœ…
seedream seedream-5-0-lite-260128 HERANDHIM_SEEDREAM_API_KEY โœ…
fal fal-ai/flux/schnell HERANDHIM_FAL_KEY โ€”
replicate black-forest-labs/flux-schnell HERANDHIM_REPLICATE_API_TOKEN โ€”
stability core HERANDHIM_STABILITY_API_KEY โ€”
dashscope wan2.2-t2i-flash HERANDHIM_DASHSCOPE_API_KEY โ€”
comfyui your workflow none โ€”
sdwebui your checkpoint none โ€”
custom yours HERANDHIM_IMAGE_API_KEY โœ…

Three of these need no new signup at all. pollinations needs no account whatsoever โ€” photos work before you've registered anywhere. gemini and openrouter reuse the key you already pasted for vision or chat, so the one-line quickstart at the top of this README gives you a companion who can already send selfies.

For the local options โ€” ComfyUI or Automatic1111 โ€” there's no key and no upload: nothing about her appearance ever leaves your machine. ComfyUI runs the built-in workflow by default, or point skills.comfyui.workflow at your own exported API-format graph and it will run that instead (%prompt%, %negative%, %seed%, %width%, %height%, %model% get substituted).

If you care most about her looking like the same person every time, use a backend with reference-image support โ€” bfl (FLUX.1 Kontext is built for exactly this), seedream, openai, gemini, or openrouter. The rest still generate; they just lean on the stable seed and the appearance description instead of a face anchor.

Aggregators that speak the OpenAI image API (Together, DeepInfra, Novita, SiliconFlow, Fireworksโ€ฆ) need no dedicated backend โ€” point custom at them.

Three trigger paths:

  • Scheduled โ€” fires at the times in selfie.schedule (default 10:00 / 16:00 / 20:00)
  • Proactive โ€” attached to a proactive message with proactiveProbability chance
  • On demand โ€” when the user says something like "send me a selfie", the LLM invokes the selfie skill

Scene-driven. Each selfie's content is derived from the activity scheduled for the current time in today_plan.md. If the plan says "10:00 coffee on the balcony", the 10:00 selfie will be exactly that.

Visual consistency.

  • Edit ~/.herandhim/context/persona/appearance.md to lock the character's look
  • Drop reference portraits into ~/.herandhim/context/photos/reference/ for face anchoring
  • A stable seed derived from the appearance description keeps the face consistent across shots

Photos are stored under ~/.herandhim/context/photos/ and pruned automatically after 30 days.


๐Ÿ“ Project layout

HerAndHim/
โ”œโ”€โ”€ herandhim/
โ”‚   โ”œโ”€โ”€ main.py                  # CLI entry point
โ”‚   โ”œโ”€โ”€ onboard.py               # setup wizard
โ”‚   โ”œโ”€โ”€ daemon.py                # daemon process manager
โ”‚   โ”œโ”€โ”€ server.py                # Telegram + scheduler bootstrap
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py             # core reasoning loop
โ”‚   โ”‚   โ”œโ”€โ”€ persistent_agent.py  # session persistence
โ”‚   โ”‚   โ”œโ”€โ”€ tools.py             # tool dispatch
โ”‚   โ”‚   โ”œโ”€โ”€ skill_loader.py      # three-tier progressive skill loading
โ”‚   โ”‚   โ”œโ”€โ”€ compaction.py        # context compaction
โ”‚   โ”‚   โ”œโ”€โ”€ stt.py               # speech-to-text (Deepgram)
โ”‚   โ”‚   โ”œโ”€โ”€ llm/                 # provider adapters (6)
โ”‚   โ”‚   โ”œโ”€โ”€ memory/              # Markdown memory + emotional graph + milestones + temporal index
โ”‚   โ”‚   โ”œโ”€โ”€ retrieval/           # BM25 + dense + RRF + LLM reranker
โ”‚   โ”‚   โ”œโ”€โ”€ knowledge/           # knowledge-base RAG
โ”‚   โ”‚   โ””โ”€โ”€ image_gen/           # selfie pipeline (13 backends)
โ”‚   โ”œโ”€โ”€ channels/
โ”‚   โ”‚   โ””โ”€โ”€ telegram_bot.py      # Telegram bot (streaming / voice / images)
โ”‚   โ”œโ”€โ”€ scheduler/
โ”‚   โ”‚   โ”œโ”€โ”€ cron.py              # generic cron jobs
โ”‚   โ”‚   โ”œโ”€โ”€ planner.py           # daily 24-hour plan generator
โ”‚   โ”‚   โ”œโ”€โ”€ proactive.py         # sentiment-aware proactive messages
โ”‚   โ”‚   โ”œโ”€โ”€ selfie_task.py       # scheduled selfies
โ”‚   โ”‚   โ””โ”€โ”€ heartbeat.py         # heartbeat monitor
โ”‚   โ”œโ”€โ”€ web/                     # FastAPI dashboard + WebSocket chat
โ”‚   โ””โ”€โ”€ templates/               # built-in persona / soul / skills
โ”œโ”€โ”€ tests/                       # 208 tests
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ LICENSE

๐Ÿ› ๏ธ Development

git clone https://github.com/ericwang915/HerAndHim.git
cd HerAndHim
python -m venv .venv && source .venv/bin/activate
pip install -e .
pytest tests/ -v
ruff check herandhim tests

๐Ÿ›ก๏ธ Safety & responsible self-hosting

HerAndHim is a relationship-simulation engine for adults (18+) โ€” an emotional-companionship research project, not an adult-content generator. Everything the companion says is generated fiction: it is not a person, and not a substitute for professional help.

It ships SFW. The bundled personas, prompts, and image pipeline are written for everyday companionship โ€” a friend who texts you about her day. Explicit sexual content is not a feature, is not included, and the image guard refuses categorically illegal generation outright. Personas depicting minors are blocked at the code level and are never acceptable, in any form, including text.

Two guardrails ship enabled and are deliberately not configuration flags:

  • Crisis safety (herandhim/core/safety.py) โ€” detects acute distress and responds with care and real helpline resources ahead of persona immersion.
  • Image content guard (herandhim/core/image_gen/guard.py) โ€” blocks categorically illegal image generation at the single chokepoint.

If you self-host, you are the operator: local laws on AI chat services, data protection, and age restrictions are your responsibility.

๐Ÿ“„ SAFETY.md โ€” the full crisis protocol, content limits, and anti-dark-pattern design decisions. ๐Ÿ”’ SECURITY.md โ€” hardening notes and vulnerability reporting.

Status

v0.1.0 โ€” early but real. Runs daily on the maintainer's own machine. The companion engine (memory, daily life, photos, humanized delivery) is stable; the web dashboard is functional but plain. Expect rough edges in setup.

Roadmap: local-model (Ollama) first-class support ยท voice notes both directions ยท a desktop avatar mode ยท more languages. Ideas and issues welcome.


๐Ÿ“„ License

AGPL-3.0 โ€” free to self-host, modify, and share. If you run a modified version as a service for others, you must open-source your modifications. (This keeps hosted forks honest.)


Made with ๐Ÿ’• by HerAndHim

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

herandhim-0.2.0.tar.gz (810.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

herandhim-0.2.0-py3-none-any.whl (811.9 kB view details)

Uploaded Python 3

File details

Details for the file herandhim-0.2.0.tar.gz.

File metadata

  • Download URL: herandhim-0.2.0.tar.gz
  • Upload date:
  • Size: 810.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for herandhim-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4d98d06c0e75ba4eb793d914dc5de7518a91eb47718431872f6ec751771a1402
MD5 e01e99aaf287b96d064dcd8e121f060a
BLAKE2b-256 563e3b2eb722a938fea50ae798d480f41a2747c986426b3c88314ce3af5e17f0

See more details on using hashes here.

File details

Details for the file herandhim-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: herandhim-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 811.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for herandhim-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b17a201ec794b6cec8b0f1d59a02fcd29c8f3a144e8580db34233864e7169e61
MD5 93287a7837b6e511dd416f3a612b9aa9
BLAKE2b-256 af1ed12bfb2f9a523c74230bab3ac15a1aa3ad18fc0675046c407751d460a0e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page