统一域名 https://tokenzj.com · Midjourney / Google AI Studio 官方池 / 自建 Gemini(账号池)· 公网 HTTPS
aistudio / gemini / mj 三类范围,单 Key 可绑多 scope),然后在请求里携带:
Authorization: Bearer sk-xxxxxxxxxxxxxxxxMidjourney 部分接口若按其原协议使用
mj-api-secret 头,亦可改用 mj-api-secret: sk-xxxx;OSS 拉图接口若用 ?token= 也可填本平台 Key。
基于 trueai-org/midjourney-proxy 部署,Official 模式直连 Midjourney API。
| 基础信息 | 值 |
|---|---|
| 服务地址 | https://tokenzj.com(API 路径前缀 /mj/) |
| 认证 | Header: Authorization: Bearer sk-xxx(在控制台创建,scope 含 mj)或 mj-api-secret: sk-xxx,二选一 |
| OSS 图片获取 | https://tokenzj.com/task/{taskId}/oss-urls?token=sk-xxx |
curl https://tokenzj.com/mj/submit/imagine \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"botType":"MID_JOURNEY","prompt":"a cat astronaut --ar 2:3","base64Array":[]}'
{
"botType": "MID_JOURNEY",
"prompt": "https://your-oss-url/ref.png 一只猫咪 --ar 2:3 --s 300",
"base64Array": [],
"accountFilter": {
"channelId": "", "instanceId": "", "modes": [], "remix": true
}
}
响应:
{ "code": 1, "description": "提交成功", "result": "1775794513090387" }
s.mj.run 链接。无需 base64。{
"id": "1775794513090387",
"status": "SUCCESS", // NOT_START / SUBMITTED / IN_PROGRESS / SUCCESS / FAILURE
"progress": "100%",
"imageUrl": "https://cdn.midjourney.com/xxx/0_0.webp",
"submitTime": 1775794513,
"finishTime": 1775794560
}
Authorization: Bearer sk-xxx 头形式。{
"task_id": "1775794513090387",
"status": "done",
"oss_urls": [
"https://books-nigu.oss-cn-shenzhen.aliyuncs.com/mjopen/midjourney_xxx_1.webp",
"..."
]
}
1. POST https://tokenzj.com/mj/submit/imagine → taskId (Header: Authorization: Bearer sk-xxx)
2. 轮询 GET /mj/task/{id}/fetch → 等待 SUCCESS
3. GET /task/{id}/oss-urls?token=sk-xxx → 拿到 OSS 图片 URL 列表
OpenAI Chat Completions 兼容接口。后端聚合一组 Google AI Studio API Key(AIza...),按 RPM/RPD 与 per-project 配额 智能调度,自动绕开单 Key 的每日额度上限并保留 10% 安全水位。
| 基础信息 | 值 |
|---|---|
| 服务地址 | https://tokenzj.com/aistudio/v1/ |
| 认证 | Authorization: Bearer sk-xxx(控制台创建,scope 含 aistudio)。客户端无需持有任何 Google 凭证,平台自动从 Key 池调度并注入 X-goog-api-key。 |
| 响应头 | X-Used-Key-Name 标识本次实际命中的 Key 名称(便于排查)。 |
| 上游 | generativelanguage.googleapis.com(每个 Key 可绑定独立 sticky 代理出口) |
所有 Gemini 系(AI Studio + 自建账号池)的图/聊天接口都内置一个 LLM 重写器:你可以直接把发给 MJ 的 prompt 原封不动发给我们,平台会在送给 Gemini 之前调用 gemini-flash-latest 把它**理解式重写**成 Gemini 官方推荐的叙事段落(不是关键词字典替换),并把 --ar 提取出来走 官方 generationConfig.imageConfig.aspectRatio API 字段,不再塞进 prompt 文本。这条路径专门解决三件事:
--no book mockup 当强阳性 keyword 读成 "书的 mockup"强制平面 2D 风格:本平台只用于 2D 插画/装饰画/Logo 等平面创作,不出物理实体。重写器的 system prompt 内置一份禁词清单(photo / DSLR / 3D render / octane / 8K / hyper-realistic / masterpiece 等),即使原 prompt 出现这些词也会被丢弃并改写为对应的 2D 描述("Mucha-style 平面装饰" / "flat heraldic 2D" / "woodblock print 风格")。
prompt_format 四档开关(请求体顶层):
| 取值 | 行为 | 典型场景 |
|---|---|---|
"auto"(默认) | 检测到 MJ 语法或 prompt 较长则走 LLM 重写;纯短叙事段落直接 passthrough | 大多数业务方 |
"midjourney" | 强制走 LLM 重写,不论格式 | 明确知道传的是 MJ DSL |
"gemini_native" | 跳过重写;只把 --ar 提取到 imageConfig 字段 | 已经按 Gemini 风格写好的 prompt |
"raw" | 整个兼容层完全跳过,prompt 一字不改下发 | 对照实验 / 故障排查 |
aspect_ratio 走官方 API 字段:重写器从 --ar 抽出比例,校验后写入 generationConfig.imageConfig.aspectRatio。支持 1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9(来自 Google 官方)。比例不在白名单内则 fallback 到模型默认 1:1。
kind 自动分类(6 种 2D 子类型):重写器会把每条 prompt 归类到 decorative_panel(装饰画/涂色本/Art Nouveau)/ editorial_illustration(杂志插画)/ flat_logo_or_mark(Logo)/ flat_pattern(连续花纹)/ chinese_traditional(国画工笔)/ western_classical(铜版画/木刻),并按 8 维度补全(subject / action / environment / lighting / medium / mood / composition / color treatment)。
透明度 — drops 列表:每次重写返回的 prompt_hints.drops 数组会列出"被丢弃了什么、为什么"(--ar 1:1 (extracted to aspect_ratio) / "ivory cream" 从调色板移除以抑制白边偏置 / "masterpiece, 8K" SD 噪声词,已删除),便于业务方调试。同时还返回 quality_score(1-5) 是重写器对输出的自评。
缓存策略:重写结果按 SHA1(input + prompt_format) 落 SQLite,TTL 30 天。相同 prompt 第二次提交不会再扣一次重写费(适配批量场景)。prompt_hints.cache_hit = true 时 latency ≈ 0ms。
白边自动裁剪 (auto_trim, 默认 OFF):旧版本默认开启的服务端裁边逻辑现已默认关闭——因为 V2 重写器在 prompt 层就把白边偏置消除了,且裁边会改变图片比例(用户明确不接受后期处理改尺寸)。如果你确实不在乎比例,可以在请求体加 "auto_trim": true 开启兜底裁剪。
fallback 兜底:LLM 重写器调用失败(quota 耗尽、超时、JSON 解析错误等),自动降级到老的正则归一化路径(剥 flag + 拼 negatives 句),prompt_hints.rewrite_kind = "fallback_regex",fallback_reason 字段会记录原因。从不阻塞调用。
任务详情页(管理后台)显示完整 pipeline:原始输入 / 送给模型 双栏对比 + drops 明细 + kind / quality_score / 重写器延迟 / 缓存命中。/mj/* 端点不受影响(MJ 原生支持自家 DSL)。
# 业务方一份 prompt 通跑 MJ 和 Gemini,无需手动改写
curl https://tokenzj.com/aistudio/v1/images/generations \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "A grand gothic castle with intricate spires rises from swirling mists --ar 1:1 --s 300 --no collage, grid, split image, physical book, book spine, hardcover, paperback, book mockup, 3D render, border frame, watermark, signature, clip-art"
}'
# 平台改写后送给 Gemini 的真实 body:
# POST .../v1beta/models/gemini-2.5-flash-image:generateContent
# {
# "contents": [{"role":"user","parts":[{"text":"Generate an image: Create a brooding flat 2D illustration of a tall gothic castle perched on a jagged cliff edge at twilight, its many spires and pointed turrets silhouetted against a deep violet sky streaked with rose-gold cloud bands. Heavy mist rolls in low across the cliff base, breaking around the foundations and dissolving into the valley below... The valley is empty of any inhabitant or vehicle... Render in a limited palette of midnight indigo, smoky teal, and warm rose-gold highlights with flat solid color fills and faint cross-hatching for shadow, in the manner of a vintage travel poster, drawn entirely as a single flat-plane composition rather than a 3D render."}]}],
# "generationConfig": { "imageConfig": { "aspectRatio": "1:1" } }
# }
#
# 返回里 prompt_hints.drops 会列出:
# ["--ar 1:1 (extracted to aspect_ratio)",
# "--s 300 (Midjourney stylize flag, no Gemini equivalent)",
# "--no collage, grid, ... (converted to semantic positives)",
# "physical book / hardcover / book mockup (rephrased as scene-appropriate description)",
# "3D render (forbidden token, dropped)",
# "clip-art (low-quality token, dropped)"]
stream: true 流式输出(SSE)。Vision 输入可在 content 数组中传 image_url。curl https://tokenzj.com/aistudio/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-flash-latest",
"messages": [{"role":"user","content":"用一句话解释什么是 RAG"}],
"temperature": 0.7
}'
gemini-2.5-flash-image(俗称 Nano Banana)。默认返回阿里云 OSS 永久 URL(图片已自动转存 books-nigu/aistudio/YYYY/MM/DD/...png)。指定 response_format=b64_json 仍返回原始 base64 兼容老客户端。支持参考图(图生图 / 图片编辑):在请求体加 images: ["https://...","data:image/png;base64,..."],最多 8 张,每张 ≤ 20MB;可与 prompt 任意搭配。同步调用最长等 ~120s,建议批量任务用下文异步 / 批量接口。curl https://tokenzj.com/aistudio/v1/images/generations \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "a cute cat astronaut, cyberpunk style",
"n": 1,
"images": [
"https://books-nigu.oss-cn-shenzhen.aliyuncs.com/genimg/2026/04/10/sample.png"
]
}'
# 返回示例
{
"created": 1745392000,
"data": [
{ "url": "https://books-nigu.oss-cn-shenzhen.aliyuncs.com/aistudio/2026/04/24/1745...png",
"mime_type": "image/png" }
],
"_account": "tholevan86-aistudio",
"_task_id": "7f3b...e21"
}
task_id,由后台 worker 池调度执行。客户端轮询 poll_url 拿结果,避免长连接超时;图片自动入 OSS。# 1. 提交
curl -X POST https://tokenzj.com/aistudio/v1/images/async \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "vintage red car under cherry blossoms",
"n": 1,
"images": ["https://books-nigu.oss-cn-shenzhen.aliyuncs.com/.../ref.png"]
}'
# → {"task_id":"7f3b...","status":"queued","model":"gemini-2.5-flash-image",
# "poll_url":"/aistudio/v1/tasks/7f3b..."}
# 2. 轮询(建议 2-5 秒一次)
curl https://tokenzj.com/aistudio/v1/tasks/7f3b... \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
# → {
# "task_id":"7f3b...","status":"done",
# "model":"gemini-2.5-flash-image","account":"tholevan86-aistudio:gemini-2.5-flash-image",
# "image_urls":["https://books-nigu.oss-cn-shenzhen.aliyuncs.com/aistudio/2026/04/24/...png"],
# "image_count":1,"duration_ms":7800,
# "created_at":1745..,"started_at":1745..,"ended_at":1745..
# }
# 3. 取消(仅 queued/running 有效)
curl -X DELETE https://tokenzj.com/aistudio/v1/tasks/7f3b... \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
状态机:queued → running → done | failed | cancelled。
同样的异步范式适用于纯文本:POST /aistudio/v1/chat/async,请求体与 chat/completions 一致。
batch_id 用于查询整体进度。# 1. 提交批
curl -X POST https://tokenzj.com/aistudio/v1/images/batch \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompts": [
"a red apple on a wooden table",
{ "prompt": "make this car blue", "images": ["https://.../car.png"] },
"a yellow flower in macro shot"
],
"images": ["https://books-nigu.oss-cn-shenzhen.aliyuncs.com/.../style-ref.png"],
"n": 1,
"concurrency": 4,
"name": "demo-batch"
}'
# prompts 支持两种写法:
# - 字符串:仅文本 prompt(沿用顶层 images 作共享参考图)
# - 对象 {prompt, images}:自定义本条 prompt 的参考图(与顶层 images 合并)
# 顶层 images 会作为整批共享参考图,最多 8 张/任务,单张 ≤ 20MB。
# → {"batch_id":"b9a...","total":3,"concurrency":4,"task_ids":["...","...","..."],
# "poll_url":"/aistudio/v1/tasks/batch/b9a..."}
# 2. 查整批进度(默认带每个子任务详情,?include_tasks=false 只看汇总)
curl https://tokenzj.com/aistudio/v1/tasks/batch/b9a... \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
# → {
# "batch_id":"b9a...","name":"demo-batch","status":"running",
# "total":3,"concurrency":4,
# "counts": {"done":2,"failed":0,"cancelled":0,"running":1,"queued":0},
# "tasks":[ {...}, {...}, {...} ]
# }
# 3. 取消整批
curl -X DELETE https://tokenzj.com/aistudio/v1/tasks/batch/b9a... \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
批量 status 解释:queued 全部待跑;running 有任务在跑;done 全成功;partial 部分成功部分失败;failed 全失败;cancelled 全部被取消。
建议轮询节奏:3-5 秒一次。后台 worker 数 = AISTUDIO_WORKERS env,默认 8;每个 (Key, 模型) 仍受 RPM/RPD 调度器限速。
下表为 Free Tier 出厂限制,调度器实际安全水位 = 额度 × 0.9(达到即跳过该 Key)。Tier1(付费)后台单独建 Key 时选 tier1 即可享受千倍 RPM/RPD。
| 模型 ID | RPM | RPD(free) | 能力 |
|---|---|---|---|
gemini-flash-latest | 10 | 250 | 文本(推荐入门) |
gemini-2.5-flash | 10 | 250 | 文本 + Vision |
gemini-2.5-flash-lite | 15 | 1000 | 大额度文本 |
gemini-2.5-pro | 5 | 100 | 高质量 |
gemini-2.5-flash-image | 10 | 100 | 生图(Nano Banana) |
gemini-3-pro-preview | 2 | 50 | Gemini 3 Pro |
gemini-3-flash-preview | 5 | 100 | Gemini 3 Flash |
project_id 字段后,调度器会自动按 project 汇总扣减。
基于自建 gemini-webapi(HanaokaYuzu/Gemini-API 系)+ 多 Google 账号轮询。统一走本域名 /gemini/v1/。同一套 prompt 兼容层(LLM 重写器 + 自动 aspect_ratio)与 AI Studio 共用。
| 基础信息 | 值 |
|---|---|
| 对外基础地址 | https://tokenzj.com(子路径 /gemini/v1/) |
| 认证 | 客户端调用:Authorization: Bearer sk-xxx(在控制台创建,scope 含 gemini)管理接口( /admin/*):X-Admin-Key,请登录 开发者控制台 操作 |
| 实现说明 | 基于自建 gemini-webapi + Google 账号池(Cookie + 代理),每账号一个独立 sticky 代理,worker 按「今日剩余额度从高到低」轮询 |
以下表格由服务端 GET /gemini/v1/models 动态维护,每条记录 capabilities.image_out=true 才能走文生图/图生图端点,否则只支持文本。
| 模型 ID | 文本输出 | 图片输入(ref) | 图片输出 | 档位要求 | 说明 |
|---|---|---|---|---|---|
unspecified | ✓ | ✓ | ✓ | free | 自动路由,由 Google 决定最终模型(最稳妥) |
gemini-3-flash | ✓ | ✓ | ✗ | free | 轻量文本对话 + 参考图输入 |
gemini-3-pro | ✓ | ✓ | ✗ | pro | 高质量文本对话,可读图但不生成图 |
gemini-3-flash-thinking | ✓ | ✓ | ✗ | pro | Flash 推理链 |
gemini-3-pro-plus | ✓ | ✓ | ✓ | pro | Pro 档增强,可生图 |
gemini-3-flash-plus | ✓ | ✓ | ✓ | pro | Flash 档增强,可生图 |
gemini-3-flash-thinking-plus | ✓ | ✓ | ✗ | pro | Flash thinking 增强 |
gemini-3-pro-advanced | ✓ | ✓ | ✓ | ultra | Ultra 档 Pro 模型,可生图 |
gemini-3-flash-advanced | ✓ | ✓ | ✓ | ultra | Ultra 档 Flash 模型,可生图 |
gemini-3-flash-thinking-advanced | ✓ | ✓ | ✗ | ultra | Ultra 档 Flash thinking |
Google Gemini Web 对每个账号的生图张数有硬上限,超出会临时封禁。平台按「订阅档位」设定软安全帽(5% 余量),由管理员在账号录入时选择;命中上限后自动在账号池里跳过,并在全部账号都打满时返回 HTTP 429。
| 档位 | 硬上限(Google) | 平台安全帽 | 说明 |
|---|---|---|---|
free | ~50 | 40 | 免费 Gemini 账号(含未订阅 Gmail) |
pro | 100 | 95 | Gemini Advanced / Pro 订阅 |
ultra | 1000 | 950 | Ultra 订阅 |
账号可在管理后台覆盖 daily_cap 自定义数值。日界按 America/Los_Angeles 00:00,与 Google 计费粒度对齐。
# 命中上限时的返回
HTTP/1.1 429 Too Many Requests
{
"detail": {
"type": "all_accounts_capped",
"message": "all enabled gemini accounts have reached today's image cap",
"usage": [
{"name":"gmail-1","used":95,"cap":95,"tier":"pro"},
{"name":"gmail-2","used":90,"cap":90,"tier":"pro"}
],
"resets_at_pacific_midnight": 1777648800
}
}
只传 prompt + model,无 images 字段。必须选择上表中 image_out=✓ 的模型(典型:gemini-3-flash-plus / gemini-3-pro-plus / -advanced 系列,或 unspecified)。
--ar、--no)转成 Gemini native 叙事 + aspect_ratio,返回可公开访问的 OSS URL。curl https://tokenzj.com/gemini/v1/images/generations \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-flash-plus",
"prompt": "a cat astronaut, cyberpunk style --ar 3:2 --no text, watermark",
"n": 1
}'
# 响应
{
"created": 1777600000,
"data": [{ "url": "https://books-nigu.oss-cn-shenzhen.aliyuncs.com/genimg/..." }],
"_account": "gmail-2",
"_task_id": "..."
}
在上面的请求体加 顶层 images 数组(URL 或 data-uri),Gemini 会把它们当参考图带入生成。最多 8 张,单张 ≤ 20MB。无独立 /images/edits 路径;同一端点根据请求体是否包含 images 自动切换文生图/图生图。
curl https://tokenzj.com/gemini/v1/images/generations \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-pro-plus",
"prompt": "把这张照片改成赛博朋克夜景风格,保留人物轮廓",
"images": [
"https://books-nigu.oss-cn-shenzhen.aliyuncs.com/.../portrait.jpg"
],
"n": 1
}'
POST /gemini/v1/chat/completions 也支持多模态入参:在 messages.content 数组里加 {"type":"image_url","image_url":{"url":"..."}},或顶层加 images: ["url"...]。文生图场景直接留空即可。stream: true(SSE)。如果模型 image_out=true 且 prompt 含生图指令,响应 content 会追加 Markdown 图片链接;否则只返回文本。curl https://tokenzj.com/gemini/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-pro",
"messages": [
{ "role": "user", "content": [
{ "type": "text", "text": "这张图里有什么元素?" },
{ "type": "image_url", "image_url": { "url": "https://.../photo.jpg" } }
]}
],
"stream": false
}'
长耗时请求(如 30+ 秒生图)或批量任务建议走异步通道,由后端 worker 池排队消费,状态机:queued → running → done | failed | cancelled。所有 5 个端点与 AI Studio 侧等价,但用的是 cookie 池的独立 worker(环境变量 GEMINI_WORKERS,默认 4)与独立日配额。
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /gemini/v1/images/async | 提交一个文生图/图生图任务(body 同 /images/generations),立即返回 task_id |
| POST | /gemini/v1/chat/async | 提交一个非流式聊天任务,立即返回 task_id(stream 请走同步端点) |
| GET | /gemini/v1/tasks/{task_id} | 轮询任务状态;status === "done" 时 image_urls 为最终 OSS URL 列表 |
| DELETE | /gemini/v1/tasks/{task_id} | 取消 queued/running 任务 |
| POST | /gemini/v1/images/batch | 一次提交最多 200 条 prompt,返回 batch_id 与 task_ids |
| GET | /gemini/v1/tasks/batch/{batch_id} | 返回批次聚合状态 + 内部 task 列表 |
| DELETE | /gemini/v1/tasks/batch/{batch_id} | 批量取消(只作用于 queued/running) |
# 1. 提交
curl -X POST https://tokenzj.com/gemini/v1/images/async \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model":"gemini-3-flash-plus","prompt":"a calm lake at sunrise --ar 16:9"}'
# -> { "task_id": "ab12…", "status": "queued", "poll_url": "/v1/tasks/ab12…" }
# 2. 轮询(2~5s 间隔)
curl https://tokenzj.com/gemini/v1/tasks/ab12… \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
# -> { "task_id": "ab12…", "status": "done",
# "image_urls": ["https://books-nigu.oss-cn-shenzhen.aliyuncs.com/..."], ... }
# 3. 批量提交
curl -X POST https://tokenzj.com/gemini/v1/images/batch \
-H "Authorization: Bearer sk-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-flash-plus",
"concurrency": 4,
"prompts": [
"a red fox in snow",
"a cyberpunk cat astronaut",
{ "prompt": "a watercolor lake", "images": ["https://.../ref.png"] }
]
}'
# -> { "batch_id": "b9c…", "total": 3, "task_ids": ["…","…","…"], ... }
tasks.status IN ('queued','running') 的 gemini 任务自动重新入队;已经 done/failed 的记录不会重新跑。 gemini_usage 计数器,按 实际返回的图片张数 递增(失败不计)。
capabilities / tier_required / notes,可直接喂给前端动态渲染模型选择器。curl https://tokenzj.com/gemini/v1/models \
-H "Authorization: Bearer sk-xxxxxxxxxxxx"
# -> { "object": "list", "data": [
# { "id": "gemini-3-flash-plus", "capabilities": {"text":true,"image_in":true,"image_out":true},
# "tier_required": "pro", "notes": "Flash 档增强,可生图" },
# ...
# ]}
X-Admin-Key。gemini-flash-latest);默认开启,prompt_format 可选 auto(默认)/ midjourney / gemini_native / raw。