Skip to content

XxxXTeam/XiaoMiweb2api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XiaoMi Web2API

将小米 AI Studio (MiMo) 的 Web 接口转换为 OpenAI 兼容的 API 服务。

功能特性

  • OpenAI 兼容 API: 支持 /v1/chat/completions/v1/models 端点
  • 流式输出: 支持 SSE 流式响应
  • 多账号轮询: 自动负载均衡,账号鉴权失效自动剔除
  • 深度思考: 支持 -thinking 后缀启用思考模式
  • 联网搜索: 支持 -search 后缀启用网络搜索
  • 工具调用: 支持 Function Calling
  • 监控面板: 内置实时指标监控页面

支持的模型

模型名称 说明
mimo-v2-flash-studio 默认模型
mimo-v2-flash 基础模型
mimo-v2-flash-studio-thinking 启用深度思考
mimo-v2-flash-studio-search 启用联网搜索
mimo-v2-flash-studio-thinking-search 思考+搜索

所有模型均支持 -thinking-search-thinking-search 后缀组合

快速开始

1. 配置

编辑 config.json:

{
  "api_key": "your-api-key",
  "port": 18080,
  "auth_check_interval": 300,
  "debug": false
}
参数 说明 默认值
api_key API 访问密钥 必填
port 服务端口 18080
auth_check_interval 账号鉴权检查间隔(秒) 300
debug 调试模式 false

2. 添加账号

data/ 目录下创建 JSON 文件(如 account1.json):

{
  "name": "账号名称",
  "cookie": "你的cookie",
  "ph": "xiaomichatbot_ph参数值"
}

获取方式:

  1. 登录 小米 AI Studio
  2. 打开浏览器开发者工具 (F12)
  3. 在 Network 中找到任意 API 请求
  4. 复制 Cookie 和 URL 中的 xiaomichatbot_ph 参数

3. 运行

# 编译
go build -o xiaomi-api

# 运行
./xiaomi-api

服务启动后访问 http://localhost:18080 查看监控面板。

API 使用

Chat Completions

curl http://localhost:18080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "model": "mimo-v2-flash-studio",
    "messages": [{"role": "user", "content": "你好"}],
    "stream": false
  }'

流式请求

curl http://localhost:18080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "model": "mimo-v2-flash-studio-thinking",
    "messages": [{"role": "user", "content": "解释量子计算"}],
    "stream": true
  }'

获取模型列表

curl http://localhost:18080/v1/models \
  -H "Authorization: Bearer your-api-key"

与第三方客户端集成

本服务兼容 OpenAI API 格式,可直接配置到:

  • ChatGPT-Next-Web
  • LobeChat
  • OpenAI SDK
  • 其他 OpenAI 兼容客户端

配置示例:

  • API Base URL: http://localhost:18080/v1
  • API Key: 你在 config.json 中设置的 api_key

项目结构

.
├── config.json      # 配置文件
├── data/            # 账号数据目录
│   └── *.json       # 账号配置文件
├── main.go          # 主程序
├── go.mod
└── go.sum

注意事项

  • Cookie 有效期有限,失效后需重新获取
  • 建议配置多个账号以提高可用性
  • 请遵守小米 AI Studio 使用条款
  • 本项目仅供学习研究使用

License

本项目采用 GPL-3.0 许可证。

About

小米aistudio网页逆向api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages