ai-zero-token 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +140 -399
- package/README.zh-CN.md +248 -0
- package/dist/cli/commands/serve.js +1 -0
- package/dist/core/services/image-service.js +2 -7
- package/dist/server/admin-page.js +9 -9
- package/dist/server/app.js +2 -1
- package/dist/server/index.js +17 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.8 - 2026-04-29
|
|
4
|
+
|
|
5
|
+
- Removed local Free-plan blocking for image generation and editing; upstream account limits now decide availability.
|
|
6
|
+
- Switched image request orchestration to `gpt-5.4-mini` while keeping the requested image model on the `image_generation` tool.
|
|
7
|
+
- Increased the default gateway request body limit to 32 MiB and added `AZT_BODY_LIMIT_MB` for large JSON base64 image inputs.
|
|
8
|
+
- Updated the management-page update command to `npm install -g ai-zero-token`.
|
|
9
|
+
- Reworked the README into a cleaner open-source project format and added `README.zh-CN.md` for Simplified Chinese.
|
|
10
|
+
|
|
3
11
|
## 1.0.7 - 2026-04-29
|
|
4
12
|
|
|
5
13
|
- Added JSON `POST /v1/images/edits` support for image-to-image workflows with URL, base64 data URL, or raw base64 image references.
|
package/README.md
CHANGED
|
@@ -1,507 +1,248 @@
|
|
|
1
1
|
# AI Zero Token
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Local-first OpenAI-compatible gateway for ChatGPT/Codex OAuth accounts.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
AI Zero Token provides a local CLI, web console, and HTTP gateway that expose saved ChatGPT/Codex account capabilities through OpenAI-style endpoints. It is designed for local single-user workflows, prototyping, automation, and OpenAI-compatible clients.
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
- `POST /v1/images/edits`
|
|
11
|
-
- `POST /v1/responses`
|
|
12
|
-
- `POST /v1/chat/completions`
|
|
13
|
-
- `GET /v1/models`
|
|
9
|
+
> This is an experimental local tool. It is not an official OpenAI product and is not recommended as a production multi-tenant gateway.
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
## Features
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
- OpenAI-compatible local API:
|
|
14
|
+
- `GET /v1/models`
|
|
15
|
+
- `POST /v1/responses`
|
|
16
|
+
- `POST /v1/chat/completions`
|
|
17
|
+
- `POST /v1/images/generations`
|
|
18
|
+
- `POST /v1/images/edits`
|
|
19
|
+
- ChatGPT/Codex OAuth login with local token refresh.
|
|
20
|
+
- Multi-account management in the web console.
|
|
21
|
+
- Account JSON import/export, including selected batch export.
|
|
22
|
+
- Apply a saved account to local Codex by backing up and updating `~/.codex/auth.json`.
|
|
23
|
+
- `gpt-image-2` image generation and JSON image editing through the ChatGPT internal Responses path.
|
|
24
|
+
- Optional upstream proxy configuration for OAuth, model refresh, and gateway forwarding.
|
|
25
|
+
- Local model discovery from the Codex model cache with manual refresh support.
|
|
30
26
|
|
|
31
|
-
##
|
|
27
|
+
## Quick Start
|
|
32
28
|
|
|
33
29
|
```bash
|
|
34
30
|
npm install -g ai-zero-token
|
|
35
31
|
azt start
|
|
36
32
|
```
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
The command starts the local web console and gateway:
|
|
39
35
|
|
|
40
36
|
```text
|
|
37
|
+
http://127.0.0.1:8787
|
|
41
38
|
http://127.0.0.1:8787/v1
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-

|
|
47
|
-
|
|
48
|
-
## 生图结果预览
|
|
49
|
-
|
|
50
|
-
下图通过 AI Zero Token 本地网关调用 `POST /v1/images/generations` 生成,模型为 `gpt-image-2`。
|
|
41
|
+
Use any non-empty API key value when a client requires one. Authentication is handled by the local gateway.
|
|
51
42
|
|
|
52
|
-
|
|
43
|
+
## Web Console
|
|
53
44
|
|
|
54
|
-
|
|
45
|
+
The web console is the recommended entry point:
|
|
55
46
|
|
|
56
|
-
|
|
47
|
+
- Log in with OpenAI Codex OAuth.
|
|
48
|
+
- Import one or more account JSON files.
|
|
49
|
+
- Switch the active account.
|
|
50
|
+
- Export one account or selected accounts.
|
|
51
|
+
- Apply a saved account to local Codex.
|
|
52
|
+
- Configure the default text model and upstream proxy.
|
|
53
|
+
- Test `models`, `responses`, `chat.completions`, `images.generations`, and `images.edits`.
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
- 想把能力接入自己的脚本、前端、本地工作流,但不想每次都手工操作网页
|
|
60
|
-
- 想统一本地调用方式,而不是每家产品各写一套接入逻辑
|
|
61
|
-
- 想学习 OAuth、CLI、网关、npm CLI、桌面端这类真实工程能力
|
|
62
|
-
|
|
63
|
-
AI Zero Token 就是围绕这些问题设计的。
|
|
64
|
-
|
|
65
|
-
## 它能解决什么
|
|
66
|
-
|
|
67
|
-
- 想把 ChatGPT 的图片生成能力接到自己的前端、小工具或脚本里
|
|
68
|
-
- 想先用本地网关验证产品原型,而不是一上来就重做整套后端
|
|
69
|
-
- 想统一成 OpenAI 风格接口,减少接入成本
|
|
70
|
-
- 想研究一条完整的 OAuth -> token -> 本地状态 -> 网关 -> 上游请求链路
|
|
71
|
-
|
|
72
|
-
## 架构概览
|
|
73
|
-
|
|
74
|
-

|
|
75
|
-
|
|
76
|
-
## 当前能做什么
|
|
77
|
-
|
|
78
|
-
- 通过 `POST /v1/images/generations` 代理 `gpt-image-2` 生图请求
|
|
79
|
-
- 通过 OpenAI Codex OAuth 登录
|
|
80
|
-
- 在本地保存 `access_token` 和 `refresh_token`
|
|
81
|
-
- 支持保存多个账号 profile,并手动切换当前生效账号
|
|
82
|
-
- 在 token 过期时自动刷新
|
|
83
|
-
- 通过 `azt start` 一键启动本地 HTTP 网关和管理页面
|
|
84
|
-
- 在管理页面里完成多账号登录、查看账号状态、切换当前账号、切换默认模型、测试接口
|
|
85
|
-
- 模型列表优先读取本机 Codex 最新缓存,并支持在 CLI / 管理页手动同步
|
|
86
|
-
- 暴露 OpenAI 风格接口:
|
|
87
|
-
- `GET /v1/models`
|
|
88
|
-
- `POST /v1/responses`
|
|
89
|
-
- `POST /v1/chat/completions`
|
|
90
|
-
- `POST /v1/images/generations`
|
|
55
|
+

|
|
91
56
|
|
|
92
|
-
##
|
|
57
|
+
## API Usage
|
|
93
58
|
|
|
94
|
-
|
|
95
|
-
- 想把 `gpt-image-2` 生图接口直接接给脚本、前端或自动化流程的人
|
|
96
|
-
- 想做自己的 AI 网关、AI CLI、AI 桌面端的人
|
|
97
|
-
- 想学习一条完整 OAuth -> token -> CLI -> HTTP API 链路的人
|
|
98
|
-
- 想把 AI 能力接入脚本、前端或自动化流程的人
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## 环境要求
|
|
102
|
-
|
|
103
|
-
- Node.js 22+ 推荐
|
|
104
|
-
- Bun 可用于开发和直接运行源码
|
|
105
|
-
- 终端网络需要可访问:
|
|
106
|
-
- `https://auth.openai.com`
|
|
107
|
-
- `https://chatgpt.com`
|
|
108
|
-
|
|
109
|
-
## 安装与运行
|
|
110
|
-
|
|
111
|
-
### 从源码运行
|
|
112
|
-
|
|
113
|
-
克隆仓库并安装依赖:
|
|
59
|
+
### Models
|
|
114
60
|
|
|
115
61
|
```bash
|
|
116
|
-
|
|
117
|
-
cd AI-Zero-Token
|
|
118
|
-
npm install
|
|
62
|
+
curl http://127.0.0.1:8787/v1/models
|
|
119
63
|
```
|
|
120
64
|
|
|
121
|
-
|
|
65
|
+
### Responses
|
|
122
66
|
|
|
123
67
|
```bash
|
|
124
|
-
|
|
68
|
+
curl http://127.0.0.1:8787/v1/responses \
|
|
69
|
+
-H "content-type: application/json" \
|
|
70
|
+
-d '{"model":"gpt-5.4","input":"Reply with OK only."}'
|
|
125
71
|
```
|
|
126
72
|
|
|
127
|
-
###
|
|
128
|
-
|
|
129
|
-
如果你只是想把它当作本地 CLI 和本地网关使用,可以直接全局安装:
|
|
73
|
+
### Chat Completions
|
|
130
74
|
|
|
131
75
|
```bash
|
|
132
|
-
|
|
76
|
+
curl http://127.0.0.1:8787/v1/chat/completions \
|
|
77
|
+
-H "content-type: application/json" \
|
|
78
|
+
-d '{
|
|
79
|
+
"model": "gpt-5.4",
|
|
80
|
+
"messages": [
|
|
81
|
+
{
|
|
82
|
+
"role": "user",
|
|
83
|
+
"content": "Reply with OK only."
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}'
|
|
133
87
|
```
|
|
134
88
|
|
|
135
|
-
|
|
89
|
+
### Image Generation
|
|
136
90
|
|
|
137
91
|
```bash
|
|
138
|
-
|
|
139
|
-
|
|
92
|
+
curl http://127.0.0.1:8787/v1/images/generations \
|
|
93
|
+
-H "content-type: application/json" \
|
|
94
|
+
-d '{
|
|
95
|
+
"model": "gpt-image-2",
|
|
96
|
+
"prompt": "A clean product photo of a red apple on a white background.",
|
|
97
|
+
"size": "1024x1024",
|
|
98
|
+
"quality": "low",
|
|
99
|
+
"response_format": "b64_json"
|
|
100
|
+
}'
|
|
140
101
|
```
|
|
141
102
|
|
|
142
|
-
|
|
103
|
+
The gateway returns an OpenAI-style response with `data[].b64_json`.
|
|
143
104
|
|
|
144
|
-
-
|
|
105
|
+

