Supported AI Models
mainxiaogpt supports the following AI providers:
- ChatGPT
- New Bing
- ChatGLM
- Gemini
- Doubao
- Moonshot
- 01
- Llama3
- 通义千问 (Qwen)
repository·main·Indexed 27 days ago
https://github.com/yihong0618/xiaogptA tool that allows users to interact with various Large Language Models (LLMs)—including ChatGPT, Gemini, Qwen, Llama3, and others—through a Xiaomi AI Speaker. It supports multiple TTS engines such as edge, openai, azure, and fish, and can be configured via CLI arguments, YAML/JSON files, or Docker.
xiaogpt supports the following AI providers:
yihong0618/xiaogpt. You must provide an OPENAI_API_KEY via environment variables. You can pass command-line arguments directly to the container to configure your Xiaomi account, password, and hardware ID.To use a configuration file (e.g., config.yaml) within a Docker container, mount a local directory to /config and use the --config flag pointing to the path inside the container.
docker run -v <your-config-dir>:/config yihong0618/xiaogpt --config=/config/config.yaml
# Using host network mode
docker run -v <your-config-dir>:/config --network=host yihong0618/xiaogpt --config=/config/config.yaml--build-arg to specify a mirror (e.g., Tsinghua). For Apple Silicon (M1/M2) users needing an x86 image, use buildx.Some TTS providers (like edge-tts) start a local HTTP service. When running in Docker, you must map the container port to the host and set the XIAOGPT_HOSTNAME environment variable to your host's IP address so the Xiaomi device can reach the service.
docker run -v <your-config-dir>:/config -p 9527:9527 -e XIAOGPT_HOSTNAME=<your ip> yihong0618/xiaogpt --config=/config/config.yamlInstall the xiaogpt package using pip. It is recommended to use the [locked] extra to ensure dependency compatibility.
pip install -U --force-reinstall xiaogpt[locked]To interact with your Xiaomi speaker, you need its DID (Device ID). You can obtain this using the miservice_fork package.
pip install miservice_forkexport MI_USER=xxx and export MI_PASS=xxxmicli list (to find your DID)export MI_DID=xxxpip install miservice_forkset MI_USER=xxx and set MI_PASS=xxxmicli listset MI_DID=xxxpip install miservice_fork$env:MI_USER="xxx" and $env:MI_PASS="xxx"micli list$env:MI_DID="xxx"Note: If micli list fails, try switching your wireless network.
pip install miservice_fork
export MI_USER=xxx
export MI_PASS=xxx
micli list
export MI_DID=xxxxiaogpt supports several TTS providers: edge, openai, azure, volc, baidu, google, and fish. You can enable them via the tts key in your configuration file.
tts: edgeYou can start xiaogpt using a configuration file (YAML or JSON) via the --config flag.
Priority order: CLI arguments > default > config file.
To set OpenAI model parameters like temperature or top_p, use the gpt_options key in your YAML file.
gpt_options:
temperature: 0.9
top_p: 0.9python3 xiaogpt.py --config xiao_config.yamlYou can specify which AI engine and Text-to-Speech (TTS) engine to use via the bot and tts configuration keys.
chatgptapi, newbing, qwen, and gemini. Default is chatgptapi.mi, edge, openai, azure, volc, baidu, google, and minimax. Default is mi.The xiaogpt project uses several configuration parameters to manage AI models, Xiaomi speaker credentials, and interaction behaviors. You can configure these via environment variables or direct input depending on your setup.
| 参数 | 说明 | 默认值 | 可选值 |
| --------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| hardware | 设备型号 | | |
| account | 小爱账户 | | |
| password | 小爱账户密码 | | |
| openai_key | openai 的 apikey | | |
| moonshot_api_key | moonshot kimi 的 [apikey](https://platform.moonshot.cn/docs/api/chat#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B) | | |
| yi_api_key | 01 wanwu 的 [apikey](https://platform.lingyiwanwu.com/apikeys) | | |
| llama_api_key | groq 的 llama3 [apikey](https://console.groq.com/docs/quickstart) | | |
| serpapi_api_key | serpapi 的 key 参考 [SerpAPI](https://serpapi.com/) | | |
| glm_key | chatglm 的 apikey | | |
| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | | |
| gemini_api_domain | gemini 的自定义域名 [参考](https://github.com/antergone/palm-netlify-proxy) | | |
| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | | |
| cookie | 小爱账户 cookie(如果用上面密码登录可以不填) | | |
| mi_did | 设备 did | | |
| use_command | 使用 MI command 与小爱交互 | `false` | |
| mute_xiaoai | 快速停掉小爱自己的回答 | `true` | |
| verbose | 是否打印详细日志 | `false` | |
| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` | |
| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、 `azure`、 `volc`、 `baidu`、 `google`、 `minimax` |
| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | | |
| prompt | 自定义 prompt | `请用100字以内回答` | |
| keyword | 自定义请求词列表 | `["请"]` | |
| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` | |
| start_conversation | 开始持续对话关键词 | `开始持续对话` | |
| end_conversation | 结束持续对话关键词 | `结束持续对话` | |
| stream | 使用流式响应,获得更快的响应 | `true` | |
| proxy | 支持 HTTP 代理,传入 http proxy URL | "" | |
| gpt_options | OpenAI API 的参数字典 | `{}` | |
| deployment_id | Azure OpenAI 服务的 deployment ID | | |
| api_base | 如果需要替换默认的 api,或者使用 Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` | |
| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | |
| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | |If you encounter Login failed errors (often due to Xiaomi's regional security controls preventing overseas logins to mainland accounts), use cookie-based login.
.mi.token file in your user folder (C:\Users\<username> on Windows or ~/ on Linux)..mi.token file to your server.