2026-02-07 17:51:18 +08:00

43 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import express from "express";
import { success, error } from "@/lib/responseFormat";
import u from "@/utils";
import { validateFields } from "@/middleware/middleware";
import { z } from "zod";
const router = express.Router();
// 检查语言模型
export default router.post(
"/",
validateFields({
modelName: z.string().optional(),
apiKey: z.string(),
baseURL: z.string().optional(),
manufacturer: z.string(),
}),
async (req, res) => {
const { modelName, apiKey, baseURL, manufacturer } = req.body;
try {
const image = await u.ai.image(
{
prompt:
"一张16:9比例的图片完美等分为2x2四宫格布局各区域无缝衔接\n左上宫格一只可爱的猫毛发蓬松眼睛明亮姿态俏皮\n右上宫格一只友善的狗金毛犬表情愉悦摇着尾巴\n左下宫格一头健壮的牛田园背景目光温和皮毛光泽\n右下宫格一匹骏马姿态优雅鬃毛飘逸肌肉健美\n风格要求四个宫格风格统一色彩鲜艳饱和高清画质细节清晰锐利专业插画风格线条干净统一的左上方光源柔和阴影和谐配色卡通/半写实风格,宫格间用白色或浅灰细线分隔",
imageBase64: [],
aspectRatio: "16:9",
size: "1K",
},
{
model: modelName,
apiKey,
baseURL,
manufacturer,
},
);
res.status(200).send(success(image));
} catch (err) {
const msg = u.error(err).message;
console.error(msg);
res.status(500).send(error(msg));
}
},
);