Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/elouangrimm/zAi. ai bot on bluesky with openrouter's api! zai.elouan.xyz
Something went wrong. Try again.
Files
- Python 100%
README.md
zAi - Bluesky AI Bot #
Tag @zai.botsky.social on Bluesky to interact!
Features #
- Responds to all mentions and replies on Bluesky (via notifications)
- Uses Gemini 2.0 Flash (or the models of your choice) for all AI-powered text responses. Best part is that its completley free!
- Thread-aware: Replies with context of the entire conversation
- Persistent cache: Prevents duplicate replies (even if restarted)
- Pretty Terminal UI: has niceley formatted terminal info, mainly to run on your own machine!
Setup #
-
Clone this repository
-
Create a
.envfile with your credentials:BLUESKY_HANDLE=your-bluesky-handle BLUESKY_PASSWORD=your-bluesky-password OPENROUTER_API_KEY_PRIMARY=your-openrouter-api-key -
Install dependencies (requires Python 3.8+):
pip install -r requirements.txtIt will install the
websocketsandrequestspackages, as well asatprotoandpython-dotenvalong with some others! -
Run the bot:
python bot.pyOptional: change the default model by adding -m then your OpenRouter model name. Example:
python bot.py -m meta-llama/llama-4-maverick:free. Or, openmodels.txtand edit the priority of models chosen.
How It Works #
- Listens for direct mentions and replies to your bot on Bluesky using the notifications API.
- Fetches the context of the whole thread for the most relevant and chaotic AI response.
- All replies are generated by Gemini 2.0 Flash (or another model) via OpenRouter (should be free-ish for now).
- Models are chose based on error. The
models.txtfile has a list of models ranked by priority, and the bot will use the first one until it gets timed out or has an error, then switches to the next. - Prevents duplicate replies with a persistent log file (
processed_uris.txt).
Deployment #
- This bot is platform-agnostic: you can run it on your computeron, your own server, Raspberry Pi, or deploy it on any service that supports persistent Python processes (like Railway, Fly.io, etc).
- Make sure your process can run continuously and has a persistent filesystem for the cache file.
Notes #
- Restarting the bot will not duplicate responses to old posts, as long as the
processed_uris.txtfile is kept.
Example .env #
BLUESKY_HANDLE=your-handle.bsky.social
BLUESKY_PASSWORD=your-bluesky-app-password
OPENROUTER_KEY=sk-...your openrouter api key...