diff --git a/app/(admin)/settings/_lib/types.ts b/app/(admin)/settings/_lib/types.ts
index 5ba9d781e..e491153fb 100644
--- a/app/(admin)/settings/_lib/types.ts
+++ b/app/(admin)/settings/_lib/types.ts
@@ -86,6 +86,7 @@ export type AdminAiProvider = {
| "bfl-image"
| "ruxa-image"
| "fal-image"
+ | "snapgen-image"
| "openai-image"
| "stepfun-image"
| "midjourney"
diff --git a/app/(admin)/settings/admin-settings-client.tsx b/app/(admin)/settings/admin-settings-client.tsx
index 169063a20..24047ee84 100644
--- a/app/(admin)/settings/admin-settings-client.tsx
+++ b/app/(admin)/settings/admin-settings-client.tsx
@@ -159,6 +159,7 @@ import {
} from "@/lib/ai/detail-agent-model-config";
import { FAL_IMAGE_MODEL_PRESETS } from "@/lib/ai/fal-image-models";
import { RUXA_IMAGE_MODEL_PRESETS } from "@/lib/ai/ruxa-image-models";
+import { SNAPGEN_IMAGE_MODEL_PRESETS } from "@/lib/ai/snapgen-image-models";
import {
formatImageModelCreditDiscountLabel,
getGenerationCreditCostFromImageGenConfig,
@@ -611,6 +612,7 @@ type AiProvider = {
| "bfl-image"
| "ruxa-image"
| "fal-image"
+ | "snapgen-image"
| "openai-image"
| "stepfun-image"
| "midjourney"
@@ -1564,6 +1566,7 @@ const PROVIDER_TYPES = [
{ value: "bfl-image", label: "BFL FLUX.2 图片编辑" },
{ value: "ruxa-image", label: "RUXA生图" },
{ value: "fal-image", label: "FAL 图片生成/编辑" },
+ { value: "snapgen-image", label: "SnapGen 生图" },
{ value: "openai-image", label: "OpenAI 图片兼容" },
{ value: "stepfun-image", label: "阶跃星辰 Step Image Edit" },
{ value: "bltcy-video", label: "柏拉图统一视频" },
@@ -1597,6 +1600,7 @@ const PROVIDER_DEFAULT_BASE_URL: Record = {
"bfl-image": "https://api.bfl.ai",
"ruxa-image": "https://api.ruxa.ai",
"fal-image": "https://fal.run",
+ "snapgen-image": "https://api.snapgen.ai",
"openai-image": "https://api.openai.com/v1",
"stepfun-image": "https://api.stepfun.com",
"bltcy-video": "https://api.bltcy.ai",
@@ -3996,6 +4000,7 @@ export function AdminSettingsClient() {
| "bfl-image"
| "ruxa-image"
| "fal-image"
+ | "snapgen-image"
| "openai-image"
| "stepfun-image"
| "midjourney"
@@ -6232,6 +6237,7 @@ export function AdminSettingsClient() {
const isKreaProvider = providerForm.type === "krea";
const isFalImageProvider = providerForm.type === "fal-image";
const isRuxaImageProvider = providerForm.type === "ruxa-image";
+ const isSnapgenImageProvider = providerForm.type === "snapgen-image";
const isBltcyVideoProvider = providerForm.type === "bltcy-video";
const isLemonProvider =
providerForm.type === "openai" &&
@@ -6363,6 +6369,17 @@ export function AdminSettingsClient() {
}
}
+ if (isNewProvider && isSnapgenImageProvider && providerId) {
+ try {
+ await handleQuickAddSnapgenImageModels(providerId, { skipConfirm: true });
+ } catch (modelError) {
+ console.error("[Auto Add SnapGen Image Models] Error:", modelError);
+ toast.warning(
+ 'SnapGen 生图预设模型添加失败,请手动点击"快速添加 SnapGen 图片预设"按钮'
+ );
+ }
+ }
+
if (isNewProvider && isBltcyVideoProvider && providerId) {
try {
await handleQuickAddBltcyVideoModels(providerId, {
@@ -7291,6 +7308,51 @@ export function AdminSettingsClient() {
}
};
+ const handleQuickAddSnapgenImageModels = async (
+ providerId: string,
+ options?: { skipConfirm?: boolean }
+ ) => {
+ if (
+ !options?.skipConfirm &&
+ !confirm(
+ `将为此服务商添加 ${SNAPGEN_IMAGE_MODEL_PRESETS.length} 个 SnapGen 生图预设模型(Nano Banana Pro、Nano Banana 2、Grok Image、Meta AI Image、GPT Image 2)。\n\n继续吗?`
+ )
+ ) {
+ return;
+ }
+
+ try {
+ toast.info("正在添加 SnapGen 生图预设模型...");
+
+ const response = await fetch("/api/admin/snapgen-image-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 { addedCount, updatedCount, errors } = data;
+ const totalSynced = Number(addedCount || 0) + Number(updatedCount || 0);
+
+ if (totalSynced > 0) {
+ toast.success(`成功同步 ${totalSynced} 个 SnapGen 生图预设模型`);
+ mutateModels();
+ }
+
+ if (errors && errors.length > 0) {
+ toast.warning(`${errors.length} 个模型同步失败`);
+ }
+ } catch (error: any) {
+ console.error("[Quick Add SnapGen Image Models] Error:", error);
+ toast.error(error.message || "添加 SnapGen 生图预设模型失败");
+ }
+ };
+
const handleUseFalImageProviderPreset = () => {
setProviderForm({
id: "",
@@ -15471,6 +15533,12 @@ export function AdminSettingsClient() {
可填写 step-image-edit-2, 支持文生图和图片编辑。
)}
+ {providerForm.type === "snapgen-image" && (
+
+ SnapGen 使用 x-api-key 认证,默认地址
+ https://api.snapgen.ai。保存后会自动添加文档里的全部生图模型预设。
+
+ )}
{providerForm.type === "bfl-image" &&
isBltcyBflBaseUrl(providerForm.baseUrl) && (
@@ -15578,6 +15646,19 @@ export function AdminSettingsClient() {
快速添加 FAL 图片预设
)}
+ {provider.type === "snapgen-image" && (
+
+ )}
{provider.type === "bltcy-video" && (