fix: use single image for OpenAI SDK images.edit (does not support array)
Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
shiyue
2026-03-12 00:31:53 +00:00
parent f9d3e64146
commit ae105d06ef

View File

@@ -160,10 +160,12 @@ export async function generateImageViaOpenAICompat(request: OpenAICompatImageReq
const editModelId = providerKey === 'grok2' ? 'grok-imagine-1.0-edit' : normalizedModelId const editModelId = providerKey === 'grok2' ? 'grok-imagine-1.0-edit' : normalizedModelId
if (referenceImages.length > 0) { if (referenceImages.length > 0) {
// OpenAI SDK 的 images.edit 只接受单个图片文件,不支持数组
// 如果有多张参考图,只使用第一张
const response = await client.images.edit({ const response = await client.images.edit({
model: editModelId, model: editModelId,
prompt, prompt,
image: await Promise.all(referenceImages.map((image, index) => toUploadFile(image, index))), image: await toUploadFile(referenceImages[0], 0),
response_format: responseFormat, response_format: responseFormat,
...(outputFormat ? { output_format: outputFormat } : {}), ...(outputFormat ? { output_format: outputFormat } : {}),
...(quality ? { quality } : {}), ...(quality ? { quality } : {}),