PHPackages                             tokenmixai/tokenmix-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. tokenmixai/tokenmix-php

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

tokenmixai/tokenmix-php
=======================

PHP client for TokenMix — one API key for GPT-5, Claude, Gemini, DeepSeek and 155+ LLMs

001PythonCI passing

Since Apr 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/TokenMixAi/tg-ai-bot)[ Packagist](https://packagist.org/packages/tokenmixai/tokenmix-php)[ RSS](/packages/tokenmixai-tokenmix-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

tg-ai-bot
=========

[](#tg-ai-bot)

Your own AI chatbot on Telegram. One file, one command, 155+ models.

Supports any OpenAI-compatible API. Streams responses in real time. Send photos and the bot can see them (vision). Switch models mid-conversation.

Setup
-----

[](#setup)

Two things you need:

1. **Telegram bot token** — message [@BotFather](https://t.me/BotFather), type `/newbot`, follow the steps
2. **LLM API key** — from [TokenMix.ai](https://tokenmix.ai) ($1 free credit, 155+ models) or any OpenAI-compatible provider

### Deploy with Docker (recommended)

[](#deploy-with-docker-recommended)

```
git clone https://github.com/diaoyulao9657/tg-ai-bot
cd tg-ai-bot
cp .env.example .env
# edit .env — fill in BOT_TOKEN and API_KEY
docker compose up -d
```

Done. Open your bot on Telegram and say hi.

### Run without Docker

[](#run-without-docker)

```
git clone https://github.com/diaoyulao9657/tg-ai-bot
cd tg-ai-bot
pip install -r requirements.txt
cp .env.example .env
# edit .env
python bot.py
```

Features
--------

[](#features)

- **Streaming** — responses appear word-by-word, not after a long wait
- **Vision** — send a photo with a question, the bot understands it
- **Voice messages** — send a voice note, it gets transcribed and answered
- **Markdown** — code blocks, bold, and other formatting render properly
- **Group chat** — in groups, responds only when @mentioned or replied to
- **Model switching** — `/model gpt-4o` to try a different model anytime
- **Conversation memory** — keeps context across messages (configurable depth)
- **Long replies** — responses over 4096 chars are split across multiple messages
- **Access control** — optionally restrict to specific Telegram user IDs

Commands
--------

[](#commands)

```
/model   — switch to a different model
/clear         — wipe conversation history
/help          — show commands

```

Configuration
-------------

[](#configuration)

Everything is in `.env`:

VariableRequiredDefault`BOT_TOKEN`yes—From @BotFather`API_KEY`yes—LLM API key`BASE_URL`no`https://api.tokenmix.ai/v1`API endpoint`MODEL`no`gpt-4o-mini`Default model`MAX_HISTORY`no`20`Messages kept in context`ALLOWED_USERS`no*(everyone)*Comma-separated user IDs`SYSTEM_PROMPT`no`You are a helpful assistant.`System promptFind your Telegram user ID by messaging [@userinfobot](https://t.me/userinfobot).

How it works
------------

[](#how-it-works)

It's one Python file. The bot receives messages via Telegram's API, forwards them to an LLM through the OpenAI-compatible chat completions endpoint, and streams the response back by editing the message as tokens arrive. Photos are base64-encoded and sent as vision inputs.

Conversation history is stored in memory (resets when the bot restarts). For most use cases this is fine — if you need persistence, a database would be straightforward to add.

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance60

Regular maintenance activity

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cba32e981abf0a4aff503f044258b5a65dcd47b6d104190270c25ba53800408b?d=identicon)[TokenMixAi](/maintainers/TokenMixAi)

---

Top Contributors

[![TokenMixAi](https://avatars.githubusercontent.com/u/267831043?v=4)](https://github.com/TokenMixAi "TokenMixAi (4 commits)")

---

Tags

aichatbotdockerllmopenaipythontelegramtelegram-bot

### Embed Badge

![Health badge](/badges/tokenmixai-tokenmix-php/health.svg)

```
[![Health](https://phpackages.com/badges/tokenmixai-tokenmix-php/health.svg)](https://phpackages.com/packages/tokenmixai-tokenmix-php)
```

###  Alternatives

[felixfbecker/language-server

PHP Implementation of the Visual Studio Code Language Server Protocol

1.2k95.7k](/packages/felixfbecker-language-server)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4676.9k](/packages/tiamo-phpas2)[shopware/deployment-helper

Shopware deployment tools

19365.5k5](/packages/shopware-deployment-helper)[yousign/zdd-message-bundle

Assert Zero Downtime Deployment compliance for messages

27124.5k](/packages/yousign-zdd-message-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