|
|
145
106
|
|
|
146
|
-
|
|
107
|
+
### Image Editing
|
|
147
108
|
|
|
148
|
-
|
|
109
|
+
`/v1/images/edits` currently supports JSON requests with URL, data URL, or raw base64 image references:
|
|
149
110
|
|
|
150
111
|
```bash
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
112
|
+
curl http://127.0.0.1:8787/v1/images/edits \
|
|
113
|
+
-H "content-type: application/json" \
|
|
114
|
+
-d '{
|
|
115
|
+
"model": "gpt-image-2",
|
|
116
|
+
"prompt": "Use this reference image and create a cleaner product advertisement version.",
|
|
117
|
+
"images": [
|
|
118
|
+
{
|
|
119
|
+
"image_url": "data:image/png;base64,REPLACE_WITH_IMAGE_BASE64"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"size": "1024x1024",
|
|
123
|
+
"quality": "low",
|
|
124
|
+
"response_format": "b64_json"
|
|
125
|
+
}'
|
|
164
126
|
```
|
|
165
127
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
接下来在管理页里完成这几件事:
|
|
128
|
+
More examples are available in [docs/API_USAGE.md](docs/API_USAGE.md).
|
|
169
129
|
|
|
170
|
-
|
|
171
|
-
- 查看当前账号状态和过期时间
|
|
172
|
-
- 在已保存账号之间切换当前使用账号
|
|
173
|
-
- 切换默认模型
|
|
174
|
-
- 直接测试 `models`、`responses`、`chat.completions`
|
|
175
|
-
- 直接测试 `images.generations` 生图接口
|
|
130
|
+
## Account Management
|
|
176
131
|
|
|
177
|
-
|
|
132
|
+
AI Zero Token stores account state locally under:
|
|
178
133
|
|
|
179
134
|
```text
|
|
180
|
-
|
|
135
|
+
~/.ai-zero-token/.state
|
|
181
136
|
```
|
|
182
137
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
- [API 使用说明](docs/API_USAGE.md)
|
|
138
|
+
The web console supports:
|
|
186
139
|
|
|
187
|
-
|
|
140
|
+
- OAuth login.
|
|
141
|
+
- JSON import from a single profile, an array, or a `profiles` bundle.
|
|
142
|
+
- Single-account export.
|
|
143
|
+
- Selected batch export using checkboxes.
|
|
144
|
+
- Account deletion and active-account switching.
|
|
188
145
|
|
|
189
|
-
|
|
146
|
+
Exported account JSON includes authentication tokens and should be treated as a secret.
|
|
190
147
|
|
|
191
|
-
|
|
192
|
-
AZT_CORS_ORIGIN=http://127.0.0.1:8124 azt start
|
|
193
|
-
```
|
|
148
|
+
### Apply to Codex
|
|
194
149
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
AZT_CORS_ORIGIN=http://127.0.0.1:8124,http://localhost:3000 azt start
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
如果你当前还没有全局命令,也可以把上面的 `azt` 临时替换成:
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
bun src/cli.ts
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
例如:`bun src/cli.ts start`
|
|
208
|
-
|
|
209
|
-
## 网关使用说明
|
|
210
|
-
|
|
211
|
-
如果你主要把 AI Zero Token 当作本地网关来使用,推荐只记住一个命令:
|
|
212
|
-
|
|
213
|
-
### 1. 启动
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
azt start
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
启动后会自动打开管理页。管理页就是默认工作入口,你可以在里面直接:
|
|
220
|
-
|
|
221
|
-
- 触发 OpenAI Codex OAuth 登录并新增账号
|
|
222
|
-
- 查看当前账号、已保存账号列表、过期时间、token 摘要
|
|
223
|
-
- 查看账号套餐 plan 和当前账号是否支持生图
|
|
224
|
-
- 在多个已保存账号之间切换当前使用账号
|
|
225
|
-
- 在“新增账号”里选择 OAuth 登录,或粘贴外部账号 JSON 批量导入
|
|
226
|
-
- 导出单个账号,或勾选多个账号后批量导出所选账号 JSON
|
|
227
|
-
- 将任一已保存账号“应用到 Codex”,自动备份并更新本机 `~/.codex/auth.json`
|
|
228
|
-
- 删除单个本地账号,或一键清空全部本地账号
|
|
229
|
-
- 切换默认模型
|
|
230
|
-
- 测试 `models` / `responses` / `chat.completions`
|
|
231
|
-
- 测试 `images.generations`
|
|
232
|
-
|
|
233
|
-
管理页里邮箱默认脱敏显示,需要手动点击“查看邮箱”才会显示明文。
|
|
234
|
-
|
|
235
|
-
导出的账号 JSON 包含完整 `access_token` 和 `refresh_token`,等同于账号登录凭据,只适合在可信环境中传递。
|
|
236
|
-
|
|
237
|
-
账号卡片里的“应用到 Codex”会把该账号的 `access_token`、`refresh_token`、`id_token` 和 `account_id` 写入本机 Codex 的 `~/.codex/auth.json`。写入前会自动备份原文件;新开的 Codex 会话会使用该账号。
|
|
238
|
-
|
|
239
|
-
如果当前网络访问海外上游不稳定,可以在管理页的“接口测试 / 系统设置”区域启用“上游代理”,并填写你自己的代理地址。保存后,OAuth 换取 token、模型刷新和接口转发都会通过该代理访问上游;本地管理页和 `127.0.0.1` 默认保持直连。
|
|
240
|
-
|
|
241
|
-
默认监听地址:
|
|
150
|
+
The `Apply to Codex` action writes the selected account to:
|
|
242
151
|
|
|
243
152
|
```text
|
|
244
|
-
|
|
153
|
+
~/.codex/auth.json
|
|
245
154
|
```
|
|
246
155
|
|
|
247
|
-
|
|
156
|
+
Before writing, the existing file is backed up as `auth.json.azt-backup-*`. New Codex sessions will use the applied account.
|
|
248
157
|
|
|
249
|
-
|
|
250
|
-
http://127.0.0.1:8787
|
|
251
|
-
```
|
|
158
|
+
## Configuration
|
|
252
159
|
|
|
253
|
-
|
|
160
|
+
Default listener:
|
|
254
161
|
|
|
255
162
|
```text
|
|
256
|
-
|
|
163
|
+
0.0.0.0:8787
|
|
257
164
|
```
|
|
258
165
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
客户端或 SDK 里把 Base URL 改成:
|
|
166
|
+
Local gateway base URL:
|
|
262
167
|
|
|
263
168
|
```text
|
|
264
169
|
http://127.0.0.1:8787/v1
|
|
265
170
|
```
|
|
266
171
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
### 3. 查看模型列表
|
|
270
|
-
|
|
271
|
-
OpenAI 风格模型接口:
|
|
172
|
+
Restrict browser CORS origins:
|
|
272
173
|
|
|
273
174
|
```bash
|
|
274
|
-
|
|
175
|
+
AZT_CORS_ORIGIN=http://127.0.0.1:8124 azt start
|
|
275
176
|
```
|
|
276
177
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
最小请求示例:
|
|
178
|
+
Multiple origins can be separated by commas:
|
|
280
179
|
|
|
281
180
|
```bash
|
|
282
|
-
|
|
283
|
-
-H "content-type: application/json" \
|
|
284
|
-
-d '{"model":"gpt-5.4","input":"请只回复 OK"}'
|
|
181
|
+
AZT_CORS_ORIGIN=http://127.0.0.1:8124,http://localhost:3000 azt start
|
|
285
182
|
```
|
|
286
183
|
|
|
287
|
-
|
|
184
|
+
The persistent state directory can be overridden with:
|
|
288
185
|
|
|
289
186
|
```bash
|
|
290
|
-
|
|
291
|
-
-H "content-type: application/json" \
|
|
292
|
-
-d '{"model":"gpt-5.4","instructions":"你是一个简洁助手","input":"请只回复 OK"}'
|
|
187
|
+
AI_ZERO_TOKEN_HOME=/path/to/home azt start
|
|
293
188
|
```
|
|
294
189
|
|
|
295
|
-
|
|
190
|
+
The default request body limit is `32 MiB`, which is intended to make JSON base64 image references practical for local image editing. You can override it with:
|
|
296
191
|
|
|
297
192
|
```bash
|
|
298
|
-
|
|
299
|
-
-H "content-type: application/json" \
|
|
300
|
-
-d '{
|
|
301
|
-
"model": "gpt-5.4",
|
|
302
|
-
"messages": [
|
|
303
|
-
{
|
|
304
|
-
"role": "user",
|
|
305
|
-
"content": "请只回复 OK"
|
|
306
|
-
}
|
|
307
|
-
]
|
|
308
|
-
}'
|
|
193
|
+
AZT_BODY_LIMIT_MB=64 azt start
|
|
309
194
|
```
|
|
310
195
|
|
|
311
|
-
|
|
196
|
+
## Image Limits
|
|
312
197
|
|
|
313
|
-
|
|
198
|
+
ChatGPT Images availability and limits are controlled by the upstream account. Free accounts can attempt image generation, but rate limits and feature availability are stricter than paid plans and are not published as fixed public numbers. The gateway forwards image requests and surfaces the upstream response, for example `usage_limit_reached` with reset information.
|
|
314
199
|
|
|
315
|
-
|
|
316
|
-
curl http://127.0.0.1:8787/v1/images/generations \
|
|
317
|
-
-H "content-type: application/json" \
|
|
318
|
-
-d '{
|
|
319
|
-
"model": "gpt-image-2",
|
|
320
|
-
"prompt": "生成一张白底红苹果商品图,构图简洁,光线干净。",
|
|
321
|
-
"size": "1024x1024",
|
|
322
|
-
"quality": "low",
|
|
323
|
-
"response_format": "b64_json"
|
|
324
|
-
}'
|
|
325
|
-
```
|
|
200
|
+
Image requests use `gpt-5.4-mini` as the internal orchestration model and pass the requested image model, such as `gpt-image-2`, to the `image_generation` tool.
|
|
326
201
|
|
|
327
|
-
|
|
328
|
-
如果请求里不显式传 `model`,当前默认会使用 `gpt-image-2`。
|
|
202
|
+
For JSON image editing, base64 payloads are about 33% larger than the original image. With the default `32 MiB` body limit, a raw image around `24 MiB` is the practical upper bound before JSON overhead. For larger images or batch workflows, prefer a reachable image URL.
|
|
329
203
|
|
|
330
|
-
|
|
204
|
+
## Limitations
|
|
331
205
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
{
|
|
340
|
-
"image_url": "data:image/png;base64,替换为你的图片base64"
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
"size": "1024x1024",
|
|
344
|
-
"quality": "low",
|
|
345
|
-
"response_format": "b64_json"
|
|
346
|
-
}'
|
|
347
|
-
```
|
|
206
|
+
- This project is intended for local single-user use.
|
|
207
|
+
- Streaming request fields are recognized, but full streaming parity is not implemented for every endpoint.
|
|
208
|
+
- `/v1/images/generations` currently returns `b64_json`; hosted image URLs are not supported.
|
|
209
|
+
- `/v1/images/generations` does not support `n > 1`.
|
|
210
|
+
- `/v1/images/edits` currently supports JSON only. `multipart/form-data`, `mask`, and `file_id` are not yet supported.
|
|
211
|
+
- Very large base64 JSON requests are constrained by `AZT_BODY_LIMIT_MB` and local memory.
|
|
212
|
+
- OpenAI Responses API compatibility is partial and focused on common local client workflows.
|
|
348
213
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
- `plus` 或更高套餐账号可正常调用 `images.generations` / `images.edits`
|
|
352
|
-
- `free` 账号不支持生图,网关会直接返回明确错误,而不是继续请求上游
|
|
353
|
-
- 管理页会显示当前账号的 `plan` 和“生图能力”状态
|
|
354
|
-
- 当当前账号是 `free` 且你选中 `Images` 测试时,“发送请求”按钮会被直接禁用
|
|
355
|
-
|
|
356
|
-
### 6. 当前支持的接口
|
|
357
|
-
|
|
358
|
-
- `GET /_gateway/health`
|
|
359
|
-
- `GET /_gateway/status`
|
|
360
|
-
- `GET /_gateway/models`
|
|
361
|
-
- `POST /_gateway/models/refresh`
|
|
362
|
-
- `GET /_gateway/admin/config`
|
|
363
|
-
- `POST /_gateway/admin/login`
|
|
364
|
-
- `POST /_gateway/admin/logout`
|
|
365
|
-
- `POST /_gateway/admin/profiles/activate`
|
|
366
|
-
- `POST /_gateway/admin/profiles/remove`
|
|
367
|
-
- `PUT /_gateway/admin/settings`
|
|
368
|
-
- `GET /v1/models`
|
|
369
|
-
- `POST /v1/responses`
|
|
370
|
-
- `POST /v1/chat/completions`
|
|
371
|
-
- `POST /v1/images/generations`
|
|
372
|
-
- `POST /v1/images/edits`
|
|
373
|
-
|
|
374
|
-
### 7. 当前支持的主要参数
|
|
375
|
-
|
|
376
|
-
`POST /v1/responses` 当前主要支持:
|
|
377
|
-
|
|
378
|
-
- `model`
|
|
379
|
-
- `input`
|
|
380
|
-
- `instructions`
|
|
381
|
-
- `stream`
|
|
382
|
-
- `tools`
|
|
383
|
-
- `tool_choice`
|
|
384
|
-
- `include`
|
|
385
|
-
- `text`
|
|
386
|
-
- `store`
|
|
387
|
-
- `parallel_tool_calls`
|
|
388
|
-
- `experimental_codex.body`
|
|
389
|
-
- `experimental_codex.allow_unknown_model`
|
|
390
|
-
- `experimental_codex.include_raw`
|
|
391
|
-
|
|
392
|
-
`POST /v1/chat/completions` 当前主要支持:
|
|
393
|
-
|
|
394
|
-
- `model`
|
|
395
|
-
- `messages`
|
|
396
|
-
- `tools`
|
|
397
|
-
- `tool_choice`
|
|
398
|
-
- `response_format`
|
|
399
|
-
- `temperature`
|
|
400
|
-
- `top_p`
|
|
401
|
-
- `presence_penalty`
|
|
402
|
-
- `frequency_penalty`
|
|
403
|
-
- `metadata`
|
|
404
|
-
- `stop`
|
|
405
|
-
- `store`
|
|
406
|
-
- `parallel_tool_calls`
|
|
407
|
-
|
|
408
|
-
`POST /v1/images/generations` 当前主要支持:
|
|
409
|
-
|
|
410
|
-
- `prompt`
|
|
411
|
-
- `model`
|
|
412
|
-
- `n`
|
|
413
|
-
- `size`
|
|
414
|
-
- `quality`
|
|
415
|
-
- `background`
|
|
416
|
-
- `output_format`
|
|
417
|
-
- `output_compression`
|
|
418
|
-
- `moderation`
|
|
419
|
-
- `response_format`
|
|
420
|
-
- `user`
|
|
421
|
-
|
|
422
|
-
`POST /v1/images/edits` 当前主要支持 JSON 请求:
|
|
423
|
-
|
|
424
|
-
- `prompt`
|
|
425
|
-
- `images`
|
|
426
|
-
- `image`
|
|
427
|
-
- `model`
|
|
428
|
-
- `n`
|
|
429
|
-
- `size`
|
|
430
|
-
- `quality`
|
|
431
|
-
- `background`
|
|
432
|
-
- `output_format`
|
|
433
|
-
- `output_compression`
|
|
434
|
-
- `moderation`
|
|
435
|
-
- `response_format`
|
|
436
|
-
- `user`
|
|
437
|
-
|
|
438
|
-
其中 `images` / `image` 支持 `image_url`,可以是 `https://...` URL、`data:image/...;base64,...`,或裸 base64 字符串。
|
|
439
|
-
|
|
440
|
-
### 8. 当前限制
|
|
441
|
-
|
|
442
|
-
- `stream=true` 目前只识别,不返回真实流式结果
|
|
443
|
-
- 还没有完整覆盖 OpenAI Responses API 的全部字段
|
|
444
|
-
- `chat.completions` 暂不支持 `n > 1`
|
|
445
|
-
- `images.generations` 暂不支持 `n > 1`
|
|
446
|
-
- `images.generations` 当前只返回 `b64_json`,暂不支持托管图片 `url`
|
|
447
|
-
- `images.generations` 当前只透传 GPT Image 路径,不兼容 DALL·E 专有参数
|
|
448
|
-
- `images.edits` 当前只支持 `application/json`,暂不支持 `multipart/form-data`、`mask` 和 `file_id`
|
|
449
|
-
- `images.generations` / `images.edits` 对账号套餐有要求;`free` 账号会被网关直接拦截并返回“不支持图片生成”
|
|
450
|
-
- 网关当前默认面向本地单用户使用
|
|
451
|
-
|
|
452
|
-
## 兼容说明
|
|
453
|
-
|
|
454
|
-
代码里仍然保留了 `login`、`status`、`models`、`profiles`、`ask`、`serve`、`clear` 等 CLI 命令,主要用于调试、兼容和后续扩展。
|
|
455
|
-
|
|
456
|
-
账号 JSON 也可以通过 CLI 导入/导出:
|
|
214
|
+
## Security
|
|
457
215
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
azt profiles export "openai-codex:<accountId>" ./profile.json
|
|
463
|
-
```
|
|
216
|
+
- Access tokens, refresh tokens, and ID tokens are equivalent to login credentials.
|
|
217
|
+
- Do not expose the gateway to untrusted networks.
|
|
218
|
+
- Do not share exported account JSON outside trusted environments.
|
|
219
|
+
- Review files under `~/.ai-zero-token/.state` and `~/.codex/auth.json` before copying or publishing local data.
|
|
464
220
|
|
|
465
|
-
|
|
221
|
+
## Development
|
|
222
|
+
|
|
223
|
+
Install dependencies:
|
|
466
224
|
|
|
467
225
|
```bash
|
|
468
|
-
|
|
226
|
+
npm install
|
|
469
227
|
```
|
|
470
228
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
如果你在使用过程中遇到安装问题、账号切换问题、生图异常,或者想交流自己的接入场景,可以通过下面两种方式联系我:
|
|
474
|
-
|
|
475
|
-
- GitHub Issues: [https://github.com/fchangjun/AI-Zero-Token/issues](https://github.com/fchangjun/AI-Zero-Token/issues)
|
|
476
|
-
- 微信交流:先加我微信,备注 `AI Zero Token`,我会再拉你进交流群
|
|
477
|
-
|
|
478
|
-
如果你已经把二维码放到仓库里,可以直接查看:
|
|
479
|
-
|
|
480
|
-

|
|
229
|
+
Run from source:
|
|
481
230
|
|
|
482
|
-
|
|
231
|
+
```bash
|
|
232
|
+
bun src/cli.ts start
|
|
233
|
+
```
|
|
483
234
|
|
|
484
|
-
|
|
235
|
+
Validate:
|
|
485
236
|
|
|
486
|
-
|
|
487
|
-
|
|
237
|
+
```bash
|
|
238
|
+
npm run typecheck
|
|
239
|
+
npm run build
|
|
240
|
+
```
|
|
488
241
|
|
|
489
|
-
|
|
242
|
+
CLI packaging and release notes are documented in [BUILD_CLI.md](BUILD_CLI.md). User-facing changes are tracked in [CHANGELOG.md](CHANGELOG.md).
|
|
490
243
|
|
|
491
|
-
|
|
492
|
-
- 默认模型和服务配置
|
|
244
|
+
## Project Status
|
|
493
245
|
|
|
494
|
-
|
|
246
|
+
AI Zero Token is evolving quickly. The current focus is a reliable local gateway, account transfer workflows, and image generation/editing compatibility for OpenAI-style clients.
|
|
495
247
|
|
|
496
|
-
|
|
497
|
-
CLI 命令解析和命令分发
|
|
498
|
-
- `src/core/`
|
|
499
|
-
核心业务逻辑
|
|
500
|
-
- `src/core/services/`
|
|
501
|
-
认证、模型、聊天、配置服务
|
|
502
|
-
- `src/core/store/`
|
|
503
|
-
本地状态读写
|
|
504
|
-
- `src/core/providers/openai-codex/`
|
|
505
|
-
OpenAI Codex provider 实现
|
|
506
|
-
- `src/server/`
|
|
507
|
-
本地 HTTP 网关
|
|
248
|
+
Issues and feature requests: [GitHub Issues](https://github.com/fchangjun/AI-Zero-Token/issues)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# AI Zero Token
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
AI Zero Token 是一个本地优先的 OpenAI 兼容网关,用于把 ChatGPT/Codex OAuth 账号能力包装成本地 CLI、管理页和 HTTP API。
|
|
6
|
+
|
|
7
|
+
它适合本地单用户场景、原型验证、自动化脚本和 OpenAI-compatible 客户端接入。
|
|
8
|
+
|
|
9
|
+
> 这是实验性质的本地工具,不是 OpenAI 官方产品,也不建议作为生产级多租户网关使用。
|
|
10
|
+
|
|
11
|
+
## 功能
|
|
12
|
+
|
|
13
|
+
- OpenAI 风格本地接口:
|
|
14
|
+
- `GET /v1/models`
|
|
15
|
+
- `POST /v1/responses`
|
|
16
|
+
- `POST /v1/chat/completions`
|
|
17
|
+
- `POST /v1/images/generations`
|
|
18
|
+
- `POST /v1/images/edits`
|
|
19
|
+
- 支持 ChatGPT/Codex OAuth 登录和本地 token 自动刷新。
|
|
20
|
+
- 管理页支持多账号保存、切换和删除。
|
|
21
|
+
- 支持账号 JSON 导入/导出,以及复选框选择后的批量导出。
|
|
22
|
+
- 支持把已保存账号应用到本机 Codex,并自动备份 `~/.codex/auth.json`。
|
|
23
|
+
- 支持 `gpt-image-2` 文生图和 JSON 图生图。
|
|
24
|
+
- 支持上游代理配置,覆盖 OAuth、模型刷新和接口转发。
|
|
25
|
+
- 模型列表优先读取本机 Codex 模型缓存,并支持手动刷新。
|
|
26
|
+
|
|
27
|
+
## 快速开始
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g ai-zero-token
|
|
31
|
+
azt start
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
启动后会打开本地管理页,并暴露本地网关:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
http://127.0.0.1:8787
|
|
38
|
+
http://127.0.0.1:8787/v1
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
如果客户端必须填写 API Key,可以填任意非空占位值;真正起作用的是本地网关里的账号授权。
|
|
42
|
+
|
|
43
|
+
## 管理页
|
|
44
|
+
|
|
45
|
+
管理页是推荐入口,可以完成:
|
|
46
|
+
|
|
47
|
+
- OpenAI Codex OAuth 登录。
|
|
48
|
+
- 导入一个或多个账号 JSON。
|
|
49
|
+
- 切换当前账号。
|
|
50
|
+
- 导出单个账号或勾选导出多个账号。
|
|
51
|
+
- 将已保存账号应用到本机 Codex。
|
|
52
|
+
- 配置默认文本模型和上游代理。
|
|
53
|
+
- 测试 `models`、`responses`、`chat.completions`、`images.generations`、`images.edits`。
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
## API 使用
|
|
58
|
+
|
|
59
|
+
### 模型列表
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
curl http://127.0.0.1:8787/v1/models
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Responses
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
curl http://127.0.0.1:8787/v1/responses \
|
|
69
|
+
-H "content-type: application/json" \
|
|
70
|
+
-d '{"model":"gpt-5.4","input":"请只回复 OK"}'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Chat Completions
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
curl http://127.0.0.1:8787/v1/chat/completions \
|
|
77
|
+
-H "content-type: application/json" \
|
|
78
|
+
-d '{
|
|
79
|
+
"model": "gpt-5.4",
|
|
80
|
+
"messages": [
|
|
81
|
+
{
|
|
82
|
+
"role": "user",
|
|
83
|
+
"content": "请只回复 OK"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 文生图
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
curl http://127.0.0.1:8787/v1/images/generations \
|
|
93
|
+
-H "content-type: application/json" \
|
|
94
|
+
-d '{
|
|
95
|
+
"model": "gpt-image-2",
|
|
96
|
+
"prompt": "生成一张白底红苹果商品图,构图简洁,光线干净。",
|
|
97
|
+
"size": "1024x1024",
|
|
98
|
+
"quality": "low",
|
|
99
|
+
"response_format": "b64_json"
|
|
100
|
+
}'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
响应会返回 OpenAI 风格的 `data[].b64_json`。
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
### 图生图
|
|
108
|
+
|
|
109
|
+
`/v1/images/edits` 当前支持 JSON 请求,图片可以使用 URL、data URL 或裸 base64:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
curl http://127.0.0.1:8787/v1/images/edits \
|
|
113
|
+
-H "content-type: application/json" \
|
|
114
|
+
-d '{
|
|
115
|
+
"model": "gpt-image-2",
|
|
116
|
+
"prompt": "参考这张图,生成一张更适合科技产品广告的版本。",
|
|
117
|
+
"images": [
|
|
118
|
+
{
|
|
119
|
+
"image_url": "data:image/png;base64,替换为你的图片base64"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"size": "1024x1024",
|
|
123
|
+
"quality": "low",
|
|
124
|
+
"response_format": "b64_json"
|
|
125
|
+
}'
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
更多示例见 [docs/API_USAGE.md](docs/API_USAGE.md)。
|
|
129
|
+
|
|
130
|
+
## 账号管理
|
|
131
|
+
|
|
132
|
+
AI Zero Token 的账号状态默认保存在:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
~/.ai-zero-token/.state
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
管理页支持:
|
|
139
|
+
|
|
140
|
+
- OAuth 登录。
|
|
141
|
+
- 从单个 profile、数组或 `profiles` bundle 导入。
|
|
142
|
+
- 导出单个账号。
|
|
143
|
+
- 使用复选框批量导出已选择账号。
|
|
144
|
+
- 删除账号和切换当前账号。
|
|
145
|
+
|
|
146
|
+
导出的账号 JSON 包含认证 token,等同于登录凭据,只应在可信环境中使用。
|
|
147
|
+
|
|
148
|
+
### 应用到 Codex
|
|
149
|
+
|
|
150
|
+
`应用到 Codex` 会把选中的账号写入:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
~/.codex/auth.json
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
写入前会把原文件备份为 `auth.json.azt-backup-*`。新的 Codex 会话会使用该账号。
|
|
157
|
+
|
|
158
|
+
## 配置
|
|
159
|
+
|
|
160
|
+
默认监听:
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
0.0.0.0:8787
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
本地网关 Base URL:
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
http://127.0.0.1:8787/v1
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
限制浏览器 CORS 来源:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
AZT_CORS_ORIGIN=http://127.0.0.1:8124 azt start
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
多个来源用英文逗号分隔:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
AZT_CORS_ORIGIN=http://127.0.0.1:8124,http://localhost:3000 azt start
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
覆盖持久化状态目录:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
AI_ZERO_TOKEN_HOME=/path/to/home azt start
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
默认请求体上限是 `32 MiB`,用于让 JSON base64 图片在本地图片编辑场景里更实用。可以用下面的环境变量覆盖:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
AZT_BODY_LIMIT_MB=64 azt start
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 生图额度
|
|
197
|
+
|
|
198
|
+
ChatGPT Images 的可用性和额度由上游账号决定。Free 账号可以尝试生图,但限制比付费账号更严格,官方没有公开固定张数。网关不会本地硬拦截 Free 账号,而是展示上游真实返回,例如 `usage_limit_reached` 和重置时间。
|
|
199
|
+
|
|
200
|
+
图片请求内部使用 `gpt-5.4-mini` 作为编排模型,并把请求里的图片模型(例如 `gpt-image-2`)传给 `image_generation` tool。
|
|
201
|
+
|
|
202
|
+
对于 JSON 图生图,base64 通常比原始图片大约 33%。在默认 `32 MiB` 请求体上限下,原始图片约 `24 MiB` 是比较实际的上限,再大就容易被 JSON 开销和本地内存影响。大图或批量场景建议优先使用可访问的图片 URL。
|
|
203
|
+
|
|
204
|
+
## 当前限制
|
|
205
|
+
|
|
206
|
+
- 项目默认面向本地单用户使用。
|
|
207
|
+
- `stream=true` 目前只识别,并未对所有接口实现完整流式兼容。
|
|
208
|
+
- `/v1/images/generations` 当前返回 `b64_json`,暂不支持托管图片 URL。
|
|
209
|
+
- `/v1/images/generations` 暂不支持 `n > 1`。
|
|
210
|
+
- `/v1/images/edits` 当前只支持 JSON,暂不支持 `multipart/form-data`、`mask` 和 `file_id`。
|
|
211
|
+
- 超大的 base64 JSON 请求受 `AZT_BODY_LIMIT_MB` 和本地内存限制。
|
|
212
|
+
- OpenAI Responses API 兼容范围是常见本地客户端工作流,不是完整实现。
|
|
213
|
+
|
|
214
|
+
## 安全
|
|
215
|
+
|
|
216
|
+
- `access_token`、`refresh_token`、`id_token` 都等同于登录凭据。
|
|
217
|
+
- 不要把本地网关暴露给不可信网络。
|
|
218
|
+
- 不要在不可信环境中传递导出的账号 JSON。
|
|
219
|
+
- 复制或发布本地文件前,请检查 `~/.ai-zero-token/.state` 和 `~/.codex/auth.json`。
|
|
220
|
+
|
|
221
|
+
## 开发
|
|
222
|
+
|
|
223
|
+
安装依赖:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm install
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
源码运行:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
bun src/cli.ts start
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
验证:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm run typecheck
|
|
239
|
+
npm run build
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
CLI 构建和发布说明见 [BUILD_CLI.md](BUILD_CLI.md)。用户可见变更见 [CHANGELOG.md](CHANGELOG.md)。
|
|
243
|
+
|
|
244
|
+
## 项目状态
|
|
245
|
+
|
|
246
|
+
AI Zero Token 仍在快速迭代。当前重点是稳定本地网关、账号迁移工作流,以及 OpenAI 风格客户端的图片生成/编辑兼容性。
|
|
247
|
+
|
|
248
|
+
反馈和问题:[GitHub Issues](https://github.com/fchangjun/AI-Zero-Token/issues)
|
|
@@ -44,6 +44,7 @@ async function runServeCommand(args, options) {
|
|
|
44
44
|
console.log(`admin: ${adminUrl}`);
|
|
45
45
|
console.log(`apiBase: ${adminUrl}/v1`);
|
|
46
46
|
console.log(`corsOrigin: ${server.corsOrigin}`);
|
|
47
|
+
console.log(`bodyLimitMB: ${(server.bodyLimit / 1024 / 1024).toFixed(1)}`);
|
|
47
48
|
console.log(`activeProvider: ${status.activeProvider ?? "none"}`);
|
|
48
49
|
console.log(`defaultModel: ${status.defaultModel}`);
|
|
49
50
|
if (shouldOpenBrowser) {
|
|
@@ -6,6 +6,7 @@ const SUPPORTED_IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
6
6
|
"gpt-image-1.5",
|
|
7
7
|
"gpt-image-2"
|
|
8
8
|
]);
|
|
9
|
+
const IMAGE_ORCHESTRATOR_MODEL = "gpt-5.4-mini";
|
|
9
10
|
const SUPPORTED_IMAGE_QUALITIES = /* @__PURE__ */ new Set([
|
|
10
11
|
"low",
|
|
11
12
|
"medium",
|
|
@@ -260,15 +261,9 @@ class ImageService {
|
|
|
260
261
|
}
|
|
261
262
|
return model;
|
|
262
263
|
}
|
|
263
|
-
isFreePlan(profile) {
|
|
264
|
-
return profile.quota?.planType === "free";
|
|
265
|
-
}
|
|
266
264
|
async generate(request) {
|
|
267
265
|
const profile = await this.deps.authService.requireUsableProfile("openai-codex");
|
|
268
|
-
|
|
269
|
-
throw new Error("\u5F53\u524D\u8D26\u53F7\u4E3A free \u5957\u9910\uFF0C\u4E0D\u652F\u6301\u56FE\u7247\u751F\u6210\u3002\u8BF7\u5207\u6362\u5230 Plus \u6216\u66F4\u9AD8\u5957\u9910\u8D26\u53F7\u3002");
|
|
270
|
-
}
|
|
271
|
-
const orchestratorModel = await this.deps.configService.getDefaultModel();
|
|
266
|
+
const orchestratorModel = IMAGE_ORCHESTRATOR_MODEL;
|
|
272
267
|
const requestedImageModel = this.resolveRequestedImageModel(request.model);
|
|
273
268
|
const requestSummary = {
|
|
274
269
|
requestedImageModel,
|
|
@@ -1933,12 +1933,12 @@ function renderAdminPage() {
|
|
|
1933
1933
|
title.textContent = "\u53D1\u73B0\u65B0\u7248\u672C\u53EF\u66F4\u65B0";
|
|
1934
1934
|
detail.textContent = "\u5F53\u524D\u7248\u672C " + versionStatus.currentVersion + "\uFF0C\u6700\u65B0\u7248\u672C "
|
|
1935
1935
|
+ versionStatus.latestVersion + "\u3002\u66F4\u65B0\u540E\u53EF\u83B7\u5F97\u6700\u65B0\u6A21\u578B\u5217\u8868\u903B\u8F91\u3001\u7BA1\u7406\u9875\u4F53\u9A8C\u548C\u63A5\u53E3\u4FEE\u590D\u3002";
|
|
1936
|
-
command.textContent = "npm install -g " + versionStatus.packageName
|
|
1936
|
+
command.textContent = "npm install -g " + versionStatus.packageName;
|
|
1937
1937
|
panel.classList.add("is-visible");
|
|
1938
1938
|
}
|
|
1939
1939
|
|
|
1940
1940
|
function supportsImageGeneration(profile) {
|
|
1941
|
-
return
|
|
1941
|
+
return Boolean(profile);
|
|
1942
1942
|
}
|
|
1943
1943
|
|
|
1944
1944
|
function getImageCapability(profile) {
|
|
@@ -1954,10 +1954,10 @@ function renderAdminPage() {
|
|
|
1954
1954
|
const planType = getPlanType(profile);
|
|
1955
1955
|
if (planType === "free") {
|
|
1956
1956
|
return {
|
|
1957
|
-
supported:
|
|
1958
|
-
label: "\u751F\u56FE
|
|
1959
|
-
detail: "free \
|
|
1960
|
-
badgeClass: "
|
|
1957
|
+
supported: true,
|
|
1958
|
+
label: "\u53EF\u5C1D\u8BD5\u751F\u56FE",
|
|
1959
|
+
detail: "free \u8D26\u53F7\u53EF\u5C1D\u8BD5\u56FE\u7247\u751F\u6210\uFF0C\u989D\u5EA6\u548C\u53EF\u7528\u6027\u4EE5\u4E0A\u6E38\u8FD4\u56DE\u4E3A\u51C6\u3002",
|
|
1960
|
+
badgeClass: "orange",
|
|
1961
1961
|
};
|
|
1962
1962
|
}
|
|
1963
1963
|
|
|
@@ -2844,10 +2844,10 @@ function renderAdminPage() {
|
|
|
2844
2844
|
const isImageEndpoint = endpointSelect.value === "/v1/images/generations" || endpointSelect.value === "/v1/images/edits";
|
|
2845
2845
|
imageCapabilityHint.textContent = capability.detail;
|
|
2846
2846
|
imageCapabilityHint.className = capability.supported && !isImageEndpoint ? "hint" : "hint warn";
|
|
2847
|
-
runTestBtn.disabled = isImageEndpoint && !
|
|
2847
|
+
runTestBtn.disabled = isImageEndpoint && !config.profile;
|
|
2848
2848
|
if (isImageEndpoint && !capability.supported) {
|
|
2849
2849
|
testerMeta.textContent = capability.label;
|
|
2850
|
-
} else if (testerMeta.textContent === capability.label || testerMeta.textContent === "\u751F\u56FE\u53D7\u9650") {
|
|
2850
|
+
} else if (testerMeta.textContent === capability.label || testerMeta.textContent === "\u751F\u56FE\u53D7\u9650" || testerMeta.textContent === "\u53EF\u5C1D\u8BD5\u751F\u56FE") {
|
|
2851
2851
|
testerMeta.textContent = "\u51C6\u5907\u5C31\u7EEA";
|
|
2852
2852
|
}
|
|
2853
2853
|
}
|
|
@@ -2878,7 +2878,7 @@ function renderAdminPage() {
|
|
|
2878
2878
|
authStatus.textContent = config.status.loggedIn
|
|
2879
2879
|
? (supportsImageGeneration(config.profile)
|
|
2880
2880
|
? "\u7F51\u5173\u5DF2\u53EF\u76F4\u63A5\u8F6C\u53D1\u8BF7\u6C42\uFF0C\u53EF\u4EE5\u5728\u4E0B\u65B9\u5207\u6362\u9ED8\u8BA4\u6A21\u578B\u5E76\u53D1\u9001\u6D4B\u8BD5\u8BF7\u6C42\u3002"
|
|
2881
|
-
: "\u5F53\u524D\u8D26\u53F7\
|
|
2881
|
+
: "\u5F53\u524D\u8D26\u53F7\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u540E\u518D\u6D4B\u8BD5\u63A5\u53E3\u3002")
|
|
2882
2882
|
: "\u8BF7\u5148\u70B9\u51FB\u201C\u65B0\u589E\u8D26\u53F7\u201D\uFF0C\u5B8C\u6210 OAuth \u540E\u518D\u6D4B\u8BD5\u63A5\u53E3\u3002";
|
|
2883
2883
|
if (!requestBody.value) {
|
|
2884
2884
|
requestBody.value = buildExample(endpointSelect.value || "/v1/chat/completions");
|
package/dist/server/app.js
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { ConfigService } from "../core/services/config-service.js";
|
|
3
3
|
import { createApp } from "./app.js";
|
|
4
|
+
const DEFAULT_BODY_LIMIT_MB = 32;
|
|
4
5
|
function resolveCorsOrigin() {
|
|
5
6
|
const raw = process.env.AZT_CORS_ORIGIN?.trim();
|
|
6
7
|
if (!raw || raw === "*") {
|
|
@@ -9,9 +10,22 @@ function resolveCorsOrigin() {
|
|
|
9
10
|
const values = raw.split(",").map((item) => item.trim()).filter(Boolean);
|
|
10
11
|
return values.length <= 1 ? values[0] ?? true : values;
|
|
11
12
|
}
|
|
13
|
+
function resolveBodyLimitBytes() {
|
|
14
|
+
const raw = process.env.AZT_BODY_LIMIT_MB?.trim();
|
|
15
|
+
if (!raw) {
|
|
16
|
+
return DEFAULT_BODY_LIMIT_MB * 1024 * 1024;
|
|
17
|
+
}
|
|
18
|
+
const value = Number(raw);
|
|
19
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
20
|
+
return DEFAULT_BODY_LIMIT_MB * 1024 * 1024;
|
|
21
|
+
}
|
|
22
|
+
return Math.floor(value * 1024 * 1024);
|
|
23
|
+
}
|
|
12
24
|
async function startServer(params) {
|
|
25
|
+
const bodyLimit = resolveBodyLimitBytes();
|
|
13
26
|
const app = createApp({
|
|
14
|
-
corsOrigin: resolveCorsOrigin()
|
|
27
|
+
corsOrigin: resolveCorsOrigin(),
|
|
28
|
+
bodyLimit
|
|
15
29
|
});
|
|
16
30
|
const configService = new ConfigService();
|
|
17
31
|
const defaults = await configService.getServerConfig();
|
|
@@ -25,7 +39,8 @@ async function startServer(params) {
|
|
|
25
39
|
app,
|
|
26
40
|
host,
|
|
27
41
|
port,
|
|
28
|
-
corsOrigin: process.env.AZT_CORS_ORIGIN?.trim() || "*"
|
|
42
|
+
corsOrigin: process.env.AZT_CORS_ORIGIN?.trim() || "*",
|
|
43
|
+
bodyLimit
|
|
29
44
|
};
|
|
30
45
|
}
|
|
31
46
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-zero-token",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Local-first OpenAI-compatible AI CLI and gateway with Codex OAuth, multi-account management, and gpt-image-2 image generation/editing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"CHANGELOG.md",
|
|
61
61
|
"docs/API_USAGE.md",
|
|
62
62
|
"README.md",
|
|
63
|
+
"README.zh-CN.md",
|
|
63
64
|
"package.json"
|
|
64
65
|
]
|
|
65
66
|
}
|