feat(generate-image): 新增可选的 Atlas Cloud provider(并给 --ref 补一条回退路径) - #2
Open
binyangzhu000-sudo wants to merge 1 commit into
Open
feat(generate-image): 新增可选的 Atlas Cloud provider(并给 --ref 补一条回退路径)#2binyangzhu000-sudo wants to merge 1 commit into
binyangzhu000-sudo wants to merge 1 commit into
Conversation
脚本现在支持 OpenRouter 和 Gemini 两条路,都需要对应地区能直连的官方 API。
新增 --provider atlas,用 Atlas Cloud 调同一批模型;**默认 provider 顺序不变**
(OPENROUTER → GEMINI → ATLASCLOUD),不配 ATLASCLOUD_API_KEY 时行为完全一致。
单开一条调用路径而不是把 OpenRouter 的 base URL 指过去,是实测的结果:Atlas 的
图像模型从 /v1/chat/completions 返回 400(带不带 modalities 都一样),它走的是
异步的提交-轮询接口,所以 generateImageAtlas() 自己实现 submit → poll → download,
返回和另两条分支一样的 { imageData, mimeType }。
顺带修掉一个能力缺口:原来 --ref 只能走 Gemini(OpenRouter 不支持图片输入),
没有 GEMINI_API_KEY 时直接退出。Atlas 把参考图放在 images 字段、并自动把调用名
切到模型的 /edit 任务,所以现在 OpenRouter + --ref 多了一条回退路径。
实测行为写进了 usage 和 SKILL.md:
- --aspect-ratio 有效(默认模型 nano-banana-pro 认 aspect_ratio,16:9 实测 1376×768)
- --size 2k 在该模型上没有对应字段,会打印提示并返回模型默认分辨率;需要精确尺寸
时换 bytedance/seedream-v4(精确遵守尺寸,但最小 921600 像素)
- 返回的容器不固定:同一个模型一次 PNG、一次 JPEG,所以新增一行「扩展名与实际
字节不符」的提示,避免留下一个没人解释的 .png 里装 JPEG
- api.atlascloud.ai 会用 403(error code 1010) 拒掉部分客户端的默认 User-Agent,
所以请求显式带 UA
验证:--provider atlas 出图 147KB PNG(1376×768,16:9);带 --ref 时自动切到
/edit 并出图;三个 key 都不配时报错列出全部三个变量名。
Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
scripts/generate-image.ts现在支持 OpenRouter 和 Gemini 两条路,都要求对应地区能直连官方 API。这个 PR 加
--provider atlas,用 Atlas Cloud调同一批模型。
默认 provider 顺序不变(OPENROUTER → GEMINI → ATLASCLOUD),不配
ATLASCLOUD_API_KEY时行为完全一致。
为什么单开一条调用路径
我先试了最省事的做法——把 OpenRouter 分支的 base URL 指向 Atlas、换个 model id。实测不行:
Atlas 的图像模型从
/v1/chat/completions返回400,带不带modalities: ["image","text"]都一样。它走的是异步的提交-轮询接口,所以
generateImageAtlas()自己实现 submit → poll → download,返回和另两条分支一样的
{ imageData, mimeType },调用点只多一个分支。顺带修掉一个能力缺口
原来
--ref只能走 Gemini(OpenRouter 不支持图片输入),没有GEMINI_API_KEY时直接退出。Atlas 把参考图放在
images字段,并且会自动把调用名切到模型的/edit任务,所以现在「OpenRouter +
--ref」多了一条回退路径,而不是只能报错。实测差异(已写进 usage 和 SKILL.md)
--aspect-ratiogoogle/nano-banana-pro/text-to-image认aspect_ratio,16:9实测 1376×768--size 2k--model bytedance/seedream-v4(精确遵守尺寸,但最小 921600 像素)api.atlascloud.ai会用403 error code 1010拒掉部分客户端的默认User-Agent,所以请求显式带 UA因为容器不固定,这个 PR 还加了一行提示:当写出的字节和
--output的扩展名不符时打印一句说明。这条对三个 provider 都生效——留下一个
.png里装着 JPEG 而没人解释,比多打一行日志糟糕。文件路径本身没改,仍然写用户指定的那个。
验证
--provider atlas --aspect-ratio 16:9→ 147 KB PNG,1376×768。--ref diagram.png --provider atlas→ 自动切到/edit,出图成功。示例里的 key 一律是环境变量占位,diff 里没有真实凭证。
🤝 合作 & 联系
这个 PR 来自 Atlas Cloud 团队。除了上面的集成,我们很乐意和 smart-illustrator 探讨更深入的合作 —— 比如联合营销(co-marketing),或互相做 featured integration 推荐。
如果有兴趣,欢迎随时联系:
当然,也很乐意按你们项目的规范调整这个 PR —— 留个 comment 就行。🙌