|
|
@ -83,6 +83,23 @@ function capabilitiesForMediaType(mediaType?: string): ModelCapability[] { |
|
|
return map[mediaType ?? ""] ?? ["text-to-image"]; |
|
|
return map[mediaType ?? ""] ?? ["text-to-image"]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function mergeImageGenerationParameters( |
|
|
|
|
|
parameters: Record<string, unknown> | undefined, |
|
|
|
|
|
aspectRatio: string | undefined, |
|
|
|
|
|
resolution: string | undefined |
|
|
|
|
|
): Record<string, unknown> | undefined { |
|
|
|
|
|
const merged = { ...(parameters || {}) }; |
|
|
|
|
|
if (aspectRatio && merged.aspectRatio === undefined && merged.aspect_ratio === undefined) { |
|
|
|
|
|
merged.aspectRatio = aspectRatio; |
|
|
|
|
|
merged.aspect_ratio = aspectRatio; |
|
|
|
|
|
} |
|
|
|
|
|
if (resolution && merged.resolution === undefined && merged.imageSize === undefined) { |
|
|
|
|
|
merged.resolution = resolution; |
|
|
|
|
|
merged.imageSize = resolution; |
|
|
|
|
|
} |
|
|
|
|
|
return Object.keys(merged).length > 0 ? merged : undefined; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export async function POST(request: NextRequest) { |
|
|
export async function POST(request: NextRequest) { |
|
|
const requestId = Math.random().toString(36).substring(7); |
|
|
const requestId = Math.random().toString(36).substring(7); |
|
|
console.log(`\n[API:${requestId}] ========== NEW GENERATE REQUEST ==========`); |
|
|
console.log(`\n[API:${requestId}] ========== NEW GENERATE REQUEST ==========`); |
|
|
@ -162,7 +179,7 @@ export async function POST(request: NextRequest) { |
|
|
}, |
|
|
}, |
|
|
prompt: prompt || "", |
|
|
prompt: prompt || "", |
|
|
images: images ? [...images] : [], |
|
|
images: images ? [...images] : [], |
|
|
parameters, |
|
|
parameters: mergeImageGenerationParameters(parameters, aspectRatio, resolution), |
|
|
dynamicInputs, |
|
|
dynamicInputs, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|