A simple Telegram bot that chats using OpenAI's Large language model (LLM) ! THe code can be also used for any other LLM like claude or gemini ai with slight changes.
Follow these steps to set it up and start chatting.
- Connects directly to OpenAI's API for dynamic responses.
- Easy setup with minimal configuration.
- Message BotFather on Telegram, send
/newbot, and follow the steps. - Copy your bot's token.
- Sign up at OpenAI and grab an API key from the API keys section. (there is a free trial credits I believe)
git clone https://github.com/ababaee1/LLM_API_Telegram_bot.git
cd LLM_API_Telegram_botpip install -r requirements.txt
enter the token values.
TELEGRAM_BOT_TOKEN=your_telegram_token
OPENAI_API_KEY=your_openai_key
python bot.py