[READ-ONLY] Mirror of https://github.com/elouangrimm/zAi. ai bot on bluesky with openrouter's api! zai.elouan.xyz
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 #

  1. Clone this repository

  2. Create a .env file with your credentials:

    BLUESKY_HANDLE=your-bluesky-handle
    BLUESKY_PASSWORD=your-bluesky-password
    OPENROUTER_API_KEY_PRIMARY=your-openrouter-api-key
    
  3. Install dependencies (requires Python 3.8+):

    pip install -r requirements.txt
    

    It will install the websockets and requests packages, as well as atproto and python-dotenv along with some others!

  4. Run the bot:

    python bot.py
    

    Optional: change the default model by adding -m then your OpenRouter model name. Example: python bot.py -m meta-llama/llama-4-maverick:free. Or, open models.txt and 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.txt file 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.txt file is kept.

Example .env #

BLUESKY_HANDLE=your-handle.bsky.social
BLUESKY_PASSWORD=your-bluesky-app-password
OPENROUTER_KEY=sk-...your openrouter api key...