From e8d1aa25aa5aa67e93e9114573b48eda2b55d491 Mon Sep 17 00:00:00 2001
From: 134
Date: Tue, 21 Jul 2026 11:01:43 +0800
Subject: [PATCH] feat: add Atlas Cloud image provider
---
app/(admin)/settings/_lib/types.ts | 1 +
.../settings/admin-settings-client.tsx | 73 +++
app/(chat)/api/chat/_lib/image-failover.ts | 2 +
app/(chat)/api/chat/_lib/image-media.ts | 1 +
app/(chat)/api/chat/_lib/stream.ts | 1 +
app/(chat)/api/chat/route.ts | 13 +
app/api/admin/ai-providers/route.ts | 4 +
app/api/admin/atlascloud-models/route.ts | 155 +++++
app/api/canvas/text-edit/route.ts | 12 +-
app/api/scene-fusion/route.ts | 58 +-
components/image-generation-loading.tsx | 1 +
components/image-params-bar.tsx | 1 +
components/image-preview.tsx | 3 +
lib/ai/atlascloud-models.ts | 523 +++++++++++++++
lib/ai/dynamic-provider.ts | 13 +
lib/ai/model-classification.ts | 1 +
lib/ai/model-router.ts | 13 +-
lib/ai/provider-defaults.ts | 1 +
lib/ai/providers/atlascloud.ts | 596 ++++++++++++++++++
lib/canvas/generate-image.ts | 25 +-
lib/db/migrate.ts | 3 +-
.../0092_add_atlascloud_provider_type.sql | 40 ++
lib/db/migrations/meta/_journal.json | 7 +
lib/db/queries.ts | 4 +-
lib/db/schema.ts | 2 +-
lib/external-image-api/service.ts | 1 +
lib/scene-fusion/output-capabilities.ts | 2 +
27 files changed, 1541 insertions(+), 15 deletions(-)
create mode 100644 app/api/admin/atlascloud-models/route.ts
create mode 100644 lib/ai/atlascloud-models.ts
create mode 100644 lib/ai/providers/atlascloud.ts
create mode 100644 lib/db/migrations/0092_add_atlascloud_provider_type.sql
diff --git a/app/(admin)/settings/_lib/types.ts b/app/(admin)/settings/_lib/types.ts
index 7a89fcbe5..38740da8f 100644
--- a/app/(admin)/settings/_lib/types.ts
+++ b/app/(admin)/settings/_lib/types.ts
@@ -90,6 +90,7 @@ export type AdminAiProvider = {
| "openai-image"
| "bananaimage"
| "visionary"
+ | "atlascloud"
| "stepfun-image"
| "midjourney"
| "fal-video"
diff --git a/app/(admin)/settings/admin-settings-client.tsx b/app/(admin)/settings/admin-settings-client.tsx
index d26512e1f..37bb911de 100644
--- a/app/(admin)/settings/admin-settings-client.tsx
+++ b/app/(admin)/settings/admin-settings-client.tsx
@@ -625,6 +625,7 @@ type AiProvider = {
| "openai-image"
| "bananaimage"
| "visionary"
+ | "atlascloud"
| "stepfun-image"
| "midjourney"
| "fal-video"
@@ -1585,6 +1586,7 @@ const PROVIDER_TYPES = [
{ value: "openai-image", label: "OpenAI 图片兼容" },
{ value: "bananaimage", label: "BananaImage 生图" },
{ value: "visionary", label: "Visionary 生图" },
+ { value: "atlascloud", label: "Atlas Cloud 图片模型" },
{ value: "stepfun-image", label: "阶跃星辰 Step Image Edit" },
{ value: "bltcy-video", label: "柏拉图统一视频" },
{ value: "grsai-gpt-image", label: "Grsai GPT Image" },
@@ -1621,6 +1623,7 @@ const PROVIDER_DEFAULT_BASE_URL: Record = {
"openai-image": "https://api.openai.com/v1",
bananaimage: "https://bananaimage.aigenmedia.art",
visionary: "https://api.visionary.beer",
+ atlascloud: "https://api.atlascloud.ai",
"stepfun-image": "https://api.stepfun.com",
"bltcy-video": "https://api.bltcy.ai",
"grsai-gpt-image": "https://grsai.dakka.com.cn",
@@ -4039,6 +4042,7 @@ export function AdminSettingsClient() {
| "openai-image"
| "bananaimage"
| "visionary"
+ | "atlascloud"
| "stepfun-image"
| "midjourney"
| "fal-video"
@@ -6277,6 +6281,7 @@ export function AdminSettingsClient() {
const isSnapgenImageProvider = providerForm.type === "snapgen-image";
const isBananaImageProvider = providerForm.type === "bananaimage";
const isVisionaryProvider = providerForm.type === "visionary";
+ const isAtlasCloudProvider = providerForm.type === "atlascloud";
const isBltcyVideoProvider = providerForm.type === "bltcy-video";
const isLemonProvider =
providerForm.type === "openai" &&
@@ -6441,6 +6446,17 @@ export function AdminSettingsClient() {
}
}
+ if (isNewProvider && isAtlasCloudProvider && providerId) {
+ try {
+ await handleQuickAddAtlasCloudModels(providerId, { skipConfirm: true });
+ } catch (modelError) {
+ console.error("[Auto Add Atlas Cloud Models] Error:", modelError);
+ toast.warning(
+ 'Atlas Cloud 模型同步失败,请手动点击"同步 Atlas Cloud 全部图片模型"按钮'
+ );
+ }
+ }
+
if (isNewProvider && isBltcyVideoProvider && providerId) {
try {
await handleQuickAddBltcyVideoModels(providerId, {
@@ -7490,6 +7506,45 @@ export function AdminSettingsClient() {
}
};
+ const handleQuickAddAtlasCloudModels = async (
+ providerId: string,
+ options?: { skipConfirm?: boolean }
+ ) => {
+ if (
+ !options?.skipConfirm &&
+ !confirm(
+ "将从 Atlas Cloud 官方目录同步全部开放图片模型,并读取每个模型的参数 Schema。同步数量较多,可能需要几十秒。\n\n继续吗?"
+ )
+ ) {
+ return;
+ }
+
+ try {
+ toast.info("正在读取 Atlas Cloud 官方目录和模型参数...");
+ const response = await fetch("/api/admin/atlascloud-models", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ providerId }),
+ });
+ const data = await response.json();
+ if (!response.ok) throw new Error(data.error || "同步失败");
+
+ const totalSynced =
+ Number(data.addedCount || 0) + Number(data.updatedCount || 0);
+ toast.success(
+ `已同步 ${totalSynced} 个 Atlas Cloud 图片模型(官方目录共 ${Number(data.counts?.total || totalSynced)} 个)`
+ );
+ mutateModels();
+ if (data.errors?.length) {
+ toast.warning(`${data.errors.length} 个 Atlas Cloud 模型读取或同步失败`);
+ }
+ } catch (error: any) {
+ console.error("[Quick Add Atlas Cloud Models] Error:", error);
+ toast.error(error.message || "同步 Atlas Cloud 图片模型失败");
+ throw error;
+ }
+ };
+
const handleUseFalImageProviderPreset = () => {
setProviderForm({
id: "",
@@ -15706,6 +15761,13 @@ export function AdminSettingsClient() {
质量档位和 1K/2K/4K 输出。
)}
+ {providerForm.type === "atlascloud" && (
+
+ Atlas Cloud 使用 Bearer API Key 认证,默认地址
+ https://api.atlascloud.ai。保存后会从官方目录同步全部开放图片模型,
+ 并按每个模型自己的 Schema 配置多图数量、比例及 1K/2K/4K 档位。
+
+ )}
{providerForm.type === "bfl-image" &&
isBltcyBflBaseUrl(providerForm.baseUrl) && (
@@ -15852,6 +15914,17 @@ export function AdminSettingsClient() {
快速添加 Visionary 图片预设
)}
+ {provider.type === "atlascloud" && (
+
+ )}
{provider.type === "bltcy-video" && (