tokenmixai/tokenmix-php
Composer 安装命令:
composer require tokenmixai/tokenmix-php
包简介
PHP client for TokenMix — one API key for GPT-5, Claude, Gemini, DeepSeek and 155+ LLMs
README 文档
README
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
Two things you need:
- Telegram bot token — message @BotFather, type
/newbot, follow the steps - LLM API key — from TokenMix.ai ($1 free credit, 155+ models) or any OpenAI-compatible provider
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
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
- 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-4oto 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
/model <name> — switch to a different model
/clear — wipe conversation history
/help — show commands
Configuration
Everything is in .env:
| Variable | Required | Default | |
|---|---|---|---|
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 prompt |
Find your Telegram user ID by messaging @userinfobot.
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
MIT
tokenmixai/tokenmix-php 适用场景与选型建议
tokenmixai/tokenmix-php 是一款 基于 Python 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「chat」 「ai」 「Gemini」 「openai」 「gpt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tokenmixai/tokenmix-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tokenmixai/tokenmix-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tokenmixai/tokenmix-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
Client for the REST API plugin of the OpenFire Server
A PSR-7 compatible library for making CRUD API endpoints
AI Agent templates for Laravel development - Skills, Agents, and Workflows for enhanced coding assistance
The Yii2 extension module to chat registered users.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-25