File size: 1,873 Bytes
27d6aa6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: Freebuff OpenAI Proxy
emoji: 🚀
colorFrom: indigo
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
---

# Freebuff OpenAI Proxy for Hugging Face Spaces

这是一个适配 **Hugging Face Docker Space** 的版本,保留了原项目的核心能力:

- `/v1/chat/completions`
- `/v1/responses`
- `/v1/models`
- `/v1/reset-run`
- `/health`
- 多账号轮询
- Agent Run 缓存
- 登录后自动追加到账号池

## 部署方式

1. 新建一个 **Docker Space**2. 把本目录内的文件上传到 Space 根目录。
3. 推荐在 Space Settings -> Secrets 中配置:
   - `API_KEY`: 你的代理访问密钥(保护 `/v1/*`   - `ADMIN_PASSWORD`: 管理页密码(保护网页登录与账号管理)
   - `ACCOUNTS_JSON`: 可选,启动时预加载账号池
4. 打开 Space 首页,使用网页管理页完成登录或检查状态。

## 可选的 ACCOUNTS_JSON 格式

```json
[
  {
    "name": "account-1",
    "email": "a@example.com",
    "authToken": "xxx"
  },
  {
    "name": "account-2",
    "email": "b@example.com",
    "authToken": "yyy"
  }
]
```

也兼容原始的 `credentials.json` 结构:

```json
{
  "default": {
    "name": "default",
    "email": "a@example.com",
    "authToken": "xxx"
  },
  "accounts": [
    {
      "name": "default",
      "email": "a@example.com",
      "authToken": "xxx"
    }
  ]
}
```

## 持久化存储

如果你的 Space 开启了持久化存储,程序会优先把凭据写入 `/data/manicode/credentials.json`。
未开启时会写到容器内普通目录,Space 重启后会丢失。

## 接口示例

```bash
curl https://<your-space>.hf.space/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax/minimax-m2.7",
    "messages": [{"role": "user", "content": "你好"}],
    "stream": false
  }'
```