ai-zero-token 2.0.1 → 2.0.3
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 +20 -0
- package/README.md +13 -5
- package/README.zh-CN.md +13 -5
- package/admin-ui/dist/assets/InfoRow-0ULI9iI3.js +1 -0
- package/admin-ui/dist/assets/accounts-DymL4WIa.js +2 -0
- package/admin-ui/dist/assets/activity-D21-Xrc4.js +1 -0
- package/admin-ui/dist/assets/app-mark-nsRs4vo7.svg +8 -0
- package/admin-ui/dist/assets/circle-check-ZYtn9GqY.js +1 -0
- package/admin-ui/dist/assets/clock-3-BzDANsVk.js +1 -0
- package/admin-ui/dist/assets/docs-BRNWAMPw.css +1 -0
- package/admin-ui/dist/assets/docs-DtO-AOWU.js +1735 -0
- package/admin-ui/dist/assets/earth-DFdZaQIi.js +1 -0
- package/admin-ui/dist/assets/image-bed-yIVQ4dKs.js +1 -0
- package/admin-ui/dist/assets/index-By4r-wy3.css +1 -0
- package/admin-ui/dist/assets/index-DRe-tByu.js +10 -0
- package/admin-ui/dist/assets/jsx-runtime-DqpGtLhh.js +1 -0
- package/admin-ui/dist/assets/launch-CQXYrl-h.js +1 -0
- package/admin-ui/dist/assets/logs-awABDg1C.js +1 -0
- package/admin-ui/dist/assets/network-detect-sSrnwZqf.js +1 -0
- package/admin-ui/dist/assets/overview-BbSON0Jl.js +1 -0
- package/admin-ui/dist/assets/profiles-DMOjJORP.js +1 -0
- package/admin-ui/dist/assets/refresh-cw-CAAH2rqe.js +1 -0
- package/admin-ui/dist/assets/search-B2hz41D3.js +1 -0
- package/admin-ui/dist/assets/server-BrjJPb9D.js +1 -0
- package/admin-ui/dist/assets/settings-DvRiHS7i.js +1 -0
- package/admin-ui/dist/assets/tester-CftPgRE9.js +3 -0
- package/admin-ui/dist/assets/upload-CwXb7Q1b.js +1 -0
- package/admin-ui/dist/assets/zap-B4_oDbCp.js +1 -0
- package/admin-ui/dist/index.html +5 -3
- package/build/icon.icns +0 -0
- package/build/icon.ico +0 -0
- package/build/icon.png +0 -0
- package/build/icon.svg +8 -0
- package/build/mac-install-guide.txt +25 -0
- package/dist/core/context.js +3 -0
- package/dist/core/providers/http-client.js +11 -4
- package/dist/core/services/auth-service.js +88 -12
- package/dist/core/services/config-service.js +87 -23
- package/dist/core/services/github-image-bed-service.js +264 -0
- package/dist/core/services/network-detect-service.js +189 -74
- package/dist/core/services/version-service.js +1 -1
- package/dist/core/store/github-image-bed-history-store.js +68 -0
- package/dist/core/store/github-image-bed-store.js +52 -0
- package/dist/core/store/profile-store.js +73 -32
- package/dist/core/store/settings-store.js +14 -0
- package/dist/desktop/main.js +158 -6
- package/dist/server/app.js +168 -26
- package/dist/server/index.js +41 -15
- package/docs/DESKTOP_RELEASE.md +35 -3
- package/docs/PRODUCT_UPDATE_DESKTOP_TOOLBOX.md +2 -2
- package/package.json +34 -2
- package/admin-ui/dist/assets/app-mark-Gd2QnHMO.svg +0 -9
- package/admin-ui/dist/assets/index-DNzR8XR7.css +0 -1
- package/admin-ui/dist/assets/index-DZMegNPs.js +0 -1745
- package/dist/server/admin-page.js +0 -4586
|
@@ -0,0 +1,1735 @@
|
|
|
1
|
+
import{a as e,n as t,r as n,t as r}from"./jsx-runtime-DqpGtLhh.js";import{t as i}from"./server-BrjJPb9D.js";import{b as a,f as o,g as s,n as c,v as l,y as u}from"./index-DRe-tByu.js";var d=t(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),f=`# AI-Zero-Token Local Gateway Skill
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This skill tells the LLM how to integrate a webpage, local tool, or Vibe Coding project with the local AI-Zero-Token gateway.
|
|
6
|
+
|
|
7
|
+
AI-Zero-Token is a local-first personal AI gateway. It exposes OpenAI-style local HTTP APIs so that a frontend page, script, or local automation tool can call available ChatGPT / Codex account capabilities through a local endpoint.
|
|
8
|
+
|
|
9
|
+
Use this skill when the user wants to build:
|
|
10
|
+
|
|
11
|
+
- AI chat assistant
|
|
12
|
+
- text generation tool
|
|
13
|
+
- copywriting generator
|
|
14
|
+
- prompt generator
|
|
15
|
+
- image generation tool
|
|
16
|
+
- image editing / image-to-image tool
|
|
17
|
+
- poster generator
|
|
18
|
+
- product image generator
|
|
19
|
+
- social media cover generator
|
|
20
|
+
- icon or logo inspiration generator
|
|
21
|
+
- UI inspiration generator
|
|
22
|
+
- Vibe Coding webpage that needs AI capability
|
|
23
|
+
- local automation workflow that needs LLM or image generation
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Local Gateway Assumptions
|
|
28
|
+
|
|
29
|
+
Assume the user has already started AI-Zero-Token locally.
|
|
30
|
+
|
|
31
|
+
Default local management page:
|
|
32
|
+
|
|
33
|
+
\`\`\`text
|
|
34
|
+
http://127.0.0.1:8787
|
|
35
|
+
\`\`\`
|
|
36
|
+
|
|
37
|
+
OpenAI-compatible Base URL:
|
|
38
|
+
|
|
39
|
+
\`\`\`text
|
|
40
|
+
http://127.0.0.1:8787/v1
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
When using OpenAI-compatible SDKs or API clients, set:
|
|
44
|
+
|
|
45
|
+
\`\`\`text
|
|
46
|
+
baseURL = "http://127.0.0.1:8787/v1"
|
|
47
|
+
apiKey = "local"
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
The API key can be any non-empty placeholder string because the real authentication is handled by the local AI-Zero-Token gateway.
|
|
51
|
+
|
|
52
|
+
Do not ask the user to provide a real OpenAI API key unless the user explicitly wants to use the official OpenAI API instead of the local gateway.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Startup Command Reference
|
|
57
|
+
|
|
58
|
+
If the generated project includes user instructions, mention the user can start AI-Zero-Token with:
|
|
59
|
+
|
|
60
|
+
\`\`\`bash
|
|
61
|
+
npx ai-zero-token start
|
|
62
|
+
\`\`\`
|
|
63
|
+
|
|
64
|
+
or install globally:
|
|
65
|
+
|
|
66
|
+
\`\`\`bash
|
|
67
|
+
npm install -g ai-zero-token
|
|
68
|
+
azt start
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
After startup, the local management page is usually available at:
|
|
72
|
+
|
|
73
|
+
\`\`\`text
|
|
74
|
+
http://127.0.0.1:8787
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
The OpenAI-compatible API Base URL is:
|
|
78
|
+
|
|
79
|
+
\`\`\`text
|
|
80
|
+
http://127.0.0.1:8787/v1
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
If global npm installation fails with \`EACCES permission denied\`, recommend using:
|
|
84
|
+
|
|
85
|
+
\`\`\`bash
|
|
86
|
+
npx ai-zero-token start
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Available Interfaces
|
|
92
|
+
|
|
93
|
+
### 1. List Models
|
|
94
|
+
|
|
95
|
+
Use this endpoint when the app needs to show available models.
|
|
96
|
+
|
|
97
|
+
\`\`\`http
|
|
98
|
+
GET http://127.0.0.1:8787/v1/models
|
|
99
|
+
\`\`\`
|
|
100
|
+
|
|
101
|
+
Example JavaScript:
|
|
102
|
+
|
|
103
|
+
\`\`\`js
|
|
104
|
+
async function listModels() {
|
|
105
|
+
const res = await fetch("http://127.0.0.1:8787/v1/models", {
|
|
106
|
+
method: "GET",
|
|
107
|
+
headers: {
|
|
108
|
+
"Authorization": "Bearer local"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (!res.ok) {
|
|
113
|
+
throw new Error(\`Failed to list models: \${res.status}\`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return await res.json();
|
|
117
|
+
}
|
|
118
|
+
\`\`\`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### 2. Text / Reasoning / Coding Generation
|
|
123
|
+
|
|
124
|
+
Preferred endpoint:
|
|
125
|
+
|
|
126
|
+
\`\`\`http
|
|
127
|
+
POST http://127.0.0.1:8787/v1/responses
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
Use this endpoint for:
|
|
131
|
+
|
|
132
|
+
- AI assistant replies
|
|
133
|
+
- text generation
|
|
134
|
+
- copywriting
|
|
135
|
+
- prompt optimization
|
|
136
|
+
- coding assistance
|
|
137
|
+
- reasoning tasks
|
|
138
|
+
- content rewriting
|
|
139
|
+
- document drafting
|
|
140
|
+
|
|
141
|
+
Default recommended model:
|
|
142
|
+
|
|
143
|
+
\`\`\`text
|
|
144
|
+
gpt-5.5
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
If \`gpt-5.5\` is not available, allow the user or UI to switch models.
|
|
148
|
+
|
|
149
|
+
Example request:
|
|
150
|
+
|
|
151
|
+
\`\`\`js
|
|
152
|
+
async function generateText(input) {
|
|
153
|
+
const res = await fetch("http://127.0.0.1:8787/v1/responses", {
|
|
154
|
+
method: "POST",
|
|
155
|
+
headers: {
|
|
156
|
+
"Content-Type": "application/json",
|
|
157
|
+
"Authorization": "Bearer local"
|
|
158
|
+
},
|
|
159
|
+
body: JSON.stringify({
|
|
160
|
+
model: "gpt-5.5",
|
|
161
|
+
input
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (!res.ok) {
|
|
166
|
+
const errText = await res.text();
|
|
167
|
+
throw new Error(\`Text generation failed: \${res.status} \${errText}\`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const data = await res.json();
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
data.output_text ||
|
|
174
|
+
data.text ||
|
|
175
|
+
data.content ||
|
|
176
|
+
data.choices?.[0]?.message?.content ||
|
|
177
|
+
JSON.stringify(data, null, 2)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
\`\`\`
|
|
181
|
+
|
|
182
|
+
When building a frontend app, show loading state while the request is pending and display a readable error message if the request fails.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### 3. Chat Completions Compatibility
|
|
187
|
+
|
|
188
|
+
Use this endpoint when the user asks for an OpenAI-compatible chat app or when a template already uses \`/v1/chat/completions\`.
|
|
189
|
+
|
|
190
|
+
\`\`\`http
|
|
191
|
+
POST http://127.0.0.1:8787/v1/chat/completions
|
|
192
|
+
\`\`\`
|
|
193
|
+
|
|
194
|
+
Example request:
|
|
195
|
+
|
|
196
|
+
\`\`\`js
|
|
197
|
+
async function chat(messages) {
|
|
198
|
+
const res = await fetch("http://127.0.0.1:8787/v1/chat/completions", {
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers: {
|
|
201
|
+
"Content-Type": "application/json",
|
|
202
|
+
"Authorization": "Bearer local"
|
|
203
|
+
},
|
|
204
|
+
body: JSON.stringify({
|
|
205
|
+
model: "gpt-5.5",
|
|
206
|
+
messages
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (!res.ok) {
|
|
211
|
+
const errText = await res.text();
|
|
212
|
+
throw new Error(\`Chat completion failed: \${res.status} \${errText}\`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const data = await res.json();
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
data.choices?.[0]?.message?.content ||
|
|
219
|
+
data.output_text ||
|
|
220
|
+
JSON.stringify(data, null, 2)
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
\`\`\`
|
|
224
|
+
|
|
225
|
+
Use this for chat UI components, OpenAI-compatible templates, or existing chat SDK style code.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### 4. Image Generation
|
|
230
|
+
|
|
231
|
+
Use this endpoint when the user wants image generation.
|
|
232
|
+
|
|
233
|
+
\`\`\`http
|
|
234
|
+
POST http://127.0.0.1:8787/v1/images/generations
|
|
235
|
+
\`\`\`
|
|
236
|
+
|
|
237
|
+
Use this endpoint for:
|
|
238
|
+
|
|
239
|
+
- poster generation
|
|
240
|
+
- product image generation
|
|
241
|
+
- social media image generation
|
|
242
|
+
- cover image generation
|
|
243
|
+
- icon inspiration
|
|
244
|
+
- logo inspiration
|
|
245
|
+
- UI visual inspiration
|
|
246
|
+
- marketing image generation
|
|
247
|
+
- illustration generation
|
|
248
|
+
|
|
249
|
+
Default recommended image model:
|
|
250
|
+
|
|
251
|
+
\`\`\`text
|
|
252
|
+
gpt-image-2
|
|
253
|
+
\`\`\`
|
|
254
|
+
|
|
255
|
+
Example request:
|
|
256
|
+
|
|
257
|
+
\`\`\`js
|
|
258
|
+
async function generateImage(prompt, size = "1024x1024") {
|
|
259
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/generations", {
|
|
260
|
+
method: "POST",
|
|
261
|
+
headers: {
|
|
262
|
+
"Content-Type": "application/json",
|
|
263
|
+
"Authorization": "Bearer local"
|
|
264
|
+
},
|
|
265
|
+
body: JSON.stringify({
|
|
266
|
+
model: "gpt-image-2",
|
|
267
|
+
prompt,
|
|
268
|
+
size,
|
|
269
|
+
n: 1
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
if (!res.ok) {
|
|
274
|
+
const errText = await res.text();
|
|
275
|
+
throw new Error(\`Image generation failed: \${res.status} \${errText}\`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const data = await res.json();
|
|
279
|
+
|
|
280
|
+
const image =
|
|
281
|
+
data.data?.[0]?.url ||
|
|
282
|
+
data.data?.[0]?.b64_json ||
|
|
283
|
+
data.output?.[0]?.url ||
|
|
284
|
+
data.url ||
|
|
285
|
+
data.image;
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
raw: data,
|
|
289
|
+
image
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
\`\`\`
|
|
293
|
+
|
|
294
|
+
When displaying generated images:
|
|
295
|
+
|
|
296
|
+
- If the response contains a URL, use it directly as the \`src\`.
|
|
297
|
+
- If the response contains \`b64_json\`, convert it to a data URL:
|
|
298
|
+
|
|
299
|
+
\`\`\`js
|
|
300
|
+
const src = \`data:image/png;base64,\${b64_json}\`;
|
|
301
|
+
\`\`\`
|
|
302
|
+
|
|
303
|
+
- Always show the raw response in a collapsible debug panel if this is a prototype or developer-facing tool.
|
|
304
|
+
- Show a helpful error if no image URL or base64 data is found.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
### 5. Image Editing / Image-to-Image
|
|
309
|
+
|
|
310
|
+
Use this endpoint when the user wants to edit an existing image or use one or more reference images.
|
|
311
|
+
|
|
312
|
+
\`\`\`http
|
|
313
|
+
POST http://127.0.0.1:8787/v1/images/edits
|
|
314
|
+
\`\`\`
|
|
315
|
+
|
|
316
|
+
AI-Zero-Token currently supports the JSON version of this endpoint. Use \`images[].image_url\` with either:
|
|
317
|
+
|
|
318
|
+
- an \`https://...\` image URL
|
|
319
|
+
- a \`data:image/...;base64,...\` data URL
|
|
320
|
+
- a bare base64 string, which the gateway treats as a PNG data URL
|
|
321
|
+
|
|
322
|
+
Do not use \`multipart/form-data\`, \`mask\`, or \`file_id\` unless the user explicitly says their installed AI-Zero-Token version supports them.
|
|
323
|
+
|
|
324
|
+
Example request:
|
|
325
|
+
|
|
326
|
+
\`\`\`js
|
|
327
|
+
async function editImage(prompt, imageUrlOrBase64, size = "1024x1024") {
|
|
328
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/edits", {
|
|
329
|
+
method: "POST",
|
|
330
|
+
headers: {
|
|
331
|
+
"Content-Type": "application/json",
|
|
332
|
+
"Authorization": "Bearer local"
|
|
333
|
+
},
|
|
334
|
+
body: JSON.stringify({
|
|
335
|
+
model: "gpt-image-2",
|
|
336
|
+
prompt,
|
|
337
|
+
images: [
|
|
338
|
+
{
|
|
339
|
+
image_url: imageUrlOrBase64
|
|
340
|
+
}
|
|
341
|
+
],
|
|
342
|
+
size,
|
|
343
|
+
quality: "low",
|
|
344
|
+
response_format: "b64_json"
|
|
345
|
+
})
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
if (!res.ok) {
|
|
349
|
+
const errText = await res.text();
|
|
350
|
+
throw new Error(\`Image edit failed: \${res.status} \${errText}\`);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const data = await res.json();
|
|
354
|
+
const image = data.data?.[0]?.b64_json || data.data?.[0]?.url || data.image;
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
raw: data,
|
|
358
|
+
image
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
\`\`\`
|
|
362
|
+
|
|
363
|
+
When building a frontend for image editing:
|
|
364
|
+
|
|
365
|
+
- Let the user paste an image URL.
|
|
366
|
+
- Optionally support local file upload by converting the file to a base64 data URL in the browser, then send it as \`images[].image_url\`.
|
|
367
|
+
- Show the edited image using \`data:image/png;base64,...\` when the response contains \`b64_json\`.
|
|
368
|
+
- Mention that mask/inpainting is not supported by this JSON integration yet.
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Frontend Integration Rules
|
|
373
|
+
|
|
374
|
+
When generating a web app that uses AI-Zero-Token:
|
|
375
|
+
|
|
376
|
+
1. Use \`http://127.0.0.1:8787/v1\` as the default Base URL.
|
|
377
|
+
2. Use \`local\` as the default API Key placeholder.
|
|
378
|
+
3. Do not hardcode a real OpenAI API key.
|
|
379
|
+
4. Provide editable fields for:
|
|
380
|
+
- Base URL
|
|
381
|
+
- text model name
|
|
382
|
+
- image model name
|
|
383
|
+
- prompt / input
|
|
384
|
+
5. Use \`gpt-5.5\` as the default text model.
|
|
385
|
+
6. Use \`gpt-image-2\` as the default image model.
|
|
386
|
+
7. Add loading states.
|
|
387
|
+
8. Add error display.
|
|
388
|
+
9. Add a clear result area.
|
|
389
|
+
10. Add a copy button for text outputs.
|
|
390
|
+
11. Add an image preview area for image outputs.
|
|
391
|
+
12. For image editing tools, accept either pasted image URLs or local files converted to base64 data URLs.
|
|
392
|
+
13. Add a download button for generated or edited images when possible.
|
|
393
|
+
14. Keep all calls client-side for local prototype projects unless the user asks for a backend.
|
|
394
|
+
15. If the browser reports a CORS error, tell the user to check whether AI-Zero-Token is running and whether the gateway allows browser requests.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Recommended UI Patterns
|
|
399
|
+
|
|
400
|
+
For a simple Vibe Coding webpage, create:
|
|
401
|
+
|
|
402
|
+
- A settings panel:
|
|
403
|
+
- Base URL
|
|
404
|
+
- Text model
|
|
405
|
+
- Image model
|
|
406
|
+
- A text generation panel:
|
|
407
|
+
- textarea for input
|
|
408
|
+
- button: Generate Text
|
|
409
|
+
- output area
|
|
410
|
+
- An image generation panel:
|
|
411
|
+
- textarea for prompt
|
|
412
|
+
- size selector
|
|
413
|
+
- button: Generate Image
|
|
414
|
+
- image preview area
|
|
415
|
+
- For image editing tools:
|
|
416
|
+
- image URL input or file picker
|
|
417
|
+
- textarea for edit instruction
|
|
418
|
+
- button: Edit Image
|
|
419
|
+
- before / after image preview
|
|
420
|
+
- A debug panel:
|
|
421
|
+
- raw JSON response
|
|
422
|
+
- error message
|
|
423
|
+
|
|
424
|
+
Use a clean layout that is easy for non-developers to understand.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## Default Models
|
|
429
|
+
|
|
430
|
+
Use these defaults unless the user says otherwise:
|
|
431
|
+
|
|
432
|
+
\`\`\`text
|
|
433
|
+
Text model: gpt-5.5
|
|
434
|
+
Image model: gpt-image-2
|
|
435
|
+
\`\`\`
|
|
436
|
+
|
|
437
|
+
If a model call fails, suggest:
|
|
438
|
+
|
|
439
|
+
1. Check whether AI-Zero-Token is running.
|
|
440
|
+
2. Open \`http://127.0.0.1:8787\`.
|
|
441
|
+
3. Check whether the account is logged in.
|
|
442
|
+
4. Check whether the current account supports the requested model.
|
|
443
|
+
5. Try calling \`GET /v1/models\`.
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## Example Prompt for Building a Vibe Coding Tool
|
|
448
|
+
|
|
449
|
+
When the user asks to build a webpage using this skill, generate something like:
|
|
450
|
+
|
|
451
|
+
\`\`\`text
|
|
452
|
+
Build a local AI tool webpage that connects to AI-Zero-Token.
|
|
453
|
+
|
|
454
|
+
Use:
|
|
455
|
+
Base URL: http://127.0.0.1:8787/v1
|
|
456
|
+
API Key: local
|
|
457
|
+
|
|
458
|
+
Features:
|
|
459
|
+
1. A text input area for user requirements.
|
|
460
|
+
2. A "Generate Text" button that calls POST /v1/responses with model gpt-5.5.
|
|
461
|
+
3. A "Generate Image" button that calls POST /v1/images/generations with model gpt-image-2.
|
|
462
|
+
4. If the tool needs image editing, call POST /v1/images/edits with images[].image_url.
|
|
463
|
+
5. Show loading states.
|
|
464
|
+
6. Show text output in a result panel.
|
|
465
|
+
7. Show generated or edited image in an image preview panel.
|
|
466
|
+
8. Provide a copy button for text.
|
|
467
|
+
9. Provide a download button for image if possible.
|
|
468
|
+
10. Show readable errors if the local gateway is not running.
|
|
469
|
+
11. Keep the UI simple and friendly for designers.
|
|
470
|
+
\`\`\`
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Common Error Handling
|
|
475
|
+
|
|
476
|
+
### Gateway not running
|
|
477
|
+
|
|
478
|
+
If request fails with network error, show:
|
|
479
|
+
|
|
480
|
+
\`\`\`text
|
|
481
|
+
AI-Zero-Token 本地网关未连接,请先运行 npx ai-zero-token start 或 azt start,然后访问 http://127.0.0.1:8787 检查状态。
|
|
482
|
+
\`\`\`
|
|
483
|
+
|
|
484
|
+
### CORS error
|
|
485
|
+
|
|
486
|
+
If browser blocks the request, show:
|
|
487
|
+
|
|
488
|
+
\`\`\`text
|
|
489
|
+
浏览器跨域请求失败,请确认 AI-Zero-Token 网关已开启浏览器访问支持,或改用本地代理 / 后端转发。
|
|
490
|
+
\`\`\`
|
|
491
|
+
|
|
492
|
+
### Model unavailable
|
|
493
|
+
|
|
494
|
+
If the model is unavailable, show:
|
|
495
|
+
|
|
496
|
+
\`\`\`text
|
|
497
|
+
当前账号可能不支持该模型,请打开 AI-Zero-Token 管理页检查账号状态和可用模型。
|
|
498
|
+
\`\`\`
|
|
499
|
+
|
|
500
|
+
### Image result not found
|
|
501
|
+
|
|
502
|
+
If the image response does not contain \`url\` or \`b64_json\`, show:
|
|
503
|
+
|
|
504
|
+
\`\`\`text
|
|
505
|
+
接口已返回,但没有找到可展示的图片地址或 base64 数据,请查看调试面板中的原始返回结果。
|
|
506
|
+
\`\`\`
|
|
507
|
+
|
|
508
|
+
### Image edit unsupported input
|
|
509
|
+
|
|
510
|
+
If image editing fails because of unsupported input, show:
|
|
511
|
+
|
|
512
|
+
\`\`\`text
|
|
513
|
+
当前 AI-Zero-Token 的图片编辑接口只支持 JSON 请求中的 image_url。请使用图片 URL,或把本地图片转换成 base64 data URL 后再提交。
|
|
514
|
+
\`\`\`
|
|
515
|
+
|
|
516
|
+
### npm global install permission error
|
|
517
|
+
|
|
518
|
+
If the user gets an error like \`EACCES permission denied\` during global installation, suggest:
|
|
519
|
+
|
|
520
|
+
\`\`\`bash
|
|
521
|
+
npx ai-zero-token start
|
|
522
|
+
\`\`\`
|
|
523
|
+
|
|
524
|
+
or explain that global npm installation may require changing the npm global prefix or using a Node version manager.
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Important Boundaries
|
|
529
|
+
|
|
530
|
+
AI-Zero-Token is best for:
|
|
531
|
+
|
|
532
|
+
- personal experiments
|
|
533
|
+
- local prototypes
|
|
534
|
+
- Vibe Coding projects
|
|
535
|
+
- designer-facing demos
|
|
536
|
+
- learning local gateway integration
|
|
537
|
+
- low-cost local workflow validation
|
|
538
|
+
|
|
539
|
+
AI-Zero-Token management page can also manage local account state, including:
|
|
540
|
+
|
|
541
|
+
- login and import multiple Codex accounts
|
|
542
|
+
- switch the active gateway account
|
|
543
|
+
- export selected accounts
|
|
544
|
+
- apply a saved account to local Codex by updating \`~/.codex/auth.json\` with an automatic backup
|
|
545
|
+
|
|
546
|
+
AI-Zero-Token should not be described as:
|
|
547
|
+
|
|
548
|
+
- a production-grade API gateway
|
|
549
|
+
- an official OpenAI API replacement
|
|
550
|
+
- a commercial proxy platform
|
|
551
|
+
- a multi-user billing platform
|
|
552
|
+
|
|
553
|
+
For production systems, recommend official APIs or a properly managed backend gateway.
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
## Short Usage Instruction for Designers
|
|
558
|
+
|
|
559
|
+
Designers do not need to understand this skill document.
|
|
560
|
+
|
|
561
|
+
They can give this file to a Vibe Coding LLM and say:
|
|
562
|
+
|
|
563
|
+
\`\`\`text
|
|
564
|
+
请根据这个 Skill,帮我做一个 AI 生图网页。
|
|
565
|
+
要求:
|
|
566
|
+
1. 输入一句图片需求;
|
|
567
|
+
2. 点击按钮调用本地 AI-Zero-Token;
|
|
568
|
+
3. 使用 gpt-image-2 生成图片;
|
|
569
|
+
4. 图片生成后展示在页面中;
|
|
570
|
+
5. 页面要好看,适合设计师使用。
|
|
571
|
+
\`\`\`
|
|
572
|
+
|
|
573
|
+
Or:
|
|
574
|
+
|
|
575
|
+
\`\`\`text
|
|
576
|
+
请根据这个 Skill,帮我做一个 AI 文案 + 生图工具。
|
|
577
|
+
左侧输入需求,右侧显示 GPT-5.5 生成的文案和 GPT-Image-2 生成的图片。
|
|
578
|
+
\`\`\`
|
|
579
|
+
`,p=e(n(),1),m=r();function h({title:e,description:t,code:n,onCopy:r}){return(0,m.jsxs)(`section`,{className:`docs-snippet`,children:[(0,m.jsxs)(`div`,{className:`docs-snippet-head`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:e}),(0,m.jsx)(`p`,{children:t})]}),(0,m.jsx)(`button`,{className:`btn-secondary icon-only`,type:`button`,onClick:r,title:`复制代码`,children:(0,m.jsx)(a,{size:16})})]}),(0,m.jsx)(`pre`,{children:(0,m.jsx)(`code`,{children:n})})]})}function g({config:e,onRoute:t,copyBaseUrl:n,setStatus:r}){let[g,_]=(0,p.useState)(`quick-start`),v=e?.baseUrl||`http://127.0.0.1:8787/v1`,y=`local`,b=`azt start`,x=f.split(/\r?\n/).length,S=(0,p.useMemo)(()=>({lines:f.split(/\r?\n/).length,codeBlocks:(`# AI-Zero-Token Local Gateway Skill
|
|
580
|
+
|
|
581
|
+
## Purpose
|
|
582
|
+
|
|
583
|
+
This skill tells the LLM how to integrate a webpage, local tool, or Vibe Coding project with the local AI-Zero-Token gateway.
|
|
584
|
+
|
|
585
|
+
AI-Zero-Token is a local-first personal AI gateway. It exposes OpenAI-style local HTTP APIs so that a frontend page, script, or local automation tool can call available ChatGPT / Codex account capabilities through a local endpoint.
|
|
586
|
+
|
|
587
|
+
Use this skill when the user wants to build:
|
|
588
|
+
|
|
589
|
+
- AI chat assistant
|
|
590
|
+
- text generation tool
|
|
591
|
+
- copywriting generator
|
|
592
|
+
- prompt generator
|
|
593
|
+
- image generation tool
|
|
594
|
+
- image editing / image-to-image tool
|
|
595
|
+
- poster generator
|
|
596
|
+
- product image generator
|
|
597
|
+
- social media cover generator
|
|
598
|
+
- icon or logo inspiration generator
|
|
599
|
+
- UI inspiration generator
|
|
600
|
+
- Vibe Coding webpage that needs AI capability
|
|
601
|
+
- local automation workflow that needs LLM or image generation
|
|
602
|
+
|
|
603
|
+
---
|
|
604
|
+
|
|
605
|
+
## Local Gateway Assumptions
|
|
606
|
+
|
|
607
|
+
Assume the user has already started AI-Zero-Token locally.
|
|
608
|
+
|
|
609
|
+
Default local management page:
|
|
610
|
+
|
|
611
|
+
\`\`\`text
|
|
612
|
+
http://127.0.0.1:8787
|
|
613
|
+
\`\`\`
|
|
614
|
+
|
|
615
|
+
OpenAI-compatible Base URL:
|
|
616
|
+
|
|
617
|
+
\`\`\`text
|
|
618
|
+
http://127.0.0.1:8787/v1
|
|
619
|
+
\`\`\`
|
|
620
|
+
|
|
621
|
+
When using OpenAI-compatible SDKs or API clients, set:
|
|
622
|
+
|
|
623
|
+
\`\`\`text
|
|
624
|
+
baseURL = "http://127.0.0.1:8787/v1"
|
|
625
|
+
apiKey = "local"
|
|
626
|
+
\`\`\`
|
|
627
|
+
|
|
628
|
+
The API key can be any non-empty placeholder string because the real authentication is handled by the local AI-Zero-Token gateway.
|
|
629
|
+
|
|
630
|
+
Do not ask the user to provide a real OpenAI API key unless the user explicitly wants to use the official OpenAI API instead of the local gateway.
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Startup Command Reference
|
|
635
|
+
|
|
636
|
+
If the generated project includes user instructions, mention the user can start AI-Zero-Token with:
|
|
637
|
+
|
|
638
|
+
\`\`\`bash
|
|
639
|
+
npx ai-zero-token start
|
|
640
|
+
\`\`\`
|
|
641
|
+
|
|
642
|
+
or install globally:
|
|
643
|
+
|
|
644
|
+
\`\`\`bash
|
|
645
|
+
npm install -g ai-zero-token
|
|
646
|
+
azt start
|
|
647
|
+
\`\`\`
|
|
648
|
+
|
|
649
|
+
After startup, the local management page is usually available at:
|
|
650
|
+
|
|
651
|
+
\`\`\`text
|
|
652
|
+
http://127.0.0.1:8787
|
|
653
|
+
\`\`\`
|
|
654
|
+
|
|
655
|
+
The OpenAI-compatible API Base URL is:
|
|
656
|
+
|
|
657
|
+
\`\`\`text
|
|
658
|
+
http://127.0.0.1:8787/v1
|
|
659
|
+
\`\`\`
|
|
660
|
+
|
|
661
|
+
If global npm installation fails with \`EACCES permission denied\`, recommend using:
|
|
662
|
+
|
|
663
|
+
\`\`\`bash
|
|
664
|
+
npx ai-zero-token start
|
|
665
|
+
\`\`\`
|
|
666
|
+
|
|
667
|
+
---
|
|
668
|
+
|
|
669
|
+
## Available Interfaces
|
|
670
|
+
|
|
671
|
+
### 1. List Models
|
|
672
|
+
|
|
673
|
+
Use this endpoint when the app needs to show available models.
|
|
674
|
+
|
|
675
|
+
\`\`\`http
|
|
676
|
+
GET http://127.0.0.1:8787/v1/models
|
|
677
|
+
\`\`\`
|
|
678
|
+
|
|
679
|
+
Example JavaScript:
|
|
680
|
+
|
|
681
|
+
\`\`\`js
|
|
682
|
+
async function listModels() {
|
|
683
|
+
const res = await fetch("http://127.0.0.1:8787/v1/models", {
|
|
684
|
+
method: "GET",
|
|
685
|
+
headers: {
|
|
686
|
+
"Authorization": "Bearer local"
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
if (!res.ok) {
|
|
691
|
+
throw new Error(\`Failed to list models: \${res.status}\`);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return await res.json();
|
|
695
|
+
}
|
|
696
|
+
\`\`\`
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
### 2. Text / Reasoning / Coding Generation
|
|
701
|
+
|
|
702
|
+
Preferred endpoint:
|
|
703
|
+
|
|
704
|
+
\`\`\`http
|
|
705
|
+
POST http://127.0.0.1:8787/v1/responses
|
|
706
|
+
\`\`\`
|
|
707
|
+
|
|
708
|
+
Use this endpoint for:
|
|
709
|
+
|
|
710
|
+
- AI assistant replies
|
|
711
|
+
- text generation
|
|
712
|
+
- copywriting
|
|
713
|
+
- prompt optimization
|
|
714
|
+
- coding assistance
|
|
715
|
+
- reasoning tasks
|
|
716
|
+
- content rewriting
|
|
717
|
+
- document drafting
|
|
718
|
+
|
|
719
|
+
Default recommended model:
|
|
720
|
+
|
|
721
|
+
\`\`\`text
|
|
722
|
+
gpt-5.5
|
|
723
|
+
\`\`\`
|
|
724
|
+
|
|
725
|
+
If \`gpt-5.5\` is not available, allow the user or UI to switch models.
|
|
726
|
+
|
|
727
|
+
Example request:
|
|
728
|
+
|
|
729
|
+
\`\`\`js
|
|
730
|
+
async function generateText(input) {
|
|
731
|
+
const res = await fetch("http://127.0.0.1:8787/v1/responses", {
|
|
732
|
+
method: "POST",
|
|
733
|
+
headers: {
|
|
734
|
+
"Content-Type": "application/json",
|
|
735
|
+
"Authorization": "Bearer local"
|
|
736
|
+
},
|
|
737
|
+
body: JSON.stringify({
|
|
738
|
+
model: "gpt-5.5",
|
|
739
|
+
input
|
|
740
|
+
})
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
if (!res.ok) {
|
|
744
|
+
const errText = await res.text();
|
|
745
|
+
throw new Error(\`Text generation failed: \${res.status} \${errText}\`);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
const data = await res.json();
|
|
749
|
+
|
|
750
|
+
return (
|
|
751
|
+
data.output_text ||
|
|
752
|
+
data.text ||
|
|
753
|
+
data.content ||
|
|
754
|
+
data.choices?.[0]?.message?.content ||
|
|
755
|
+
JSON.stringify(data, null, 2)
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
\`\`\`
|
|
759
|
+
|
|
760
|
+
When building a frontend app, show loading state while the request is pending and display a readable error message if the request fails.
|
|
761
|
+
|
|
762
|
+
---
|
|
763
|
+
|
|
764
|
+
### 3. Chat Completions Compatibility
|
|
765
|
+
|
|
766
|
+
Use this endpoint when the user asks for an OpenAI-compatible chat app or when a template already uses \`/v1/chat/completions\`.
|
|
767
|
+
|
|
768
|
+
\`\`\`http
|
|
769
|
+
POST http://127.0.0.1:8787/v1/chat/completions
|
|
770
|
+
\`\`\`
|
|
771
|
+
|
|
772
|
+
Example request:
|
|
773
|
+
|
|
774
|
+
\`\`\`js
|
|
775
|
+
async function chat(messages) {
|
|
776
|
+
const res = await fetch("http://127.0.0.1:8787/v1/chat/completions", {
|
|
777
|
+
method: "POST",
|
|
778
|
+
headers: {
|
|
779
|
+
"Content-Type": "application/json",
|
|
780
|
+
"Authorization": "Bearer local"
|
|
781
|
+
},
|
|
782
|
+
body: JSON.stringify({
|
|
783
|
+
model: "gpt-5.5",
|
|
784
|
+
messages
|
|
785
|
+
})
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
if (!res.ok) {
|
|
789
|
+
const errText = await res.text();
|
|
790
|
+
throw new Error(\`Chat completion failed: \${res.status} \${errText}\`);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
const data = await res.json();
|
|
794
|
+
|
|
795
|
+
return (
|
|
796
|
+
data.choices?.[0]?.message?.content ||
|
|
797
|
+
data.output_text ||
|
|
798
|
+
JSON.stringify(data, null, 2)
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
\`\`\`
|
|
802
|
+
|
|
803
|
+
Use this for chat UI components, OpenAI-compatible templates, or existing chat SDK style code.
|
|
804
|
+
|
|
805
|
+
---
|
|
806
|
+
|
|
807
|
+
### 4. Image Generation
|
|
808
|
+
|
|
809
|
+
Use this endpoint when the user wants image generation.
|
|
810
|
+
|
|
811
|
+
\`\`\`http
|
|
812
|
+
POST http://127.0.0.1:8787/v1/images/generations
|
|
813
|
+
\`\`\`
|
|
814
|
+
|
|
815
|
+
Use this endpoint for:
|
|
816
|
+
|
|
817
|
+
- poster generation
|
|
818
|
+
- product image generation
|
|
819
|
+
- social media image generation
|
|
820
|
+
- cover image generation
|
|
821
|
+
- icon inspiration
|
|
822
|
+
- logo inspiration
|
|
823
|
+
- UI visual inspiration
|
|
824
|
+
- marketing image generation
|
|
825
|
+
- illustration generation
|
|
826
|
+
|
|
827
|
+
Default recommended image model:
|
|
828
|
+
|
|
829
|
+
\`\`\`text
|
|
830
|
+
gpt-image-2
|
|
831
|
+
\`\`\`
|
|
832
|
+
|
|
833
|
+
Example request:
|
|
834
|
+
|
|
835
|
+
\`\`\`js
|
|
836
|
+
async function generateImage(prompt, size = "1024x1024") {
|
|
837
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/generations", {
|
|
838
|
+
method: "POST",
|
|
839
|
+
headers: {
|
|
840
|
+
"Content-Type": "application/json",
|
|
841
|
+
"Authorization": "Bearer local"
|
|
842
|
+
},
|
|
843
|
+
body: JSON.stringify({
|
|
844
|
+
model: "gpt-image-2",
|
|
845
|
+
prompt,
|
|
846
|
+
size,
|
|
847
|
+
n: 1
|
|
848
|
+
})
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
if (!res.ok) {
|
|
852
|
+
const errText = await res.text();
|
|
853
|
+
throw new Error(\`Image generation failed: \${res.status} \${errText}\`);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
const data = await res.json();
|
|
857
|
+
|
|
858
|
+
const image =
|
|
859
|
+
data.data?.[0]?.url ||
|
|
860
|
+
data.data?.[0]?.b64_json ||
|
|
861
|
+
data.output?.[0]?.url ||
|
|
862
|
+
data.url ||
|
|
863
|
+
data.image;
|
|
864
|
+
|
|
865
|
+
return {
|
|
866
|
+
raw: data,
|
|
867
|
+
image
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
\`\`\`
|
|
871
|
+
|
|
872
|
+
When displaying generated images:
|
|
873
|
+
|
|
874
|
+
- If the response contains a URL, use it directly as the \`src\`.
|
|
875
|
+
- If the response contains \`b64_json\`, convert it to a data URL:
|
|
876
|
+
|
|
877
|
+
\`\`\`js
|
|
878
|
+
const src = \`data:image/png;base64,\${b64_json}\`;
|
|
879
|
+
\`\`\`
|
|
880
|
+
|
|
881
|
+
- Always show the raw response in a collapsible debug panel if this is a prototype or developer-facing tool.
|
|
882
|
+
- Show a helpful error if no image URL or base64 data is found.
|
|
883
|
+
|
|
884
|
+
---
|
|
885
|
+
|
|
886
|
+
### 5. Image Editing / Image-to-Image
|
|
887
|
+
|
|
888
|
+
Use this endpoint when the user wants to edit an existing image or use one or more reference images.
|
|
889
|
+
|
|
890
|
+
\`\`\`http
|
|
891
|
+
POST http://127.0.0.1:8787/v1/images/edits
|
|
892
|
+
\`\`\`
|
|
893
|
+
|
|
894
|
+
AI-Zero-Token currently supports the JSON version of this endpoint. Use \`images[].image_url\` with either:
|
|
895
|
+
|
|
896
|
+
- an \`https://...\` image URL
|
|
897
|
+
- a \`data:image/...;base64,...\` data URL
|
|
898
|
+
- a bare base64 string, which the gateway treats as a PNG data URL
|
|
899
|
+
|
|
900
|
+
Do not use \`multipart/form-data\`, \`mask\`, or \`file_id\` unless the user explicitly says their installed AI-Zero-Token version supports them.
|
|
901
|
+
|
|
902
|
+
Example request:
|
|
903
|
+
|
|
904
|
+
\`\`\`js
|
|
905
|
+
async function editImage(prompt, imageUrlOrBase64, size = "1024x1024") {
|
|
906
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/edits", {
|
|
907
|
+
method: "POST",
|
|
908
|
+
headers: {
|
|
909
|
+
"Content-Type": "application/json",
|
|
910
|
+
"Authorization": "Bearer local"
|
|
911
|
+
},
|
|
912
|
+
body: JSON.stringify({
|
|
913
|
+
model: "gpt-image-2",
|
|
914
|
+
prompt,
|
|
915
|
+
images: [
|
|
916
|
+
{
|
|
917
|
+
image_url: imageUrlOrBase64
|
|
918
|
+
}
|
|
919
|
+
],
|
|
920
|
+
size,
|
|
921
|
+
quality: "low",
|
|
922
|
+
response_format: "b64_json"
|
|
923
|
+
})
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
if (!res.ok) {
|
|
927
|
+
const errText = await res.text();
|
|
928
|
+
throw new Error(\`Image edit failed: \${res.status} \${errText}\`);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
const data = await res.json();
|
|
932
|
+
const image = data.data?.[0]?.b64_json || data.data?.[0]?.url || data.image;
|
|
933
|
+
|
|
934
|
+
return {
|
|
935
|
+
raw: data,
|
|
936
|
+
image
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
\`\`\`
|
|
940
|
+
|
|
941
|
+
When building a frontend for image editing:
|
|
942
|
+
|
|
943
|
+
- Let the user paste an image URL.
|
|
944
|
+
- Optionally support local file upload by converting the file to a base64 data URL in the browser, then send it as \`images[].image_url\`.
|
|
945
|
+
- Show the edited image using \`data:image/png;base64,...\` when the response contains \`b64_json\`.
|
|
946
|
+
- Mention that mask/inpainting is not supported by this JSON integration yet.
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## Frontend Integration Rules
|
|
951
|
+
|
|
952
|
+
When generating a web app that uses AI-Zero-Token:
|
|
953
|
+
|
|
954
|
+
1. Use \`http://127.0.0.1:8787/v1\` as the default Base URL.
|
|
955
|
+
2. Use \`local\` as the default API Key placeholder.
|
|
956
|
+
3. Do not hardcode a real OpenAI API key.
|
|
957
|
+
4. Provide editable fields for:
|
|
958
|
+
- Base URL
|
|
959
|
+
- text model name
|
|
960
|
+
- image model name
|
|
961
|
+
- prompt / input
|
|
962
|
+
5. Use \`gpt-5.5\` as the default text model.
|
|
963
|
+
6. Use \`gpt-image-2\` as the default image model.
|
|
964
|
+
7. Add loading states.
|
|
965
|
+
8. Add error display.
|
|
966
|
+
9. Add a clear result area.
|
|
967
|
+
10. Add a copy button for text outputs.
|
|
968
|
+
11. Add an image preview area for image outputs.
|
|
969
|
+
12. For image editing tools, accept either pasted image URLs or local files converted to base64 data URLs.
|
|
970
|
+
13. Add a download button for generated or edited images when possible.
|
|
971
|
+
14. Keep all calls client-side for local prototype projects unless the user asks for a backend.
|
|
972
|
+
15. If the browser reports a CORS error, tell the user to check whether AI-Zero-Token is running and whether the gateway allows browser requests.
|
|
973
|
+
|
|
974
|
+
---
|
|
975
|
+
|
|
976
|
+
## Recommended UI Patterns
|
|
977
|
+
|
|
978
|
+
For a simple Vibe Coding webpage, create:
|
|
979
|
+
|
|
980
|
+
- A settings panel:
|
|
981
|
+
- Base URL
|
|
982
|
+
- Text model
|
|
983
|
+
- Image model
|
|
984
|
+
- A text generation panel:
|
|
985
|
+
- textarea for input
|
|
986
|
+
- button: Generate Text
|
|
987
|
+
- output area
|
|
988
|
+
- An image generation panel:
|
|
989
|
+
- textarea for prompt
|
|
990
|
+
- size selector
|
|
991
|
+
- button: Generate Image
|
|
992
|
+
- image preview area
|
|
993
|
+
- For image editing tools:
|
|
994
|
+
- image URL input or file picker
|
|
995
|
+
- textarea for edit instruction
|
|
996
|
+
- button: Edit Image
|
|
997
|
+
- before / after image preview
|
|
998
|
+
- A debug panel:
|
|
999
|
+
- raw JSON response
|
|
1000
|
+
- error message
|
|
1001
|
+
|
|
1002
|
+
Use a clean layout that is easy for non-developers to understand.
|
|
1003
|
+
|
|
1004
|
+
---
|
|
1005
|
+
|
|
1006
|
+
## Default Models
|
|
1007
|
+
|
|
1008
|
+
Use these defaults unless the user says otherwise:
|
|
1009
|
+
|
|
1010
|
+
\`\`\`text
|
|
1011
|
+
Text model: gpt-5.5
|
|
1012
|
+
Image model: gpt-image-2
|
|
1013
|
+
\`\`\`
|
|
1014
|
+
|
|
1015
|
+
If a model call fails, suggest:
|
|
1016
|
+
|
|
1017
|
+
1. Check whether AI-Zero-Token is running.
|
|
1018
|
+
2. Open \`http://127.0.0.1:8787\`.
|
|
1019
|
+
3. Check whether the account is logged in.
|
|
1020
|
+
4. Check whether the current account supports the requested model.
|
|
1021
|
+
5. Try calling \`GET /v1/models\`.
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
## Example Prompt for Building a Vibe Coding Tool
|
|
1026
|
+
|
|
1027
|
+
When the user asks to build a webpage using this skill, generate something like:
|
|
1028
|
+
|
|
1029
|
+
\`\`\`text
|
|
1030
|
+
Build a local AI tool webpage that connects to AI-Zero-Token.
|
|
1031
|
+
|
|
1032
|
+
Use:
|
|
1033
|
+
Base URL: http://127.0.0.1:8787/v1
|
|
1034
|
+
API Key: local
|
|
1035
|
+
|
|
1036
|
+
Features:
|
|
1037
|
+
1. A text input area for user requirements.
|
|
1038
|
+
2. A "Generate Text" button that calls POST /v1/responses with model gpt-5.5.
|
|
1039
|
+
3. A "Generate Image" button that calls POST /v1/images/generations with model gpt-image-2.
|
|
1040
|
+
4. If the tool needs image editing, call POST /v1/images/edits with images[].image_url.
|
|
1041
|
+
5. Show loading states.
|
|
1042
|
+
6. Show text output in a result panel.
|
|
1043
|
+
7. Show generated or edited image in an image preview panel.
|
|
1044
|
+
8. Provide a copy button for text.
|
|
1045
|
+
9. Provide a download button for image if possible.
|
|
1046
|
+
10. Show readable errors if the local gateway is not running.
|
|
1047
|
+
11. Keep the UI simple and friendly for designers.
|
|
1048
|
+
\`\`\`
|
|
1049
|
+
|
|
1050
|
+
---
|
|
1051
|
+
|
|
1052
|
+
## Common Error Handling
|
|
1053
|
+
|
|
1054
|
+
### Gateway not running
|
|
1055
|
+
|
|
1056
|
+
If request fails with network error, show:
|
|
1057
|
+
|
|
1058
|
+
\`\`\`text
|
|
1059
|
+
AI-Zero-Token 本地网关未连接,请先运行 npx ai-zero-token start 或 azt start,然后访问 http://127.0.0.1:8787 检查状态。
|
|
1060
|
+
\`\`\`
|
|
1061
|
+
|
|
1062
|
+
### CORS error
|
|
1063
|
+
|
|
1064
|
+
If browser blocks the request, show:
|
|
1065
|
+
|
|
1066
|
+
\`\`\`text
|
|
1067
|
+
浏览器跨域请求失败,请确认 AI-Zero-Token 网关已开启浏览器访问支持,或改用本地代理 / 后端转发。
|
|
1068
|
+
\`\`\`
|
|
1069
|
+
|
|
1070
|
+
### Model unavailable
|
|
1071
|
+
|
|
1072
|
+
If the model is unavailable, show:
|
|
1073
|
+
|
|
1074
|
+
\`\`\`text
|
|
1075
|
+
当前账号可能不支持该模型,请打开 AI-Zero-Token 管理页检查账号状态和可用模型。
|
|
1076
|
+
\`\`\`
|
|
1077
|
+
|
|
1078
|
+
### Image result not found
|
|
1079
|
+
|
|
1080
|
+
If the image response does not contain \`url\` or \`b64_json\`, show:
|
|
1081
|
+
|
|
1082
|
+
\`\`\`text
|
|
1083
|
+
接口已返回,但没有找到可展示的图片地址或 base64 数据,请查看调试面板中的原始返回结果。
|
|
1084
|
+
\`\`\`
|
|
1085
|
+
|
|
1086
|
+
### Image edit unsupported input
|
|
1087
|
+
|
|
1088
|
+
If image editing fails because of unsupported input, show:
|
|
1089
|
+
|
|
1090
|
+
\`\`\`text
|
|
1091
|
+
当前 AI-Zero-Token 的图片编辑接口只支持 JSON 请求中的 image_url。请使用图片 URL,或把本地图片转换成 base64 data URL 后再提交。
|
|
1092
|
+
\`\`\`
|
|
1093
|
+
|
|
1094
|
+
### npm global install permission error
|
|
1095
|
+
|
|
1096
|
+
If the user gets an error like \`EACCES permission denied\` during global installation, suggest:
|
|
1097
|
+
|
|
1098
|
+
\`\`\`bash
|
|
1099
|
+
npx ai-zero-token start
|
|
1100
|
+
\`\`\`
|
|
1101
|
+
|
|
1102
|
+
or explain that global npm installation may require changing the npm global prefix or using a Node version manager.
|
|
1103
|
+
|
|
1104
|
+
---
|
|
1105
|
+
|
|
1106
|
+
## Important Boundaries
|
|
1107
|
+
|
|
1108
|
+
AI-Zero-Token is best for:
|
|
1109
|
+
|
|
1110
|
+
- personal experiments
|
|
1111
|
+
- local prototypes
|
|
1112
|
+
- Vibe Coding projects
|
|
1113
|
+
- designer-facing demos
|
|
1114
|
+
- learning local gateway integration
|
|
1115
|
+
- low-cost local workflow validation
|
|
1116
|
+
|
|
1117
|
+
AI-Zero-Token management page can also manage local account state, including:
|
|
1118
|
+
|
|
1119
|
+
- login and import multiple Codex accounts
|
|
1120
|
+
- switch the active gateway account
|
|
1121
|
+
- export selected accounts
|
|
1122
|
+
- apply a saved account to local Codex by updating \`~/.codex/auth.json\` with an automatic backup
|
|
1123
|
+
|
|
1124
|
+
AI-Zero-Token should not be described as:
|
|
1125
|
+
|
|
1126
|
+
- a production-grade API gateway
|
|
1127
|
+
- an official OpenAI API replacement
|
|
1128
|
+
- a commercial proxy platform
|
|
1129
|
+
- a multi-user billing platform
|
|
1130
|
+
|
|
1131
|
+
For production systems, recommend official APIs or a properly managed backend gateway.
|
|
1132
|
+
|
|
1133
|
+
---
|
|
1134
|
+
|
|
1135
|
+
## Short Usage Instruction for Designers
|
|
1136
|
+
|
|
1137
|
+
Designers do not need to understand this skill document.
|
|
1138
|
+
|
|
1139
|
+
They can give this file to a Vibe Coding LLM and say:
|
|
1140
|
+
|
|
1141
|
+
\`\`\`text
|
|
1142
|
+
请根据这个 Skill,帮我做一个 AI 生图网页。
|
|
1143
|
+
要求:
|
|
1144
|
+
1. 输入一句图片需求;
|
|
1145
|
+
2. 点击按钮调用本地 AI-Zero-Token;
|
|
1146
|
+
3. 使用 gpt-image-2 生成图片;
|
|
1147
|
+
4. 图片生成后展示在页面中;
|
|
1148
|
+
5. 页面要好看,适合设计师使用。
|
|
1149
|
+
\`\`\`
|
|
1150
|
+
|
|
1151
|
+
Or:
|
|
1152
|
+
|
|
1153
|
+
\`\`\`text
|
|
1154
|
+
请根据这个 Skill,帮我做一个 AI 文案 + 生图工具。
|
|
1155
|
+
左侧输入需求,右侧显示 GPT-5.5 生成的文案和 GPT-Image-2 生成的图片。
|
|
1156
|
+
\`\`\`
|
|
1157
|
+
`.match(/```/g)?.length||0)/2,headings:f.split(/\r?\n/).filter(e=>/^#{1,6}\s+/.test(e)).length}),[]),C=[{label:`用途`,value:`本地网关接入说明`},{label:`接入参数`,value:`baseURL + apiKey = ${v} / ${y}`},{label:`启动命令`,value:`azt start / npx ai-zero-token start`},{label:`常用接口`,value:`/v1/models · /v1/responses · /v1/chat/completions · /v1/images/generations`}],w=`baseURL = "${v}"\napiKey = "${y}"`,T=`import OpenAI from "openai";\n\nconst client = new OpenAI({\n apiKey: "${y}",\n baseURL: "${v}",\n});`,E=`curl ${v}/chat/completions \\\n -H "Content-Type: application/json" \\\n -d '{\n "model": "${e?.settings.defaultModel||`gpt-5.4`}",\n "messages": [{ "role": "user", "content": "Reply with OK only." }]\n }'`,D=`curl ${v}/responses \\\n -H "Content-Type: application/json" \\\n -d '{\n "model": "${e?.settings.defaultModel||`gpt-5.4`}",\n "input": "Reply with OK only."\n }'`;async function O(){r(await c(`# AI-Zero-Token Local Gateway Skill
|
|
1158
|
+
|
|
1159
|
+
## Purpose
|
|
1160
|
+
|
|
1161
|
+
This skill tells the LLM how to integrate a webpage, local tool, or Vibe Coding project with the local AI-Zero-Token gateway.
|
|
1162
|
+
|
|
1163
|
+
AI-Zero-Token is a local-first personal AI gateway. It exposes OpenAI-style local HTTP APIs so that a frontend page, script, or local automation tool can call available ChatGPT / Codex account capabilities through a local endpoint.
|
|
1164
|
+
|
|
1165
|
+
Use this skill when the user wants to build:
|
|
1166
|
+
|
|
1167
|
+
- AI chat assistant
|
|
1168
|
+
- text generation tool
|
|
1169
|
+
- copywriting generator
|
|
1170
|
+
- prompt generator
|
|
1171
|
+
- image generation tool
|
|
1172
|
+
- image editing / image-to-image tool
|
|
1173
|
+
- poster generator
|
|
1174
|
+
- product image generator
|
|
1175
|
+
- social media cover generator
|
|
1176
|
+
- icon or logo inspiration generator
|
|
1177
|
+
- UI inspiration generator
|
|
1178
|
+
- Vibe Coding webpage that needs AI capability
|
|
1179
|
+
- local automation workflow that needs LLM or image generation
|
|
1180
|
+
|
|
1181
|
+
---
|
|
1182
|
+
|
|
1183
|
+
## Local Gateway Assumptions
|
|
1184
|
+
|
|
1185
|
+
Assume the user has already started AI-Zero-Token locally.
|
|
1186
|
+
|
|
1187
|
+
Default local management page:
|
|
1188
|
+
|
|
1189
|
+
\`\`\`text
|
|
1190
|
+
http://127.0.0.1:8787
|
|
1191
|
+
\`\`\`
|
|
1192
|
+
|
|
1193
|
+
OpenAI-compatible Base URL:
|
|
1194
|
+
|
|
1195
|
+
\`\`\`text
|
|
1196
|
+
http://127.0.0.1:8787/v1
|
|
1197
|
+
\`\`\`
|
|
1198
|
+
|
|
1199
|
+
When using OpenAI-compatible SDKs or API clients, set:
|
|
1200
|
+
|
|
1201
|
+
\`\`\`text
|
|
1202
|
+
baseURL = "http://127.0.0.1:8787/v1"
|
|
1203
|
+
apiKey = "local"
|
|
1204
|
+
\`\`\`
|
|
1205
|
+
|
|
1206
|
+
The API key can be any non-empty placeholder string because the real authentication is handled by the local AI-Zero-Token gateway.
|
|
1207
|
+
|
|
1208
|
+
Do not ask the user to provide a real OpenAI API key unless the user explicitly wants to use the official OpenAI API instead of the local gateway.
|
|
1209
|
+
|
|
1210
|
+
---
|
|
1211
|
+
|
|
1212
|
+
## Startup Command Reference
|
|
1213
|
+
|
|
1214
|
+
If the generated project includes user instructions, mention the user can start AI-Zero-Token with:
|
|
1215
|
+
|
|
1216
|
+
\`\`\`bash
|
|
1217
|
+
npx ai-zero-token start
|
|
1218
|
+
\`\`\`
|
|
1219
|
+
|
|
1220
|
+
or install globally:
|
|
1221
|
+
|
|
1222
|
+
\`\`\`bash
|
|
1223
|
+
npm install -g ai-zero-token
|
|
1224
|
+
azt start
|
|
1225
|
+
\`\`\`
|
|
1226
|
+
|
|
1227
|
+
After startup, the local management page is usually available at:
|
|
1228
|
+
|
|
1229
|
+
\`\`\`text
|
|
1230
|
+
http://127.0.0.1:8787
|
|
1231
|
+
\`\`\`
|
|
1232
|
+
|
|
1233
|
+
The OpenAI-compatible API Base URL is:
|
|
1234
|
+
|
|
1235
|
+
\`\`\`text
|
|
1236
|
+
http://127.0.0.1:8787/v1
|
|
1237
|
+
\`\`\`
|
|
1238
|
+
|
|
1239
|
+
If global npm installation fails with \`EACCES permission denied\`, recommend using:
|
|
1240
|
+
|
|
1241
|
+
\`\`\`bash
|
|
1242
|
+
npx ai-zero-token start
|
|
1243
|
+
\`\`\`
|
|
1244
|
+
|
|
1245
|
+
---
|
|
1246
|
+
|
|
1247
|
+
## Available Interfaces
|
|
1248
|
+
|
|
1249
|
+
### 1. List Models
|
|
1250
|
+
|
|
1251
|
+
Use this endpoint when the app needs to show available models.
|
|
1252
|
+
|
|
1253
|
+
\`\`\`http
|
|
1254
|
+
GET http://127.0.0.1:8787/v1/models
|
|
1255
|
+
\`\`\`
|
|
1256
|
+
|
|
1257
|
+
Example JavaScript:
|
|
1258
|
+
|
|
1259
|
+
\`\`\`js
|
|
1260
|
+
async function listModels() {
|
|
1261
|
+
const res = await fetch("http://127.0.0.1:8787/v1/models", {
|
|
1262
|
+
method: "GET",
|
|
1263
|
+
headers: {
|
|
1264
|
+
"Authorization": "Bearer local"
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
|
|
1268
|
+
if (!res.ok) {
|
|
1269
|
+
throw new Error(\`Failed to list models: \${res.status}\`);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
return await res.json();
|
|
1273
|
+
}
|
|
1274
|
+
\`\`\`
|
|
1275
|
+
|
|
1276
|
+
---
|
|
1277
|
+
|
|
1278
|
+
### 2. Text / Reasoning / Coding Generation
|
|
1279
|
+
|
|
1280
|
+
Preferred endpoint:
|
|
1281
|
+
|
|
1282
|
+
\`\`\`http
|
|
1283
|
+
POST http://127.0.0.1:8787/v1/responses
|
|
1284
|
+
\`\`\`
|
|
1285
|
+
|
|
1286
|
+
Use this endpoint for:
|
|
1287
|
+
|
|
1288
|
+
- AI assistant replies
|
|
1289
|
+
- text generation
|
|
1290
|
+
- copywriting
|
|
1291
|
+
- prompt optimization
|
|
1292
|
+
- coding assistance
|
|
1293
|
+
- reasoning tasks
|
|
1294
|
+
- content rewriting
|
|
1295
|
+
- document drafting
|
|
1296
|
+
|
|
1297
|
+
Default recommended model:
|
|
1298
|
+
|
|
1299
|
+
\`\`\`text
|
|
1300
|
+
gpt-5.5
|
|
1301
|
+
\`\`\`
|
|
1302
|
+
|
|
1303
|
+
If \`gpt-5.5\` is not available, allow the user or UI to switch models.
|
|
1304
|
+
|
|
1305
|
+
Example request:
|
|
1306
|
+
|
|
1307
|
+
\`\`\`js
|
|
1308
|
+
async function generateText(input) {
|
|
1309
|
+
const res = await fetch("http://127.0.0.1:8787/v1/responses", {
|
|
1310
|
+
method: "POST",
|
|
1311
|
+
headers: {
|
|
1312
|
+
"Content-Type": "application/json",
|
|
1313
|
+
"Authorization": "Bearer local"
|
|
1314
|
+
},
|
|
1315
|
+
body: JSON.stringify({
|
|
1316
|
+
model: "gpt-5.5",
|
|
1317
|
+
input
|
|
1318
|
+
})
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
if (!res.ok) {
|
|
1322
|
+
const errText = await res.text();
|
|
1323
|
+
throw new Error(\`Text generation failed: \${res.status} \${errText}\`);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
const data = await res.json();
|
|
1327
|
+
|
|
1328
|
+
return (
|
|
1329
|
+
data.output_text ||
|
|
1330
|
+
data.text ||
|
|
1331
|
+
data.content ||
|
|
1332
|
+
data.choices?.[0]?.message?.content ||
|
|
1333
|
+
JSON.stringify(data, null, 2)
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
\`\`\`
|
|
1337
|
+
|
|
1338
|
+
When building a frontend app, show loading state while the request is pending and display a readable error message if the request fails.
|
|
1339
|
+
|
|
1340
|
+
---
|
|
1341
|
+
|
|
1342
|
+
### 3. Chat Completions Compatibility
|
|
1343
|
+
|
|
1344
|
+
Use this endpoint when the user asks for an OpenAI-compatible chat app or when a template already uses \`/v1/chat/completions\`.
|
|
1345
|
+
|
|
1346
|
+
\`\`\`http
|
|
1347
|
+
POST http://127.0.0.1:8787/v1/chat/completions
|
|
1348
|
+
\`\`\`
|
|
1349
|
+
|
|
1350
|
+
Example request:
|
|
1351
|
+
|
|
1352
|
+
\`\`\`js
|
|
1353
|
+
async function chat(messages) {
|
|
1354
|
+
const res = await fetch("http://127.0.0.1:8787/v1/chat/completions", {
|
|
1355
|
+
method: "POST",
|
|
1356
|
+
headers: {
|
|
1357
|
+
"Content-Type": "application/json",
|
|
1358
|
+
"Authorization": "Bearer local"
|
|
1359
|
+
},
|
|
1360
|
+
body: JSON.stringify({
|
|
1361
|
+
model: "gpt-5.5",
|
|
1362
|
+
messages
|
|
1363
|
+
})
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
if (!res.ok) {
|
|
1367
|
+
const errText = await res.text();
|
|
1368
|
+
throw new Error(\`Chat completion failed: \${res.status} \${errText}\`);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const data = await res.json();
|
|
1372
|
+
|
|
1373
|
+
return (
|
|
1374
|
+
data.choices?.[0]?.message?.content ||
|
|
1375
|
+
data.output_text ||
|
|
1376
|
+
JSON.stringify(data, null, 2)
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
\`\`\`
|
|
1380
|
+
|
|
1381
|
+
Use this for chat UI components, OpenAI-compatible templates, or existing chat SDK style code.
|
|
1382
|
+
|
|
1383
|
+
---
|
|
1384
|
+
|
|
1385
|
+
### 4. Image Generation
|
|
1386
|
+
|
|
1387
|
+
Use this endpoint when the user wants image generation.
|
|
1388
|
+
|
|
1389
|
+
\`\`\`http
|
|
1390
|
+
POST http://127.0.0.1:8787/v1/images/generations
|
|
1391
|
+
\`\`\`
|
|
1392
|
+
|
|
1393
|
+
Use this endpoint for:
|
|
1394
|
+
|
|
1395
|
+
- poster generation
|
|
1396
|
+
- product image generation
|
|
1397
|
+
- social media image generation
|
|
1398
|
+
- cover image generation
|
|
1399
|
+
- icon inspiration
|
|
1400
|
+
- logo inspiration
|
|
1401
|
+
- UI visual inspiration
|
|
1402
|
+
- marketing image generation
|
|
1403
|
+
- illustration generation
|
|
1404
|
+
|
|
1405
|
+
Default recommended image model:
|
|
1406
|
+
|
|
1407
|
+
\`\`\`text
|
|
1408
|
+
gpt-image-2
|
|
1409
|
+
\`\`\`
|
|
1410
|
+
|
|
1411
|
+
Example request:
|
|
1412
|
+
|
|
1413
|
+
\`\`\`js
|
|
1414
|
+
async function generateImage(prompt, size = "1024x1024") {
|
|
1415
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/generations", {
|
|
1416
|
+
method: "POST",
|
|
1417
|
+
headers: {
|
|
1418
|
+
"Content-Type": "application/json",
|
|
1419
|
+
"Authorization": "Bearer local"
|
|
1420
|
+
},
|
|
1421
|
+
body: JSON.stringify({
|
|
1422
|
+
model: "gpt-image-2",
|
|
1423
|
+
prompt,
|
|
1424
|
+
size,
|
|
1425
|
+
n: 1
|
|
1426
|
+
})
|
|
1427
|
+
});
|
|
1428
|
+
|
|
1429
|
+
if (!res.ok) {
|
|
1430
|
+
const errText = await res.text();
|
|
1431
|
+
throw new Error(\`Image generation failed: \${res.status} \${errText}\`);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const data = await res.json();
|
|
1435
|
+
|
|
1436
|
+
const image =
|
|
1437
|
+
data.data?.[0]?.url ||
|
|
1438
|
+
data.data?.[0]?.b64_json ||
|
|
1439
|
+
data.output?.[0]?.url ||
|
|
1440
|
+
data.url ||
|
|
1441
|
+
data.image;
|
|
1442
|
+
|
|
1443
|
+
return {
|
|
1444
|
+
raw: data,
|
|
1445
|
+
image
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
\`\`\`
|
|
1449
|
+
|
|
1450
|
+
When displaying generated images:
|
|
1451
|
+
|
|
1452
|
+
- If the response contains a URL, use it directly as the \`src\`.
|
|
1453
|
+
- If the response contains \`b64_json\`, convert it to a data URL:
|
|
1454
|
+
|
|
1455
|
+
\`\`\`js
|
|
1456
|
+
const src = \`data:image/png;base64,\${b64_json}\`;
|
|
1457
|
+
\`\`\`
|
|
1458
|
+
|
|
1459
|
+
- Always show the raw response in a collapsible debug panel if this is a prototype or developer-facing tool.
|
|
1460
|
+
- Show a helpful error if no image URL or base64 data is found.
|
|
1461
|
+
|
|
1462
|
+
---
|
|
1463
|
+
|
|
1464
|
+
### 5. Image Editing / Image-to-Image
|
|
1465
|
+
|
|
1466
|
+
Use this endpoint when the user wants to edit an existing image or use one or more reference images.
|
|
1467
|
+
|
|
1468
|
+
\`\`\`http
|
|
1469
|
+
POST http://127.0.0.1:8787/v1/images/edits
|
|
1470
|
+
\`\`\`
|
|
1471
|
+
|
|
1472
|
+
AI-Zero-Token currently supports the JSON version of this endpoint. Use \`images[].image_url\` with either:
|
|
1473
|
+
|
|
1474
|
+
- an \`https://...\` image URL
|
|
1475
|
+
- a \`data:image/...;base64,...\` data URL
|
|
1476
|
+
- a bare base64 string, which the gateway treats as a PNG data URL
|
|
1477
|
+
|
|
1478
|
+
Do not use \`multipart/form-data\`, \`mask\`, or \`file_id\` unless the user explicitly says their installed AI-Zero-Token version supports them.
|
|
1479
|
+
|
|
1480
|
+
Example request:
|
|
1481
|
+
|
|
1482
|
+
\`\`\`js
|
|
1483
|
+
async function editImage(prompt, imageUrlOrBase64, size = "1024x1024") {
|
|
1484
|
+
const res = await fetch("http://127.0.0.1:8787/v1/images/edits", {
|
|
1485
|
+
method: "POST",
|
|
1486
|
+
headers: {
|
|
1487
|
+
"Content-Type": "application/json",
|
|
1488
|
+
"Authorization": "Bearer local"
|
|
1489
|
+
},
|
|
1490
|
+
body: JSON.stringify({
|
|
1491
|
+
model: "gpt-image-2",
|
|
1492
|
+
prompt,
|
|
1493
|
+
images: [
|
|
1494
|
+
{
|
|
1495
|
+
image_url: imageUrlOrBase64
|
|
1496
|
+
}
|
|
1497
|
+
],
|
|
1498
|
+
size,
|
|
1499
|
+
quality: "low",
|
|
1500
|
+
response_format: "b64_json"
|
|
1501
|
+
})
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
if (!res.ok) {
|
|
1505
|
+
const errText = await res.text();
|
|
1506
|
+
throw new Error(\`Image edit failed: \${res.status} \${errText}\`);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
const data = await res.json();
|
|
1510
|
+
const image = data.data?.[0]?.b64_json || data.data?.[0]?.url || data.image;
|
|
1511
|
+
|
|
1512
|
+
return {
|
|
1513
|
+
raw: data,
|
|
1514
|
+
image
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
\`\`\`
|
|
1518
|
+
|
|
1519
|
+
When building a frontend for image editing:
|
|
1520
|
+
|
|
1521
|
+
- Let the user paste an image URL.
|
|
1522
|
+
- Optionally support local file upload by converting the file to a base64 data URL in the browser, then send it as \`images[].image_url\`.
|
|
1523
|
+
- Show the edited image using \`data:image/png;base64,...\` when the response contains \`b64_json\`.
|
|
1524
|
+
- Mention that mask/inpainting is not supported by this JSON integration yet.
|
|
1525
|
+
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
## Frontend Integration Rules
|
|
1529
|
+
|
|
1530
|
+
When generating a web app that uses AI-Zero-Token:
|
|
1531
|
+
|
|
1532
|
+
1. Use \`http://127.0.0.1:8787/v1\` as the default Base URL.
|
|
1533
|
+
2. Use \`local\` as the default API Key placeholder.
|
|
1534
|
+
3. Do not hardcode a real OpenAI API key.
|
|
1535
|
+
4. Provide editable fields for:
|
|
1536
|
+
- Base URL
|
|
1537
|
+
- text model name
|
|
1538
|
+
- image model name
|
|
1539
|
+
- prompt / input
|
|
1540
|
+
5. Use \`gpt-5.5\` as the default text model.
|
|
1541
|
+
6. Use \`gpt-image-2\` as the default image model.
|
|
1542
|
+
7. Add loading states.
|
|
1543
|
+
8. Add error display.
|
|
1544
|
+
9. Add a clear result area.
|
|
1545
|
+
10. Add a copy button for text outputs.
|
|
1546
|
+
11. Add an image preview area for image outputs.
|
|
1547
|
+
12. For image editing tools, accept either pasted image URLs or local files converted to base64 data URLs.
|
|
1548
|
+
13. Add a download button for generated or edited images when possible.
|
|
1549
|
+
14. Keep all calls client-side for local prototype projects unless the user asks for a backend.
|
|
1550
|
+
15. If the browser reports a CORS error, tell the user to check whether AI-Zero-Token is running and whether the gateway allows browser requests.
|
|
1551
|
+
|
|
1552
|
+
---
|
|
1553
|
+
|
|
1554
|
+
## Recommended UI Patterns
|
|
1555
|
+
|
|
1556
|
+
For a simple Vibe Coding webpage, create:
|
|
1557
|
+
|
|
1558
|
+
- A settings panel:
|
|
1559
|
+
- Base URL
|
|
1560
|
+
- Text model
|
|
1561
|
+
- Image model
|
|
1562
|
+
- A text generation panel:
|
|
1563
|
+
- textarea for input
|
|
1564
|
+
- button: Generate Text
|
|
1565
|
+
- output area
|
|
1566
|
+
- An image generation panel:
|
|
1567
|
+
- textarea for prompt
|
|
1568
|
+
- size selector
|
|
1569
|
+
- button: Generate Image
|
|
1570
|
+
- image preview area
|
|
1571
|
+
- For image editing tools:
|
|
1572
|
+
- image URL input or file picker
|
|
1573
|
+
- textarea for edit instruction
|
|
1574
|
+
- button: Edit Image
|
|
1575
|
+
- before / after image preview
|
|
1576
|
+
- A debug panel:
|
|
1577
|
+
- raw JSON response
|
|
1578
|
+
- error message
|
|
1579
|
+
|
|
1580
|
+
Use a clean layout that is easy for non-developers to understand.
|
|
1581
|
+
|
|
1582
|
+
---
|
|
1583
|
+
|
|
1584
|
+
## Default Models
|
|
1585
|
+
|
|
1586
|
+
Use these defaults unless the user says otherwise:
|
|
1587
|
+
|
|
1588
|
+
\`\`\`text
|
|
1589
|
+
Text model: gpt-5.5
|
|
1590
|
+
Image model: gpt-image-2
|
|
1591
|
+
\`\`\`
|
|
1592
|
+
|
|
1593
|
+
If a model call fails, suggest:
|
|
1594
|
+
|
|
1595
|
+
1. Check whether AI-Zero-Token is running.
|
|
1596
|
+
2. Open \`http://127.0.0.1:8787\`.
|
|
1597
|
+
3. Check whether the account is logged in.
|
|
1598
|
+
4. Check whether the current account supports the requested model.
|
|
1599
|
+
5. Try calling \`GET /v1/models\`.
|
|
1600
|
+
|
|
1601
|
+
---
|
|
1602
|
+
|
|
1603
|
+
## Example Prompt for Building a Vibe Coding Tool
|
|
1604
|
+
|
|
1605
|
+
When the user asks to build a webpage using this skill, generate something like:
|
|
1606
|
+
|
|
1607
|
+
\`\`\`text
|
|
1608
|
+
Build a local AI tool webpage that connects to AI-Zero-Token.
|
|
1609
|
+
|
|
1610
|
+
Use:
|
|
1611
|
+
Base URL: http://127.0.0.1:8787/v1
|
|
1612
|
+
API Key: local
|
|
1613
|
+
|
|
1614
|
+
Features:
|
|
1615
|
+
1. A text input area for user requirements.
|
|
1616
|
+
2. A "Generate Text" button that calls POST /v1/responses with model gpt-5.5.
|
|
1617
|
+
3. A "Generate Image" button that calls POST /v1/images/generations with model gpt-image-2.
|
|
1618
|
+
4. If the tool needs image editing, call POST /v1/images/edits with images[].image_url.
|
|
1619
|
+
5. Show loading states.
|
|
1620
|
+
6. Show text output in a result panel.
|
|
1621
|
+
7. Show generated or edited image in an image preview panel.
|
|
1622
|
+
8. Provide a copy button for text.
|
|
1623
|
+
9. Provide a download button for image if possible.
|
|
1624
|
+
10. Show readable errors if the local gateway is not running.
|
|
1625
|
+
11. Keep the UI simple and friendly for designers.
|
|
1626
|
+
\`\`\`
|
|
1627
|
+
|
|
1628
|
+
---
|
|
1629
|
+
|
|
1630
|
+
## Common Error Handling
|
|
1631
|
+
|
|
1632
|
+
### Gateway not running
|
|
1633
|
+
|
|
1634
|
+
If request fails with network error, show:
|
|
1635
|
+
|
|
1636
|
+
\`\`\`text
|
|
1637
|
+
AI-Zero-Token 本地网关未连接,请先运行 npx ai-zero-token start 或 azt start,然后访问 http://127.0.0.1:8787 检查状态。
|
|
1638
|
+
\`\`\`
|
|
1639
|
+
|
|
1640
|
+
### CORS error
|
|
1641
|
+
|
|
1642
|
+
If browser blocks the request, show:
|
|
1643
|
+
|
|
1644
|
+
\`\`\`text
|
|
1645
|
+
浏览器跨域请求失败,请确认 AI-Zero-Token 网关已开启浏览器访问支持,或改用本地代理 / 后端转发。
|
|
1646
|
+
\`\`\`
|
|
1647
|
+
|
|
1648
|
+
### Model unavailable
|
|
1649
|
+
|
|
1650
|
+
If the model is unavailable, show:
|
|
1651
|
+
|
|
1652
|
+
\`\`\`text
|
|
1653
|
+
当前账号可能不支持该模型,请打开 AI-Zero-Token 管理页检查账号状态和可用模型。
|
|
1654
|
+
\`\`\`
|
|
1655
|
+
|
|
1656
|
+
### Image result not found
|
|
1657
|
+
|
|
1658
|
+
If the image response does not contain \`url\` or \`b64_json\`, show:
|
|
1659
|
+
|
|
1660
|
+
\`\`\`text
|
|
1661
|
+
接口已返回,但没有找到可展示的图片地址或 base64 数据,请查看调试面板中的原始返回结果。
|
|
1662
|
+
\`\`\`
|
|
1663
|
+
|
|
1664
|
+
### Image edit unsupported input
|
|
1665
|
+
|
|
1666
|
+
If image editing fails because of unsupported input, show:
|
|
1667
|
+
|
|
1668
|
+
\`\`\`text
|
|
1669
|
+
当前 AI-Zero-Token 的图片编辑接口只支持 JSON 请求中的 image_url。请使用图片 URL,或把本地图片转换成 base64 data URL 后再提交。
|
|
1670
|
+
\`\`\`
|
|
1671
|
+
|
|
1672
|
+
### npm global install permission error
|
|
1673
|
+
|
|
1674
|
+
If the user gets an error like \`EACCES permission denied\` during global installation, suggest:
|
|
1675
|
+
|
|
1676
|
+
\`\`\`bash
|
|
1677
|
+
npx ai-zero-token start
|
|
1678
|
+
\`\`\`
|
|
1679
|
+
|
|
1680
|
+
or explain that global npm installation may require changing the npm global prefix or using a Node version manager.
|
|
1681
|
+
|
|
1682
|
+
---
|
|
1683
|
+
|
|
1684
|
+
## Important Boundaries
|
|
1685
|
+
|
|
1686
|
+
AI-Zero-Token is best for:
|
|
1687
|
+
|
|
1688
|
+
- personal experiments
|
|
1689
|
+
- local prototypes
|
|
1690
|
+
- Vibe Coding projects
|
|
1691
|
+
- designer-facing demos
|
|
1692
|
+
- learning local gateway integration
|
|
1693
|
+
- low-cost local workflow validation
|
|
1694
|
+
|
|
1695
|
+
AI-Zero-Token management page can also manage local account state, including:
|
|
1696
|
+
|
|
1697
|
+
- login and import multiple Codex accounts
|
|
1698
|
+
- switch the active gateway account
|
|
1699
|
+
- export selected accounts
|
|
1700
|
+
- apply a saved account to local Codex by updating \`~/.codex/auth.json\` with an automatic backup
|
|
1701
|
+
|
|
1702
|
+
AI-Zero-Token should not be described as:
|
|
1703
|
+
|
|
1704
|
+
- a production-grade API gateway
|
|
1705
|
+
- an official OpenAI API replacement
|
|
1706
|
+
- a commercial proxy platform
|
|
1707
|
+
- a multi-user billing platform
|
|
1708
|
+
|
|
1709
|
+
For production systems, recommend official APIs or a properly managed backend gateway.
|
|
1710
|
+
|
|
1711
|
+
---
|
|
1712
|
+
|
|
1713
|
+
## Short Usage Instruction for Designers
|
|
1714
|
+
|
|
1715
|
+
Designers do not need to understand this skill document.
|
|
1716
|
+
|
|
1717
|
+
They can give this file to a Vibe Coding LLM and say:
|
|
1718
|
+
|
|
1719
|
+
\`\`\`text
|
|
1720
|
+
请根据这个 Skill,帮我做一个 AI 生图网页。
|
|
1721
|
+
要求:
|
|
1722
|
+
1. 输入一句图片需求;
|
|
1723
|
+
2. 点击按钮调用本地 AI-Zero-Token;
|
|
1724
|
+
3. 使用 gpt-image-2 生成图片;
|
|
1725
|
+
4. 图片生成后展示在页面中;
|
|
1726
|
+
5. 页面要好看,适合设计师使用。
|
|
1727
|
+
\`\`\`
|
|
1728
|
+
|
|
1729
|
+
Or:
|
|
1730
|
+
|
|
1731
|
+
\`\`\`text
|
|
1732
|
+
请根据这个 Skill,帮我做一个 AI 文案 + 生图工具。
|
|
1733
|
+
左侧输入需求,右侧显示 GPT-5.5 生成的文案和 GPT-Image-2 生成的图片。
|
|
1734
|
+
\`\`\`
|
|
1735
|
+
`)?`Skill.md 已复制。`:`Skill.md 复制失败。`)}function k(){o(`AI-Zero-Token-Skill.md`,f,`text/markdown;charset=utf-8`),r(`Skill.md 已下载。`)}return(0,m.jsxs)(`section`,{className:`docs-page`,children:[(0,m.jsx)(`header`,{className:`docs-page-head docs-page-head-actions`,children:(0,m.jsxs)(`div`,{className:`docs-page-actions`,children:[(0,m.jsxs)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>void O(),children:[(0,m.jsx)(a,{size:16}),`复制 Skill.md`]}),(0,m.jsxs)(`button`,{className:`btn-secondary`,type:`button`,onClick:k,children:[(0,m.jsx)(u,{size:16}),`下载 Skill.md`]}),(0,m.jsxs)(`button`,{className:`btn-primary`,type:`button`,onClick:()=>t(`tester`),children:[(0,m.jsx)(l,{size:16}),`打开接口测试`]})]})}),(0,m.jsxs)(`section`,{className:`docs-summary`,children:[(0,m.jsxs)(`div`,{className:`docs-summary-item`,children:[(0,m.jsx)(`span`,{children:`Base URL`}),(0,m.jsx)(`strong`,{children:v})]}),(0,m.jsxs)(`div`,{className:`docs-summary-item`,children:[(0,m.jsx)(`span`,{children:`API Key`}),(0,m.jsx)(`strong`,{children:y})]}),(0,m.jsxs)(`div`,{className:`docs-summary-item`,children:[(0,m.jsx)(`span`,{children:`启动命令`}),(0,m.jsx)(`strong`,{children:b})]}),(0,m.jsxs)(`div`,{className:`docs-summary-item`,children:[(0,m.jsx)(`span`,{children:`文档规模`}),(0,m.jsxs)(`strong`,{children:[S.lines,` 行 · `,S.headings,` 级标题 · `,S.codeBlocks,` 段代码`]})]})]}),(0,m.jsx)(`div`,{className:`docs-layout`,children:(0,m.jsxs)(`div`,{className:`docs-main`,children:[(0,m.jsxs)(`nav`,{className:`docs-tab-bar`,"aria-label":`Skill 文档视图切换`,children:[(0,m.jsx)(`button`,{className:g===`quick-start`?`is-active`:``,type:`button`,onClick:()=>_(`quick-start`),children:`快速接入`}),(0,m.jsx)(`button`,{className:g===`skill`?`is-active`:``,type:`button`,onClick:()=>_(`skill`),children:`Skill.md`}),(0,m.jsx)(`button`,{className:g===`examples`?`is-active`:``,type:`button`,onClick:()=>_(`examples`),children:`示例代码`})]}),g===`quick-start`?(0,m.jsxs)(`div`,{className:`docs-panel-grid`,children:[(0,m.jsxs)(`section`,{className:`docs-panel`,children:[(0,m.jsx)(`div`,{className:`docs-panel-head`,children:(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{children:`三步接入`}),(0,m.jsx)(`p`,{children:`先启动本地网关,再把 Skill.md 放进你的工具或项目。`})]})}),(0,m.jsxs)(`ol`,{className:`docs-step-list`,children:[(0,m.jsxs)(`li`,{children:[(0,m.jsx)(`strong`,{children:`启动网关`}),(0,m.jsxs)(`span`,{children:[`执行 `,(0,m.jsx)(`code`,{children:b}),`,管理页默认在 `,(0,m.jsx)(`code`,{children:`http://127.0.0.1:8787`}),`。`]})]}),(0,m.jsxs)(`li`,{children:[(0,m.jsx)(`strong`,{children:`复制接入参数`}),(0,m.jsxs)(`span`,{children:[`Base URL 用 `,(0,m.jsx)(`code`,{children:v}),`,API Key 用 `,(0,m.jsx)(`code`,{children:y}),`。`]})]}),(0,m.jsxs)(`li`,{children:[(0,m.jsx)(`strong`,{children:`下载 Skill.md`}),(0,m.jsx)(`span`,{children:`把这份文档保存到你的工作流里,或直接复制给支持 Skill 的工具。`})]})]})]}),(0,m.jsxs)(`section`,{className:`docs-panel`,children:[(0,m.jsx)(`div`,{className:`docs-panel-head`,children:(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{children:`接入模板`}),(0,m.jsx)(`p`,{children:`最少只需要这两项。`})]})}),(0,m.jsxs)(`div`,{className:`docs-mini-grid`,children:[(0,m.jsxs)(`button`,{className:`docs-mini-copy`,type:`button`,onClick:n,children:[(0,m.jsx)(`span`,{children:`Base URL`}),(0,m.jsx)(`strong`,{children:v}),(0,m.jsx)(a,{size:14})]}),(0,m.jsxs)(`button`,{className:`docs-mini-copy`,type:`button`,onClick:()=>void c(y).then(e=>r(e?`API Key 已复制。`:`API Key 复制失败。`)),children:[(0,m.jsx)(`span`,{children:`API Key`}),(0,m.jsx)(`strong`,{children:y}),(0,m.jsx)(a,{size:14})]})]}),(0,m.jsx)(`pre`,{className:`docs-code-sample`,children:(0,m.jsx)(`code`,{children:w})})]}),(0,m.jsxs)(`section`,{className:`docs-panel docs-panel-wide`,children:[(0,m.jsx)(`div`,{className:`docs-panel-head`,children:(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{children:`常用接口`}),(0,m.jsx)(`p`,{children:`这个 Skill 文档覆盖了模型、对话和生图三类常见用法。`})]})}),(0,m.jsx)(`div`,{className:`docs-endpoint-grid`,children:[`/v1/models`,`/v1/chat/completions`,`/v1/responses`,`/v1/images/generations`].map(e=>(0,m.jsxs)(`div`,{className:`docs-endpoint`,children:[(0,m.jsx)(`span`,{children:e}),(0,m.jsx)(d,{size:14})]},e))})]})]}):null,g===`skill`?(0,m.jsxs)(`section`,{className:`docs-panel docs-preview-panel`,children:[(0,m.jsx)(`div`,{className:`docs-panel-head`,children:(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h3`,{children:`Skill.md 摘要`}),(0,m.jsx)(`p`,{children:`先看关键信息,再按需展开源码。`})]})}),(0,m.jsx)(`div`,{className:`docs-skill-summary`,children:C.map(e=>(0,m.jsxs)(`article`,{className:`docs-summary-tile`,children:[(0,m.jsx)(`span`,{children:e.label}),(0,m.jsx)(`strong`,{children:e.value})]},e.label))}),(0,m.jsxs)(`details`,{className:`docs-source-fold`,children:[(0,m.jsxs)(`summary`,{children:[`查看源码`,(0,m.jsxs)(`span`,{children:[x,` 行`]})]}),(0,m.jsx)(`pre`,{className:`docs-source`,children:(0,m.jsx)(`code`,{children:f})})]})]}):null,g===`examples`?(0,m.jsxs)(`div`,{className:`docs-example-grid`,children:[(0,m.jsx)(h,{title:`OpenAI SDK`,description:`适合前端和本地脚本。`,code:T,onCopy:()=>void c(T).then(e=>r(e?`OpenAI SDK 示例已复制。`:`复制失败。`))}),(0,m.jsx)(h,{title:`curl Chat Completions`,description:`最直接的接口自测方式。`,code:E,onCopy:()=>void c(E).then(e=>r(e?`Chat Completions 示例已复制。`:`复制失败。`))}),(0,m.jsx)(h,{title:`Responses API`,description:`适用于新式文本生成调用。`,code:D,onCopy:()=>void c(D).then(e=>r(e?`Responses API 示例已复制。`:`复制失败。`))}),(0,m.jsxs)(`section`,{className:`docs-panel docs-note-panel`,children:[(0,m.jsx)(`h3`,{children:`用户如何使用`}),(0,m.jsxs)(`ul`,{children:[(0,m.jsx)(`li`,{children:`在侧边栏打开“使用文档”。`}),(0,m.jsx)(`li`,{children:`先复制 Base URL 和 API Key,再下载 Skill.md。`}),(0,m.jsx)(`li`,{children:`把 Skill.md 放到你的 AI 工具、项目文档或自动化流程里。`}),(0,m.jsx)(`li`,{children:`需要验证时,直接跳到“接口测试”页面跑一条请求。`})]}),(0,m.jsxs)(`div`,{className:`docs-action-row`,children:[(0,m.jsxs)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>t(`overview`),children:[(0,m.jsx)(i,{size:16}),`回到概览`]}),(0,m.jsxs)(`button`,{className:`btn-secondary`,type:`button`,onClick:()=>t(`tester`),children:[(0,m.jsx)(s,{size:16}),`去接口测试`]})]})]})]}):null]})})]})}export{g as DocsPage};
|