feat: add local auth billing and usage management
This commit is contained in:
1 parent
f642b5e71f
commit
196fdde83f
119 files changed
+15695
-2650
No files matched your search
@@ -5,7 +5,7 @@ export type JimengCapabilityConfig = {
|
||||
label: string;
|
||||
reqKey: string;
|
||||
enabled: boolean;
|
||||
route: "generate" | "inpaint" | "upscale";
|
||||
route: "generate";
|
||||
description: string;
|
||||
docsUrl: string;
|
||||
};
|
||||
@@ -20,24 +20,6 @@ export function getJimengCapabilities(): Record<ImageCapability, JimengCapabilit
|
||||
route: "generate",
|
||||
description: "面向营销主图、人像写真、平面设计和风格化素材的通用生成能力。",
|
||||
docsUrl: "https://www.volcengine.com/docs/85621/2275082"
|
||||
},
|
||||
"image.inpaint": {
|
||||
id: "image.inpaint",
|
||||
label: "交互编辑 inpainting",
|
||||
reqKey: process.env.JIMENG_IMAGE_INPAINT_REQ_KEY || "jimeng_image2image_dream_inpaint",
|
||||
enabled: true,
|
||||
route: "inpaint",
|
||||
description: "局部重绘与消除笔能力,使用原图和黑白 mask 生成编辑结果。",
|
||||
docsUrl: "https://www.volcengine.com/docs/85621/1976207"
|
||||
},
|
||||
"image.upscale": {
|
||||
id: "image.upscale",
|
||||
label: "智能超清",
|
||||
reqKey: process.env.JIMENG_IMAGE_UPSCALE_REQ_KEY || "jimeng_i2i_seed3_tilesr_cvtob",
|
||||
enabled: true,
|
||||
route: "upscale",
|
||||
description: "对 AIGC 图和低质量图像做 4K/8K 超清与细节增强。",
|
||||
docsUrl: "https://www.volcengine.com/docs/85621/2164806"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -67,42 +49,15 @@ export function buildJimengPayload(
|
||||
reqKey: string,
|
||||
input: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
if (capability === "image.generate") {
|
||||
const payload: Record<string, unknown> = {
|
||||
req_key: reqKey,
|
||||
prompt: String(input.prompt || "").trim()
|
||||
};
|
||||
if (!payload.prompt) throw new Error("Prompt is required for image generation.");
|
||||
const imageUrls = asStringArray(input.imageUrls);
|
||||
if (imageUrls.length) payload.image_urls = imageUrls;
|
||||
assignOptional(payload, input, ["scale", "width", "height", "min_ratio", "max_ratio", "force_single"]);
|
||||
return payload;
|
||||
}
|
||||
|
||||
if (capability === "image.inpaint") {
|
||||
const imageUrls = asStringArray(input.imageUrls);
|
||||
if (imageUrls.length !== 2) {
|
||||
throw new Error("Inpainting requires exactly two public image URLs: original image and mask.");
|
||||
}
|
||||
return {
|
||||
req_key: reqKey,
|
||||
image_urls: imageUrls,
|
||||
prompt: String(input.prompt || "删除").trim() || "删除",
|
||||
...(typeof input.seed === "number" ? { seed: input.seed } : {})
|
||||
};
|
||||
}
|
||||
|
||||
const imageUrls = asStringArray(input.imageUrls);
|
||||
if (imageUrls.length !== 1) {
|
||||
throw new Error("Upscale requires exactly one public image URL.");
|
||||
}
|
||||
const resolution = input.resolution === "8k" ? "8k" : "4k";
|
||||
return {
|
||||
const payload: Record<string, unknown> = {
|
||||
req_key: reqKey,
|
||||
image_urls: imageUrls,
|
||||
resolution,
|
||||
...(typeof input.scale === "number" ? { scale: input.scale } : {})
|
||||
prompt: String(input.prompt || "").trim()
|
||||
};
|
||||
if (!payload.prompt) throw new Error("Prompt is required for image generation.");
|
||||
const imageUrls = asStringArray(input.imageUrls);
|
||||
if (imageUrls.length) payload.image_urls = imageUrls;
|
||||
assignOptional(payload, input, ["scale", "width", "height", "min_ratio", "max_ratio", "force_single"]);
|
||||
return payload;
|
||||
}
|
||||
|
||||
export function buildJimengQueryPayload(reqKey: string, taskId: string): Record<string, unknown> {
|
||||
|
||||
Reference in new issue
Block a user