IsraelGPT API Docs Get an API key

Discord Bot

A complete reference client for the public API, written in Python - source you can download and run yourself, or invite the maintainers' own hosted instance straight into your server.

Try it out

Don't want to host it yourself? Invite our own always-on instance directly - free, no setup required.

If the hosted bot is unresponsive or shows offline, it may need a restart on our end - email support@israelgpt.site and we'll get it back up.

Important: this doesn't run on serverless hosting

A Discord bot needs a persistent WebSocket connection to Discord's gateway. Serverless functions are short-lived and can't hold one. The bot is a separate, always-on process: a small VPS, any long-running container host, or your own machine. It talks to the public API like any other client, over HTTPS.

What it does

  • Answers when it's @mentioned in a channel, DM'd, or replied to.
  • Keeps a short transcript per channel: the last 20 messages it sent and got, each reply with the sig the API gave it, so the model knows those replies are really its own. It's held in memory: a restart forgets it, and /reset clears a channel's.
  • Sends what people said since it last answered (up to the last 10 messages) as one user message, each line starting with the author's display name, since the API's messages only know user and assistant.
  • Strips the tags only the web chat can show, and posts pictures, songs and podcast episodes from media as follow-up messages.
  • Tells the channel how long to wait on a 429, and says so when its key stops working.
  • Sends the User-Agent IsraelGPT-Discord-Bot/2.0, so the key's request log on the dashboard shows which calls came from it.

Slash commands

CommandWhat it does
/modelIsraelBot 1 or YahooBot 1 for this channel
/personaWhich of the 12 personas this channel uses
/effortLow, medium or high: how creative the replies get
/uncensoredUncensored mode on or off
/shortAsk for short replies (longMode: false), which suit Discord
/imagesPost pictures, songs and podcast episodes, or not
/settingsShow this channel's settings
/resetPut this channel's settings back, and forget its conversation

Settings are per channel, shared by everyone in it. Slash commands sync globally by default, which can take up to an hour to show in Discord after the bot starts; set DISCORD_DEV_GUILD_ID in .env to sync to one test server at once.

Setup

  1. Create a Discord application and bot at the Discord Developer Portal. Under Bot, turn on the Message Content privileged intent. Invite it with the bot and applications.commands scopes, and the Send Messages and Read Message History permissions.
  2. Make a free API key on the dashboard. It's shown once.
  3. Copy discord-bot/.env.example to .env and fill in DISCORD_BOT_TOKEN and ISRAELGPT_API_KEY.
  4. Install and run:
cd discord-bot
pip install -r requirements.txt
python bot.py

The request it makes

From bot.py. The transcript it passes in holds each earlier reply with its sig:

async def call_israelgpt(messages: list[dict], settings: dict) -> dict:
    async with httpx.AsyncClient(timeout=60) as http:
        response = await http.post(
            f"{ISRAELGPT_API_BASE_URL}/chat",
            headers={"Authorization": f"Bearer {ISRAELGPT_API_KEY}", "User-Agent": USER_AGENT},
            json={
                "messages": messages,
                "personaId": settings["persona_id"],
                "selectedModel": settings["model"],
                "effort": settings["effort"],
                "uncensoredMode": settings["uncensored"],
                "longMode": not settings["short"],
            },
        )
    if response.status_code == 429:
        body = response.json()
        raise RateLimited(body.get("error", {}).get("retry_after_seconds", 30))
    if response.status_code in (401, 403, 503):
        raise ApiUnavailable(f"{response.status_code} {response.text[:300]}")
    response.raise_for_status()
    return response.json()

Forking it

The bot is meant as a real starting point, not a toy. Fork discord-bot/, swap in whatever framework or language you like, and point it at the same API Reference. Nothing about the public API is bot-specific. If your fork runs for more than one server, give it its own key, and keep the key on the machine the bot runs on.